struct-geps.ll 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. ; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
  2. target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
  3. %struct = type { i32, i32, i32 }
  4. ; CHECK-LABEL: test_simple
  5. ; CHECK-DAG: PartialAlias: %struct* %st, i32* %x
  6. ; CHECK-DAG: PartialAlias: %struct* %st, i32* %y
  7. ; CHECK-DAG: PartialAlias: %struct* %st, i32* %z
  8. ; CHECK-DAG: NoAlias: i32* %x, i32* %y
  9. ; CHECK-DAG: NoAlias: i32* %x, i32* %z
  10. ; CHECK-DAG: NoAlias: i32* %y, i32* %z
  11. ; CHECK-DAG: PartialAlias: %struct* %st, %struct* %y_12
  12. ; CHECK-DAG: PartialAlias: %struct* %y_12, i32* %x
  13. ; CHECK-DAG: PartialAlias: i32* %x, i80* %y_10
  14. ; CHECK-DAG: PartialAlias: %struct* %st, i64* %y_8
  15. ; CHECK-DAG: PartialAlias: i32* %z, i64* %y_8
  16. ; CHECK-DAG: NoAlias: i32* %x, i64* %y_8
  17. ; CHECK-DAG: MustAlias: %struct* %y_12, i32* %y
  18. ; CHECK-DAG: MustAlias: i32* %y, i64* %y_8
  19. ; CHECK-DAG: MustAlias: i32* %y, i80* %y_10
  20. define void @test_simple(%struct* %st, i64 %i, i64 %j, i64 %k) {
  21. %x = getelementptr %struct, %struct* %st, i64 %i, i32 0
  22. %y = getelementptr %struct, %struct* %st, i64 %j, i32 1
  23. %z = getelementptr %struct, %struct* %st, i64 %k, i32 2
  24. %y_12 = bitcast i32* %y to %struct*
  25. %y_10 = bitcast i32* %y to i80*
  26. %y_8 = bitcast i32* %y to i64*
  27. ret void
  28. }
  29. ; CHECK-LABEL: test_in_array
  30. ; CHECK-DAG: PartialAlias: [1 x %struct]* %st, i32* %x
  31. ; CHECK-DAG: PartialAlias: [1 x %struct]* %st, i32* %y
  32. ; CHECK-DAG: PartialAlias: [1 x %struct]* %st, i32* %z
  33. ; CHECK-DAG: NoAlias: i32* %x, i32* %y
  34. ; CHECK-DAG: NoAlias: i32* %x, i32* %z
  35. ; CHECK-DAG: NoAlias: i32* %y, i32* %z
  36. ; CHECK-DAG: PartialAlias: %struct* %y_12, [1 x %struct]* %st
  37. ; CHECK-DAG: PartialAlias: %struct* %y_12, i32* %x
  38. ; CHECK-DAG: PartialAlias: i32* %x, i80* %y_10
  39. ; CHECK-DAG: PartialAlias: [1 x %struct]* %st, i64* %y_8
  40. ; CHECK-DAG: PartialAlias: i32* %z, i64* %y_8
  41. ; CHECK-DAG: NoAlias: i32* %x, i64* %y_8
  42. ; CHECK-DAG: MustAlias: %struct* %y_12, i32* %y
  43. ; CHECK-DAG: MustAlias: i32* %y, i64* %y_8
  44. ; CHECK-DAG: MustAlias: i32* %y, i80* %y_10
  45. define void @test_in_array([1 x %struct]* %st, i64 %i, i64 %j, i64 %k, i64 %i1, i64 %j1, i64 %k1) {
  46. %x = getelementptr [1 x %struct], [1 x %struct]* %st, i64 %i, i64 %i1, i32 0
  47. %y = getelementptr [1 x %struct], [1 x %struct]* %st, i64 %j, i64 %j1, i32 1
  48. %z = getelementptr [1 x %struct], [1 x %struct]* %st, i64 %k, i64 %k1, i32 2
  49. %y_12 = bitcast i32* %y to %struct*
  50. %y_10 = bitcast i32* %y to i80*
  51. %y_8 = bitcast i32* %y to i64*
  52. ret void
  53. }
  54. ; CHECK-LABEL: test_in_3d_array
  55. ; CHECK-DAG: PartialAlias: [1 x [1 x [1 x %struct]]]* %st, i32* %x
  56. ; CHECK-DAG: PartialAlias: [1 x [1 x [1 x %struct]]]* %st, i32* %y
  57. ; CHECK-DAG: PartialAlias: [1 x [1 x [1 x %struct]]]* %st, i32* %z
  58. ; CHECK-DAG: NoAlias: i32* %x, i32* %y
  59. ; CHECK-DAG: NoAlias: i32* %x, i32* %z
  60. ; CHECK-DAG: NoAlias: i32* %y, i32* %z
  61. ; CHECK-DAG: PartialAlias: %struct* %y_12, [1 x [1 x [1 x %struct]]]* %st
  62. ; CHECK-DAG: PartialAlias: %struct* %y_12, i32* %x
  63. ; CHECK-DAG: PartialAlias: i32* %x, i80* %y_10
  64. ; CHECK-DAG: PartialAlias: [1 x [1 x [1 x %struct]]]* %st, i64* %y_8
  65. ; CHECK-DAG: PartialAlias: i32* %z, i64* %y_8
  66. ; CHECK-DAG: NoAlias: i32* %x, i64* %y_8
  67. ; CHECK-DAG: MustAlias: %struct* %y_12, i32* %y
  68. ; CHECK-DAG: MustAlias: i32* %y, i64* %y_8
  69. ; CHECK-DAG: MustAlias: i32* %y, i80* %y_10
  70. define void @test_in_3d_array([1 x [1 x [1 x %struct]]]* %st, i64 %i, i64 %j, i64 %k, i64 %i1, i64 %j1, i64 %k1, i64 %i2, i64 %j2, i64 %k2, i64 %i3, i64 %j3, i64 %k3) {
  71. %x = getelementptr [1 x [1 x [1 x %struct]]], [1 x [1 x [1 x %struct]]]* %st, i64 %i, i64 %i1, i64 %i2, i64 %i3, i32 0
  72. %y = getelementptr [1 x [1 x [1 x %struct]]], [1 x [1 x [1 x %struct]]]* %st, i64 %j, i64 %j1, i64 %j2, i64 %j3, i32 1
  73. %z = getelementptr [1 x [1 x [1 x %struct]]], [1 x [1 x [1 x %struct]]]* %st, i64 %k, i64 %k1, i64 %k2, i64 %k3, i32 2
  74. %y_12 = bitcast i32* %y to %struct*
  75. %y_10 = bitcast i32* %y to i80*
  76. %y_8 = bitcast i32* %y to i64*
  77. ret void
  78. }
  79. ; CHECK-LABEL: test_same_underlying_object_same_indices
  80. ; CHECK-DAG: NoAlias: i32* %x, i32* %x2
  81. ; CHECK-DAG: NoAlias: i32* %y, i32* %y2
  82. ; CHECK-DAG: NoAlias: i32* %z, i32* %z2
  83. ; CHECK-DAG: PartialAlias: i32* %x, i32* %y2
  84. ; CHECK-DAG: PartialAlias: i32* %x, i32* %z2
  85. ; CHECK-DAG: PartialAlias: i32* %x2, i32* %y
  86. ; CHECK-DAG: PartialAlias: i32* %y, i32* %z2
  87. ; CHECK-DAG: PartialAlias: i32* %x2, i32* %z
  88. ; CHECK-DAG: PartialAlias: i32* %y2, i32* %z
  89. define void @test_same_underlying_object_same_indices(%struct* %st, i64 %i, i64 %j, i64 %k) {
  90. %st2 = getelementptr %struct, %struct* %st, i32 10
  91. %x2 = getelementptr %struct, %struct* %st2, i64 %i, i32 0
  92. %y2 = getelementptr %struct, %struct* %st2, i64 %j, i32 1
  93. %z2 = getelementptr %struct, %struct* %st2, i64 %k, i32 2
  94. %x = getelementptr %struct, %struct* %st, i64 %i, i32 0
  95. %y = getelementptr %struct, %struct* %st, i64 %j, i32 1
  96. %z = getelementptr %struct, %struct* %st, i64 %k, i32 2
  97. ret void
  98. }
  99. ; CHECK-LABEL: test_same_underlying_object_different_indices
  100. ; CHECK-DAG: PartialAlias: i32* %x, i32* %x2
  101. ; CHECK-DAG: PartialAlias: i32* %y, i32* %y2
  102. ; CHECK-DAG: PartialAlias: i32* %z, i32* %z2
  103. ; CHECK-DAG: PartialAlias: i32* %x, i32* %y2
  104. ; CHECK-DAG: PartialAlias: i32* %x, i32* %z2
  105. ; CHECK-DAG: PartialAlias: i32* %x2, i32* %y
  106. ; CHECK-DAG: PartialAlias: i32* %y, i32* %z2
  107. ; CHECK-DAG: PartialAlias: i32* %x2, i32* %z
  108. ; CHECK-DAG: PartialAlias: i32* %y2, i32* %z
  109. define void @test_same_underlying_object_different_indices(%struct* %st, i64 %i1, i64 %j1, i64 %k1, i64 %i2, i64 %k2, i64 %j2) {
  110. %st2 = getelementptr %struct, %struct* %st, i32 10
  111. %x2 = getelementptr %struct, %struct* %st2, i64 %i2, i32 0
  112. %y2 = getelementptr %struct, %struct* %st2, i64 %j2, i32 1
  113. %z2 = getelementptr %struct, %struct* %st2, i64 %k2, i32 2
  114. %x = getelementptr %struct, %struct* %st, i64 %i1, i32 0
  115. %y = getelementptr %struct, %struct* %st, i64 %j1, i32 1
  116. %z = getelementptr %struct, %struct* %st, i64 %k1, i32 2
  117. ret void
  118. }
  119. %struct2 = type { [1 x { i32, i32 }], [2 x { i32 }] }
  120. ; CHECK-LABEL: test_struct_in_array
  121. ; CHECK-DAG: MustAlias: i32* %x, i32* %y
  122. define void @test_struct_in_array(%struct2* %st, i64 %i, i64 %j, i64 %k) {
  123. %x = getelementptr %struct2, %struct2* %st, i32 0, i32 1, i32 1, i32 0
  124. %y = getelementptr %struct2, %struct2* %st, i32 0, i32 0, i32 1, i32 1
  125. ret void
  126. }