OLD | NEW |
(Empty) | |
| 1 ; RUN: %p2i -i %s --filetype=obj --assemble --disassemble --args -O2 -nonsfi \ |
| 2 ; RUN: | FileCheck %s |
| 3 |
| 4 @G1 = internal global [4 x i8] zeroinitializer, align 4 |
| 5 |
| 6 define internal void @testCallRegular() { |
| 7 entry: |
| 8 call void @testCallRegular() |
| 9 ret void |
| 10 } |
| 11 ; Expect a simple direct call to testCallRegular. |
| 12 ; CHECK-LABEL: testCallRegular |
| 13 ; CHECK: call {{.*}} R_386_PC32 testCallRegular |
| 14 |
| 15 define internal double @testCallBuiltin(double %val) { |
| 16 entry: |
| 17 %result = frem double %val, %val |
| 18 ret double %result |
| 19 } |
| 20 ; Expect a simple direct call to fmod. |
| 21 ; CHECK-LABEL: testCallBuiltin |
| 22 ; CHECK: call {{.*}} R_386_PC32 fmod |
| 23 |
| 24 define internal i32 @testLoadBasic() { |
| 25 entry: |
| 26 %a = bitcast [4 x i8]* @G1 to i32* |
| 27 %b = load i32, i32* %a, align 1 |
| 28 ret i32 %b |
| 29 } |
| 30 ; Expect a load with a R_386_GOTOFF relocation. |
| 31 ; CHECK-LABEL: testLoadBasic |
| 32 ; CHECK: mov {{.*}} R_386_GOTOFF G1 |
| 33 |
| 34 define internal i32 @testLoadFixedOffset() { |
| 35 entry: |
| 36 %a = ptrtoint [4 x i8]* @G1 to i32 |
| 37 %a1 = add i32 %a, 4 |
| 38 %a2 = inttoptr i32 %a1 to i32* |
| 39 %b = load i32, i32* %a2, align 1 |
| 40 ret i32 %b |
| 41 } |
| 42 ; Expect a load with a R_386_GOTOFF relocation plus an immediate offset. |
| 43 ; CHECK-LABEL: testLoadFixedOffset |
| 44 ; CHECK: mov {{.*}}+0x4] {{.*}} R_386_GOTOFF G1 |
| 45 |
| 46 define internal i32 @testLoadIndexed(i32 %idx) { |
| 47 entry: |
| 48 %a = ptrtoint [4 x i8]* @G1 to i32 |
| 49 %a0 = mul i32 %idx, 4 |
| 50 %a1 = add i32 %a0, 12 |
| 51 %a2 = add i32 %a1, %a |
| 52 %a3 = inttoptr i32 %a2 to i32* |
| 53 %b = load i32, i32* %a3, align 1 |
| 54 ret i32 %b |
| 55 } |
| 56 ; CHECK-LABEL: testLoadIndexed |
| 57 |
| 58 define internal i32 @testLoadIndexedBase(i32 %base, i32 %idx) { |
| 59 entry: |
| 60 %a = ptrtoint [4 x i8]* @G1 to i32 |
| 61 %a0 = mul i32 %idx, 4 |
| 62 %a1 = add i32 %a0, 12 |
| 63 %a2 = add i32 %a1, %a |
| 64 %a3 = add i32 %a2, %base |
| 65 %a4 = inttoptr i32 %a3 to i32* |
| 66 %b = load i32, i32* %a4, align 1 |
| 67 ret i32 %b |
| 68 } |
| 69 ; CHECK-LABEL: testLoadIndexedBase |
| 70 |
| 71 define internal i32 @testLoadOpt() { |
| 72 entry: |
| 73 %a = bitcast [4 x i8]* @G1 to i32* |
| 74 %b = load i32, i32* %a, align 1 |
| 75 %c = bitcast [4 x i8]* @G1 to i32* |
| 76 %d = load i32, i32* %a, align 1 |
| 77 %e = add i32 %b, %d |
| 78 ret i32 %e |
| 79 } |
| 80 ; Expect a load-folding optimization with a R_386_GOTOFF relocation. |
| 81 ; CHECK-LABEL: testLoadOpt |
| 82 |
| 83 define internal void @testRMW() { |
| 84 entry: |
| 85 %a = bitcast [4 x i8]* @G1 to i32* |
| 86 %b = load i32, i32* %a, align 1 |
| 87 %c = add i32 %b, 1 |
| 88 store i32 %c, i32* %a, align 1 |
| 89 ret void |
| 90 } |
| 91 ; Expect an RMW optimization with a R_386_GOTOFF relocation. |
| 92 ; CHECK-LABEL: testRMW |
OLD | NEW |