MemdepMiscompile.ll 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ; RUN: opt < %s -basicaa -gvn -S | FileCheck %s
  2. 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"
  3. target triple = "x86_64-apple-macosx10.7.0"
  4. ; rdar://12801584
  5. ; Value of %shouldExit can be changed by RunInMode.
  6. ; Make sure we do not replace load %shouldExit in while.cond.backedge
  7. ; with a phi node where the value from while.body is 0.
  8. define i32 @test() nounwind ssp {
  9. entry:
  10. ; CHECK: test()
  11. ; CHECK: while.body:
  12. ; CHECK: call void @RunInMode
  13. ; CHECK: br i1 %tobool, label %while.cond.backedge, label %if.then
  14. ; CHECK: while.cond.backedge:
  15. ; CHECK: load i32, i32* %shouldExit
  16. ; CHECK: br i1 %cmp, label %while.body
  17. %shouldExit = alloca i32, align 4
  18. %tasksIdle = alloca i32, align 4
  19. store i32 0, i32* %shouldExit, align 4
  20. store i32 0, i32* %tasksIdle, align 4
  21. call void @CTestInitialize(i32* %tasksIdle) nounwind
  22. %0 = load i32, i32* %shouldExit, align 4
  23. %cmp1 = icmp eq i32 %0, 0
  24. br i1 %cmp1, label %while.body.lr.ph, label %while.end
  25. while.body.lr.ph:
  26. br label %while.body
  27. while.body:
  28. call void @RunInMode(i32 100) nounwind
  29. %1 = load i32, i32* %tasksIdle, align 4
  30. %tobool = icmp eq i32 %1, 0
  31. br i1 %tobool, label %while.cond.backedge, label %if.then
  32. if.then:
  33. store i32 0, i32* %tasksIdle, align 4
  34. call void @TimerCreate(i32* %shouldExit) nounwind
  35. br label %while.cond.backedge
  36. while.cond.backedge:
  37. %2 = load i32, i32* %shouldExit, align 4
  38. %cmp = icmp eq i32 %2, 0
  39. br i1 %cmp, label %while.body, label %while.cond.while.end_crit_edge
  40. while.cond.while.end_crit_edge:
  41. br label %while.end
  42. while.end:
  43. ret i32 0
  44. }
  45. declare void @CTestInitialize(i32*)
  46. declare void @RunInMode(i32)
  47. declare void @TimerCreate(i32*)