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