dangling-block-address.ll 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. ; RUN: opt < %s -internalize -ipsccp -S | FileCheck %s
  2. ; PR5569
  3. ; IPSCCP should prove that the blocks are dead and delete them, and
  4. ; properly handle the dangling blockaddress constants.
  5. ; CHECK: @bar.l = internal constant [2 x i8*] [i8* inttoptr (i32 1 to i8*), i8* inttoptr (i32 1 to i8*)]
  6. @code = global [5 x i32] [i32 0, i32 0, i32 0, i32 0, i32 1], align 4 ; <[5 x i32]*> [#uses=0]
  7. @bar.l = internal constant [2 x i8*] [i8* blockaddress(@bar, %lab0), i8* blockaddress(@bar, %end)] ; <[2 x i8*]*> [#uses=1]
  8. define void @foo(i32 %x) nounwind readnone {
  9. entry:
  10. %b = alloca i32, align 4 ; <i32*> [#uses=1]
  11. store volatile i32 -1, i32* %b
  12. ret void
  13. }
  14. define void @bar(i32* nocapture %pc) nounwind readonly {
  15. entry:
  16. br label %indirectgoto
  17. lab0: ; preds = %indirectgoto
  18. %indvar.next = add i32 %indvar, 1 ; <i32> [#uses=1]
  19. br label %indirectgoto
  20. end: ; preds = %indirectgoto
  21. ret void
  22. indirectgoto: ; preds = %lab0, %entry
  23. %indvar = phi i32 [ %indvar.next, %lab0 ], [ 0, %entry ] ; <i32> [#uses=2]
  24. %pc.addr.0 = getelementptr i32, i32* %pc, i32 %indvar ; <i32*> [#uses=1]
  25. %tmp1.pn = load i32, i32* %pc.addr.0 ; <i32> [#uses=1]
  26. %indirect.goto.dest.in = getelementptr inbounds [2 x i8*], [2 x i8*]* @bar.l, i32 0, i32 %tmp1.pn ; <i8**> [#uses=1]
  27. %indirect.goto.dest = load i8*, i8** %indirect.goto.dest.in ; <i8*> [#uses=1]
  28. indirectbr i8* %indirect.goto.dest, [label %lab0, label %end]
  29. }
  30. define i32 @main() nounwind readnone {
  31. entry:
  32. ret i32 0
  33. }