use-list-order.ll 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. ; RUN: verify-uselistorder < %s
  2. @a = global [4 x i1] [i1 0, i1 1, i1 0, i1 1]
  3. @b = alias i1* getelementptr ([4 x i1], [4 x i1]* @a, i64 0, i64 2)
  4. ; Check use-list order of constants used by globals.
  5. @glob1 = global i5 7
  6. @glob2 = global i5 7
  7. @glob3 = global i5 7
  8. ; Check use-list order between variables and aliases.
  9. @target = global i3 zeroinitializer
  10. @alias1 = alias i3* @target
  11. @alias2 = alias i3* @target
  12. @alias3 = alias i3* @target
  13. @var1 = global i3* @target
  14. @var2 = global i3* @target
  15. @var3 = global i3* @target
  16. ; Check use-list order for a global when used both by a global and in a
  17. ; function.
  18. @globalAndFunction = global i4 4
  19. @globalAndFunctionGlobalUser = global i4* @globalAndFunction
  20. ; Check use-list order for constants used by globals that are themselves used
  21. ; as aliases. This confirms that this globals are recognized as GlobalValues
  22. ; (not general constants).
  23. @const.global = global i63 0
  24. @const.global.ptr = global i63* @const.global
  25. @const.global.2 = global i63 0
  26. ; Same as above, but for aliases.
  27. @const.target = global i62 1
  28. @const.alias = alias i62* @const.target
  29. @const.alias.ptr = alias i62* @const.alias
  30. @const.alias.2 = alias i62* @const.target
  31. define i64 @f(i64 %f) {
  32. entry:
  33. %sum = add i64 %f, 0
  34. ret i64 %sum
  35. }
  36. define i64 @g(i64 %g) {
  37. entry:
  38. %sum = add i64 %g, 0
  39. ret i64 %sum
  40. }
  41. define i64 @h(i64 %h) {
  42. entry:
  43. %sum = add i64 %h, 0
  44. ret i64 %sum
  45. }
  46. define i64 @i(i64 %i) {
  47. entry:
  48. %sum = add i64 %i, 1
  49. ret i64 %sum
  50. }
  51. define i64 @j(i64 %j) {
  52. entry:
  53. %sum = add i64 %j, 1
  54. ret i64 %sum
  55. }
  56. define i64 @k(i64 %k) {
  57. entry:
  58. %sum = add i64 %k, 1
  59. ret i64 %sum
  60. }
  61. define i64 @l(i64 %l) {
  62. entry:
  63. %sum = add i64 %l, 1
  64. ret i64 %sum
  65. }
  66. define i1 @loadb() {
  67. entry:
  68. %b = load i1, i1* @b
  69. ret i1 %b
  70. }
  71. define i1 @loada() {
  72. entry:
  73. %a = load i1, i1* getelementptr ([4 x i1], [4 x i1]* @a, i64 0, i64 2)
  74. ret i1 %a
  75. }
  76. define i32 @f32(i32 %a, i32 %b, i32 %c, i32 %d) {
  77. entry:
  78. br label %first
  79. second:
  80. %eh = mul i32 %e, %h
  81. %sum = add i32 %eh, %ef
  82. br label %exit
  83. exit:
  84. %product = phi i32 [%ef, %first], [%sum, %second]
  85. ret i32 %product
  86. first:
  87. %e = add i32 %a, 7
  88. %f = add i32 %b, 7
  89. %g = add i32 %c, 8
  90. %h = add i32 %d, 8
  91. %ef = mul i32 %e, %f
  92. %gh = mul i32 %g, %h
  93. %gotosecond = icmp slt i32 %gh, -9
  94. br i1 %gotosecond, label %second, label %exit
  95. }
  96. define i4 @globalAndFunctionFunctionUser() {
  97. entry:
  98. %local = load i4, i4* @globalAndFunction
  99. ret i4 %local
  100. }
  101. ; Check for when an instruction is its own user.
  102. define void @selfUser(i1 %a) {
  103. entry:
  104. ret void
  105. loop1:
  106. br label %loop2
  107. loop2:
  108. %var = phi i32 [ %var, %loop1 ], [ %var, %loop2 ]
  109. br label %loop2
  110. }
  111. ; Check that block addresses work.
  112. @ba1 = constant i8* blockaddress (@bafunc1, %bb)
  113. @ba2 = constant i8* getelementptr (i8, i8* blockaddress (@bafunc2, %bb), i61 0)
  114. @ba3 = constant i8* getelementptr (i8, i8* blockaddress (@bafunc2, %bb), i61 0)
  115. define i8* @babefore() {
  116. ret i8* getelementptr (i8, i8* blockaddress (@bafunc2, %bb), i61 0)
  117. bb1:
  118. ret i8* blockaddress (@bafunc1, %bb)
  119. bb2:
  120. ret i8* blockaddress (@bafunc3, %bb)
  121. }
  122. define void @bafunc1() {
  123. unreachable
  124. bb:
  125. unreachable
  126. }
  127. define void @bafunc2() {
  128. unreachable
  129. bb:
  130. unreachable
  131. }
  132. define void @bafunc3() {
  133. unreachable
  134. bb:
  135. unreachable
  136. }
  137. define i8* @baafter() {
  138. ret i8* blockaddress (@bafunc2, %bb)
  139. bb1:
  140. ret i8* blockaddress (@bafunc1, %bb)
  141. bb2:
  142. ret i8* blockaddress (@bafunc3, %bb)
  143. }