volatile-phioper.ll 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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-LABEL: @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. define void @test(i8** nocapture %PeiServices) #0 {
  18. entry:
  19. %call = tail call i32 (...) @Trace() #2
  20. %tobool = icmp eq i32 %call, 0
  21. br i1 %tobool, label %while.body, label %if.then
  22. if.then: ; preds = %entry
  23. %call1 = tail call i32 (...) @Trace() #2
  24. br label %while.body
  25. while.body: ; preds = %entry, %if.then, %while.body
  26. %Addr.017 = phi i8* [ %incdec.ptr, %while.body ], [ null, %if.then ], [ null, %entry ]
  27. %x.016 = phi i8 [ %inc, %while.body ], [ 0, %if.then ], [ 0, %entry ]
  28. %inc = add i8 %x.016, 1
  29. %incdec.ptr = getelementptr inbounds i8, i8* %Addr.017, i64 1
  30. store volatile i8 %x.016, i8* %Addr.017, align 1
  31. %0 = ptrtoint i8* %incdec.ptr to i64
  32. %1 = trunc i64 %0 to i32
  33. %cmp = icmp ult i32 %1, 4096
  34. br i1 %cmp, label %while.body, label %end
  35. end:
  36. ret void
  37. }
  38. declare i32 @Trace(...) #1
  39. 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" }
  40. attributes #1 = { "fp-contract-model"="standard" "no-frame-pointer-elim" "no-frame-pointer-elim-non-leaf" "relocation-model"="pic" "ssp-buffers-size"="8" }
  41. attributes #2 = { nounwind }
  42. !0 = !{i32 1039}