Andrew Trick | a0a5ca0 | 2013-03-07 01:03:35 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -simplifycfg -S | FileCheck %s |
| 2 | ; |
| 3 | ; rdar:13349374 |
| 4 | ; |
| 5 | ; SimplifyCFG should not eliminate blocks with volatile stores. |
| 6 | ; Essentially, volatile needs to be backdoor that tells the optimizer |
| 7 | ; it can no longer use language standard as an excuse. The compiler |
| 8 | ; needs to expose the volatile access to the platform. |
| 9 | ; |
| 10 | ; CHECK: @test |
| 11 | ; CHECK: entry: |
| 12 | ; CHECK: @Trace |
| 13 | ; CHECK: while.body: |
| 14 | ; CHECK: store volatile |
| 15 | ; CHECK: end: |
| 16 | target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" |
| 17 | |
| 18 | define void @test(i8** nocapture %PeiServices) #0 { |
| 19 | entry: |
| 20 | %call = tail call i32 (...)* @Trace() #2 |
| 21 | %tobool = icmp eq i32 %call, 0 |
| 22 | br i1 %tobool, label %while.body, label %if.then |
| 23 | |
| 24 | if.then: ; preds = %entry |
| 25 | %call1 = tail call i32 (...)* @Trace() #2 |
| 26 | br label %while.body |
| 27 | |
| 28 | while.body: ; preds = %entry, %if.then, %while.body |
| 29 | %Addr.017 = phi i8* [ %incdec.ptr, %while.body ], [ null, %if.then ], [ null, %entry ] |
| 30 | %x.016 = phi i8 [ %inc, %while.body ], [ 0, %if.then ], [ 0, %entry ] |
| 31 | %inc = add i8 %x.016, 1 |
| 32 | %incdec.ptr = getelementptr inbounds i8* %Addr.017, i64 1 |
| 33 | store volatile i8 %x.016, i8* %Addr.017, align 1 |
| 34 | %0 = ptrtoint i8* %incdec.ptr to i64 |
| 35 | %1 = trunc i64 %0 to i32 |
| 36 | %cmp = icmp ult i32 %1, 4096 |
| 37 | br i1 %cmp, label %while.body, label %end |
| 38 | |
| 39 | end: |
| 40 | ret void |
| 41 | } |
| 42 | declare i32 @Trace(...) #1 |
| 43 | |
| 44 | attributes #0 = { nounwind ssp uwtable "fp-contract-model"="standard" "no-frame-pointer-elim" "no-frame-pointer-elim-non-leaf" "realign-stack" "relocation-model"="pic" "ssp-buffers-size"="8" } |
| 45 | attributes #1 = { "fp-contract-model"="standard" "no-frame-pointer-elim" "no-frame-pointer-elim-non-leaf" "realign-stack" "relocation-model"="pic" "ssp-buffers-size"="8" } |
| 46 | attributes #2 = { nounwind } |
| 47 | |
| 48 | !0 = metadata !{i32 1039} |