| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 %ptr = inttoptr i32 %iptr to i32* | 165 %ptr = inttoptr i32 %iptr to i32* |
| 166 call void @llvm.nacl.atomic.store.i32(i32 %val, i32* %ptr, i32 6) | 166 call void @llvm.nacl.atomic.store.i32(i32 %val, i32* %ptr, i32 6) |
| 167 br label %next2 | 167 br label %next2 |
| 168 next2: | 168 next2: |
| 169 %cmp = icmp ult i64 %val64, 0 | 169 %cmp = icmp ult i64 %val64, 0 |
| 170 br i1 %cmp, label %next, label %next2 | 170 br i1 %cmp, label %next, label %next2 |
| 171 } | 171 } |
| 172 ; CHECK-LABEL: test_local_forward_then_back | 172 ; CHECK-LABEL: test_local_forward_then_back |
| 173 ; CHECK: {{.*}} mov DWORD PTR | 173 ; CHECK: {{.*}} mov DWORD PTR |
| 174 ; CHECK-NEXT: {{.*}} mfence | 174 ; CHECK-NEXT: {{.*}} mfence |
| 175 ; CHECK-NEXT: 16: {{.*}} mov {{.*}},0x1 | 175 ; CHECK-NEXT: [[LABEL:[0-9a-f]+]]: {{.*}} mov {{.*}},0x1 |
| 176 ; CHECK-NEXT: {{.*}} cmp | 176 ; CHECK-NEXT: {{.*}} cmp |
| 177 ; CHECK-NEXT: {{.*}} jb | 177 ; CHECK-NEXT: {{.*}} jb |
| 178 ; CHECK: {{.*}} jne | 178 ; CHECK: {{.*}} jne |
| 179 ; CHECK: {{.*}} jmp 16 | 179 ; CHECK: {{.*}} jmp [[LABEL]] |
| 180 | 180 |
| 181 | 181 |
| 182 ; Test that backward local branches also work and are small. | 182 ; Test that backward local branches also work and are small. |
| 183 ; Some of the atomic instructions use a cmpxchg loop. | 183 ; Some of the atomic instructions use a cmpxchg loop. |
| 184 define internal void @test_local_backward(i64 %val64, i32 %iptr, i32 %val) { | 184 define internal void @test_local_backward(i64 %val64, i32 %iptr, i32 %val) { |
| 185 entry: | 185 entry: |
| 186 br label %next | 186 br label %next |
| 187 next: | 187 next: |
| 188 %ptr = inttoptr i32 %iptr to i32* | 188 %ptr = inttoptr i32 %iptr to i32* |
| 189 %a = call i32 @llvm.nacl.atomic.rmw.i32(i32 5, i32* %ptr, i32 %val, i32 6) | 189 %a = call i32 @llvm.nacl.atomic.rmw.i32(i32 5, i32* %ptr, i32 %val, i32 6) |
| 190 br label %next2 | 190 br label %next2 |
| 191 next2: | 191 next2: |
| 192 %success = icmp eq i32 1, %a | 192 %success = icmp eq i32 1, %a |
| 193 br i1 %success, label %next, label %next2 | 193 br i1 %success, label %next, label %next2 |
| 194 } | 194 } |
| 195 ; CHECK-LABEL: test_local_backward | 195 ; CHECK-LABEL: test_local_backward |
| 196 ; CHECK: 9: {{.*}} mov {{.*}},DWORD | 196 ; CHECK: 9: {{.*}} mov {{.*}},DWORD |
| 197 ; CHECK: b: {{.*}} mov | 197 ; CHECK: b: {{.*}} mov |
| 198 ; CHECK-NEXT: d: {{.*}} xor | 198 ; CHECK-NEXT: d: {{.*}} xor |
| 199 ; CHECK-NEXT: f: {{.*}} lock cmpxchg | 199 ; CHECK-NEXT: f: {{.*}} lock cmpxchg |
| 200 ; CHECK-NEXT: 13: 75 f6 jne b | 200 ; CHECK-NEXT: 13: 75 f6 jne b |
| 201 ; CHECK: 1c: 74 eb je 9 | 201 ; CHECK: 1c: 74 eb je 9 |
| OLD | NEW |