aliastest.ll 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. ; RUN: opt < %s -tbaa -basicaa -gvn -S | FileCheck %s
  2. ; Test that basic alias queries work.
  3. ; CHECK: @test0_yes
  4. ; CHECK: add i8 %x, %x
  5. define i8 @test0_yes(i8* %a, i8* %b) nounwind {
  6. %x = load i8, i8* %a, !tbaa !1
  7. store i8 0, i8* %b, !tbaa !2
  8. %y = load i8, i8* %a, !tbaa !1
  9. %z = add i8 %x, %y
  10. ret i8 %z
  11. }
  12. ; CHECK: @test0_no
  13. ; CHECK: add i8 %x, %y
  14. define i8 @test0_no(i8* %a, i8* %b) nounwind {
  15. %x = load i8, i8* %a, !tbaa !3
  16. store i8 0, i8* %b, !tbaa !4
  17. %y = load i8, i8* %a, !tbaa !3
  18. %z = add i8 %x, %y
  19. ret i8 %z
  20. }
  21. ; Test that basic invariant-memory queries work.
  22. ; CHECK: @test1_yes
  23. ; CHECK: add i8 %x, %x
  24. define i8 @test1_yes(i8* %a, i8* %b) nounwind {
  25. %x = load i8, i8* %a, !tbaa !5
  26. store i8 0, i8* %b
  27. %y = load i8, i8* %a, !tbaa !5
  28. %z = add i8 %x, %y
  29. ret i8 %z
  30. }
  31. ; CHECK: @test1_no
  32. ; CHECK: add i8 %x, %y
  33. define i8 @test1_no(i8* %a, i8* %b) nounwind {
  34. %x = load i8, i8* %a, !tbaa !6
  35. store i8 0, i8* %b
  36. %y = load i8, i8* %a, !tbaa !6
  37. %z = add i8 %x, %y
  38. ret i8 %z
  39. }
  40. ; Root note.
  41. !0 = !{ }
  42. ; Some type.
  43. !1 = !{!7, !7, i64 0}
  44. ; Some other non-aliasing type.
  45. !2 = !{!8, !8, i64 0}
  46. ; Some type.
  47. !3 = !{!9, !9, i64 0}
  48. ; Some type in a different type system.
  49. !4 = !{!10, !10, i64 0}
  50. ; Invariant memory.
  51. !5 = !{!11, !11, i64 0, i1 1}
  52. ; Not invariant memory.
  53. !6 = !{!11, !11, i64 0, i1 0}
  54. !7 = !{ !"foo", !0 }
  55. !8 = !{ !"bar", !0 }
  56. !9 = !{ !"foo", !0 }
  57. !10 = !{ !"bar", !"different" }
  58. !11 = !{ !"qux", !0}