OLD | NEW |
1 ; Tests various aspects of x86 branch encodings (near vs far, | 1 ; Tests various aspects of x86 branch encodings (near vs far, |
2 ; forward vs backward, using CFG labels, or local labels). | 2 ; forward vs backward, using CFG labels, or local labels). |
3 | 3 |
4 ; Use -ffunction-sections so that the offsets reset for each function. | 4 ; Use -ffunction-sections so that the offsets reset for each function. |
5 ; RUN: %p2i --filetype=obj --disassemble -i %s --args -O2 \ | 5 ; RUN: %p2i --filetype=obj --disassemble -i %s --args -O2 \ |
6 ; RUN: -ffunction-sections | FileCheck %s | 6 ; RUN: -ffunction-sections | FileCheck %s |
7 | 7 |
8 ; Use atomic ops as filler, which shouldn't get optimized out. | 8 ; Use atomic ops as filler, which shouldn't get optimized out. |
9 declare void @llvm.nacl.atomic.store.i32(i32, i32*, i32) | 9 declare void @llvm.nacl.atomic.store.i32(i32, i32*, i32) |
10 declare i32 @llvm.nacl.atomic.load.i32(i32*, i32) | 10 declare i32 @llvm.nacl.atomic.load.i32(i32*, i32) |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 %ptr = inttoptr i32 %iptr to i32* | 133 %ptr = inttoptr i32 %iptr to i32* |
134 %cmp = icmp ult i32 %val, 1 | 134 %cmp = icmp ult i32 %val, 1 |
135 br i1 %cmp, label %next3, label %next2 | 135 br i1 %cmp, label %next3, label %next2 |
136 next2: | 136 next2: |
137 call void @llvm.nacl.atomic.store.i32(i32 %val, i32* %ptr, i32 6) | 137 call void @llvm.nacl.atomic.store.i32(i32 %val, i32* %ptr, i32 6) |
138 br label %next3 | 138 br label %next3 |
139 next3: | 139 next3: |
140 call void @llvm.nacl.atomic.store.i32(i32 %val, i32* %ptr, i32 6) | 140 call void @llvm.nacl.atomic.store.i32(i32 %val, i32* %ptr, i32 6) |
141 br label %next1 | 141 br label %next1 |
142 } | 142 } |
143 ; Forward branches for non-local labels currently use the fully relaxed | 143 ; Note: forward branches for non-local labels in Subzero currently use the fully |
144 ; form to avoid needing a relaxation pass. | 144 ; relaxed form (4-byte offset) to avoid needing a relaxation pass. When we use |
| 145 ; llvm-mc, it performs the relaxation pass and uses a 1-byte offset. |
145 ; CHECK-LABEL: test_near_forward | 146 ; CHECK-LABEL: test_near_forward |
146 ; CHECK: 8: {{.*}} cmp | 147 ; CHECK: [[BACKLABEL:[0-9a-f]+]]: {{.*}} cmp |
147 ; CHECK-NEXT: b: 0f 82 05 00 00 00 jb 16 | 148 ; CHECK-NEXT: {{.*}} jb [[FORWARDLABEL:[0-9a-f]+]] |
148 ; CHECK-NEXT: 11: {{.*}} mov DWORD PTR | 149 ; CHECK-NEXT: {{.*}} mov DWORD PTR |
149 ; CHECK-NEXT: 13: {{.*}} mfence | 150 ; CHECK-NEXT: {{.*}} mfence |
150 ; CHECK-NEXT: 16: {{.*}} mov DWORD PTR | 151 ; CHECK-NEXT: [[FORWARDLABEL]]: {{.*}} mov DWORD PTR |
151 ; CHECK: 1b: eb eb jmp 8 | 152 ; CHECK: {{.*}} jmp [[BACKLABEL]] |
152 | 153 |
153 | 154 |
154 ; Unlike forward branches to cfg nodes, "local" forward branches | 155 ; Unlike forward branches to cfg nodes, "local" forward branches |
155 ; always use a 1 byte displacement. | 156 ; always use a 1 byte displacement. |
156 ; Check local forward branches, followed by a near backward branch | 157 ; Check local forward branches, followed by a near backward branch |
157 ; to make sure that the instruction size accounting for the forward | 158 ; to make sure that the instruction size accounting for the forward |
158 ; branches are correct, by the time the backward branch is hit. | 159 ; branches are correct, by the time the backward branch is hit. |
159 ; A 64-bit compare happens to use local forward branches. | 160 ; A 64-bit compare happens to use local forward branches. |
160 define internal void @test_local_forward_then_back(i64 %val64, i32 %iptr, | 161 define internal void @test_local_forward_then_back(i64 %val64, i32 %iptr, |
161 i32 %val) { | 162 i32 %val) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 %success = icmp eq i32 1, %a | 194 %success = icmp eq i32 1, %a |
194 br i1 %success, label %next, label %next2 | 195 br i1 %success, label %next, label %next2 |
195 } | 196 } |
196 ; CHECK-LABEL: test_local_backward | 197 ; CHECK-LABEL: test_local_backward |
197 ; CHECK: 9: {{.*}} mov {{.*}},DWORD | 198 ; CHECK: 9: {{.*}} mov {{.*}},DWORD |
198 ; CHECK: b: {{.*}} mov | 199 ; CHECK: b: {{.*}} mov |
199 ; CHECK-NEXT: d: {{.*}} xor | 200 ; CHECK-NEXT: d: {{.*}} xor |
200 ; CHECK-NEXT: f: {{.*}} lock cmpxchg | 201 ; CHECK-NEXT: f: {{.*}} lock cmpxchg |
201 ; CHECK-NEXT: 13: 75 f6 jne b | 202 ; CHECK-NEXT: 13: 75 f6 jne b |
202 ; CHECK: 1c: 74 eb je 9 | 203 ; CHECK: 1c: 74 eb je 9 |
OLD | NEW |