1 ; RUN: opt < %s -simplifycfg -S | FileCheck %s
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.
14 ; CHECK: store volatile
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"
18 define void @test(i8** nocapture %PeiServices) #0 {
20 %call = tail call i32 (...) @Trace() #2
21 %tobool = icmp eq i32 %call, 0
22 br i1 %tobool, label %while.body, label %if.then
24 if.then: ; preds = %entry
25 %call1 = tail call i32 (...) @Trace() #2
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, 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
42 declare i32 @Trace(...) #1
44 attributes #0 = { nounwind ssp uwtable "fp-contract-model"="standard" "no-frame-pointer-elim" "no-frame-pointer-elim-non-leaf" "relocation-model"="pic" "ssp-buffers-size"="8" }
45 attributes #1 = { "fp-contract-model"="standard" "no-frame-pointer-elim" "no-frame-pointer-elim-non-leaf" "relocation-model"="pic" "ssp-buffers-size"="8" }
46 attributes #2 = { nounwind }