OLD | NEW |
---|---|
1 ; RUN: %p2i -i %s --filetype=obj --assemble --disassemble --args -O2 -nonsfi=1 \ | 1 ; RUN: %p2i -i %s --filetype=obj --assemble --disassemble --args -O2 -nonsfi=1 \ |
2 ; RUN: | FileCheck --check-prefix=NONSFI %s | 2 ; RUN: | FileCheck --check-prefix=NONSFI %s |
3 ; RUN: %p2i -i %s --filetype=obj --assemble --disassemble --args -O2 -nonsfi=0 \ | 3 ; RUN: %p2i -i %s --filetype=obj --assemble --disassemble --args -O2 -nonsfi=0 \ |
4 ; RUN: | FileCheck --check-prefix=DEFAULT %s | 4 ; RUN: | FileCheck --check-prefix=DEFAULT %s |
5 | 5 |
6 @G1 = internal global [4 x i8] zeroinitializer, align 4 | 6 @G1 = internal global [4 x i8] zeroinitializer, align 4 |
7 @G2 = internal global [4 x i8] zeroinitializer, align 4 | 7 @G2 = internal global [4 x i8] zeroinitializer, align 4 |
8 | 8 |
9 define internal void @testCallRegular() { | 9 define internal void @testCallRegular() { |
10 entry: | 10 entry: |
11 call void @testCallRegular() | 11 call void @testCallRegular() |
12 ret void | 12 ret void |
13 } | 13 } |
14 ; Expect a simple direct call to testCallRegular. | 14 ; Expect a simple direct call to testCallRegular. |
15 ; NONSFI-LABEL: testCallRegular | 15 ; NONSFI-LABEL: testCallRegular |
16 ; NONSFI: call {{.*}} R_386_PC32 testCallRegular | 16 ; NONSFI: call {{.*}} {{(R_386_PC32 testCallRegular)?}} |
Jim Stichnoth
2016/01/10 03:08:56
This regex is a little silly.
R_386_PC32 test
sehr
2016/01/11 21:49:48
Done.
| |
17 ; DEFAULT-LABEL: testCallRegular | 17 ; DEFAULT-LABEL: testCallRegular |
18 | 18 |
19 define internal double @testCallBuiltin(double %val) { | 19 define internal double @testCallBuiltin(double %val) { |
20 entry: | 20 entry: |
21 %result = frem double %val, %val | 21 %result = frem double %val, %val |
22 ret double %result | 22 ret double %result |
23 } | 23 } |
24 ; Expect a simple direct call to fmod. | 24 ; Expect a simple direct call to fmod. |
25 ; NONSFI-LABEL: testCallBuiltin | 25 ; NONSFI-LABEL: testCallBuiltin |
26 ; NONSFI: call {{.*}} R_386_PC32 fmod | 26 ; NONSFI: call {{.*}} R_386_PC32 fmod |
27 ; DEFAULT-LABEL: testCallBuiltin | 27 ; DEFAULT-LABEL: testCallBuiltin |
28 | 28 |
29 define internal i32 @testLoadBasic() { | 29 define internal i32 @testLoadBasic() { |
30 entry: | 30 entry: |
31 %a = bitcast [4 x i8]* @G1 to i32* | 31 %a = bitcast [4 x i8]* @G1 to i32* |
32 %b = load i32, i32* %a, align 1 | 32 %b = load i32, i32* %a, align 1 |
33 ret i32 %b | 33 ret i32 %b |
34 } | 34 } |
35 ; Expect a load with a R_386_GOTOFF relocation. | 35 ; Expect a load with a R_386_GOTOFF relocation. |
36 ; NONSFI-LABEL: testLoadBasic | 36 ; NONSFI-LABEL: testLoadBasic |
37 ; NONSFI: mov {{.*}} R_386_GOTOFF G1 | 37 ; NONSFI: mov {{.*}} R_386_GOTOFF {{G1|.bss}} |
38 ; DEFAULT-LABEL: testLoadBasic | 38 ; DEFAULT-LABEL: testLoadBasic |
39 | 39 |
40 define internal i32 @testLoadFixedOffset() { | 40 define internal i32 @testLoadFixedOffset() { |
41 entry: | 41 entry: |
42 %a = ptrtoint [4 x i8]* @G1 to i32 | 42 %a = ptrtoint [4 x i8]* @G1 to i32 |
43 %a1 = add i32 %a, 4 | 43 %a1 = add i32 %a, 4 |
44 %a2 = inttoptr i32 %a1 to i32* | 44 %a2 = inttoptr i32 %a1 to i32* |
45 %b = load i32, i32* %a2, align 1 | 45 %b = load i32, i32* %a2, align 1 |
46 ret i32 %b | 46 ret i32 %b |
47 } | 47 } |
48 ; Expect a load with a R_386_GOTOFF relocation plus an immediate offset. | 48 ; Expect a load with a R_386_GOTOFF relocation plus an immediate offset. |
49 ; NONSFI-LABEL: testLoadFixedOffset | 49 ; NONSFI-LABEL: testLoadFixedOffset |
50 ; NONSFI: mov {{.*}}+0x4] {{.*}} R_386_GOTOFF G1 | 50 ; NONSFI: mov {{.*}}+0x4] {{.*}} R_386_GOTOFF {{G1|.bss}} |
51 ; DEFAULT-LABEL: testLoadFixedOffset | 51 ; DEFAULT-LABEL: testLoadFixedOffset |
52 | 52 |
53 define internal i32 @testLoadIndexed(i32 %idx) { | 53 define internal i32 @testLoadIndexed(i32 %idx) { |
54 entry: | 54 entry: |
55 %a = ptrtoint [4 x i8]* @G1 to i32 | 55 %a = ptrtoint [4 x i8]* @G1 to i32 |
56 %a0 = mul i32 %idx, 4 | 56 %a0 = mul i32 %idx, 4 |
57 %a1 = add i32 %a0, 12 | 57 %a1 = add i32 %a0, 12 |
58 %a2 = add i32 %a1, %a | 58 %a2 = add i32 %a1, %a |
59 %a3 = inttoptr i32 %a2 to i32* | 59 %a3 = inttoptr i32 %a2 to i32* |
60 %b = load i32, i32* %a3, align 1 | 60 %b = load i32, i32* %a3, align 1 |
61 ret i32 %b | 61 ret i32 %b |
62 } | 62 } |
63 ; Expect a load with a R_386_GOTOFF relocation plus an immediate offset, plus a | 63 ; Expect a load with a R_386_GOTOFF relocation plus an immediate offset, plus a |
64 ; scaled index register. | 64 ; scaled index register. |
65 ; NONSFI-LABEL: testLoadIndexed | 65 ; NONSFI-LABEL: testLoadIndexed |
66 ; NONSFI: mov {{.*}}*4+0xc] {{.*}} R_386_GOTOFF G1 | 66 ; NONSFI: mov {{.*}}*4+0xc] {{.*}} R_386_GOTOFF {{G1|.bss}} |
67 ; DEFAULT-LABEL: testLoadIndexed | 67 ; DEFAULT-LABEL: testLoadIndexed |
68 | 68 |
69 define internal i32 @testLoadIndexedBase(i32 %base, i32 %idx) { | 69 define internal i32 @testLoadIndexedBase(i32 %base, i32 %idx) { |
70 entry: | 70 entry: |
71 %a = ptrtoint [4 x i8]* @G1 to i32 | 71 %a = ptrtoint [4 x i8]* @G1 to i32 |
72 %a0 = mul i32 %idx, 4 | 72 %a0 = mul i32 %idx, 4 |
73 %a1 = add i32 %a0, %base | 73 %a1 = add i32 %a0, %base |
74 %a2 = add i32 %a1, %a | 74 %a2 = add i32 %a1, %a |
75 %a3 = add i32 %a2, 12 | 75 %a3 = add i32 %a2, 12 |
76 %a4 = inttoptr i32 %a3 to i32* | 76 %a4 = inttoptr i32 %a3 to i32* |
77 %b = load i32, i32* %a4, align 1 | 77 %b = load i32, i32* %a4, align 1 |
78 ret i32 %b | 78 ret i32 %b |
79 } | 79 } |
80 ; Expect a load with a R_386_GOTOFF relocation plus an immediate offset, but | 80 ; Expect a load with a R_386_GOTOFF relocation plus an immediate offset, but |
81 ; without the scaled index. | 81 ; without the scaled index. |
82 ; NONSFI-LABEL: testLoadIndexedBase | 82 ; NONSFI-LABEL: testLoadIndexedBase |
83 ; NONSFI: mov {{.*}}*1+0xc] {{.*}} R_386_GOTOFF G1 | 83 ; NONSFI: mov {{.*}}*1+0xc] {{.*}} R_386_GOTOFF {{G1|.bss}} |
84 ; By contrast, without -nonsfi, expect a load with a *R_386_32* relocation plus | 84 ; By contrast, without -nonsfi, expect a load with a *R_386_32* relocation plus |
85 ; an immediate offset, and *with* the scaled index. | 85 ; an immediate offset, and *with* the scaled index. |
86 ; DEFAULT-LABEL: testLoadIndexedBase | 86 ; DEFAULT-LABEL: testLoadIndexedBase |
87 ; DEFAULT: mov {{.*}},DWORD PTR [{{.*}}+{{.*}}*4+0xc] {{.*}} R_386_32 G1 | 87 ; DEFAULT: mov {{.*}},DWORD PTR [{{.*}}+{{.*}}*4+0xc] {{.*}} R_386_32 {{G1|.bss} } |
88 | 88 |
89 define internal i32 @testLoadOpt() { | 89 define internal i32 @testLoadOpt() { |
90 entry: | 90 entry: |
91 %a = bitcast [4 x i8]* @G1 to i32* | 91 %a = bitcast [4 x i8]* @G1 to i32* |
92 %b = load i32, i32* %a, align 1 | 92 %b = load i32, i32* %a, align 1 |
93 %c = bitcast [4 x i8]* @G2 to i32* | 93 %c = bitcast [4 x i8]* @G2 to i32* |
94 %d = load i32, i32* %c, align 1 | 94 %d = load i32, i32* %c, align 1 |
95 %e = add i32 %b, %d | 95 %e = add i32 %b, %d |
96 ret i32 %e | 96 ret i32 %e |
97 } | 97 } |
98 ; Expect a load-folding optimization with a R_386_GOTOFF relocation. | 98 ; Expect a load-folding optimization with a R_386_GOTOFF relocation. |
99 ; NONSFI-LABEL: testLoadOpt | 99 ; NONSFI-LABEL: testLoadOpt |
100 ; NONSFI: mov [[REG:e..]],{{.*}}+0x0] {{.*}} R_386_GOTOFF G1 | 100 ; NONSFI: mov [[REG:e..]],{{.*}}+0x0] {{.*}} R_386_GOTOFF {{G1|.bss}} |
101 ; NONSFI-NEXT: add [[REG]],{{.*}}+0x0] {{.*}} R_386_GOTOFF G2 | 101 ; NONSFI-NEXT: add [[REG]],{{.*}}+0x{{0|4}}] {{.*}} R_386_GOTOFF {{G2|.bss}} |
102 ; DEFAULT-LABEL: testLoadOpt | 102 ; DEFAULT-LABEL: testLoadOpt |
103 | 103 |
104 define internal void @testRMW() { | 104 define internal void @testRMW() { |
105 entry: | 105 entry: |
106 %a = bitcast [4 x i8]* @G1 to i32* | 106 %a = bitcast [4 x i8]* @G1 to i32* |
107 %b = load i32, i32* %a, align 1 | 107 %b = load i32, i32* %a, align 1 |
108 %c = add i32 %b, 1234 | 108 %c = add i32 %b, 1234 |
109 store i32 %c, i32* %a, align 1 | 109 store i32 %c, i32* %a, align 1 |
110 ret void | 110 ret void |
111 } | 111 } |
112 ; Expect an RMW optimization with a R_386_GOTOFF relocation. | 112 ; Expect an RMW optimization with a R_386_GOTOFF relocation. |
113 ; NONSFI-LABEL: testRMW | 113 ; NONSFI-LABEL: testRMW |
114 ; NONSFI: add DWORD PTR {{.*}}+0x0],0x4d2 {{.*}} R_386_GOTOFF G1 | 114 ; NONSFI: add DWORD PTR {{.*}}+0x0],0x4d2 {{.*}} R_386_GOTOFF {{G1|.bss}} |
115 ; DEFAULT-LABEL: testRMW | 115 ; DEFAULT-LABEL: testRMW |
OLD | NEW |