OLD | NEW |
(Empty) | |
| 1 ; This file checks that SimpleCoalescing of local stack slots is not done |
| 2 ; when calling a function with the "returns twice" attribute. |
| 3 |
| 4 ; RUN: %llvm2ice -Om1 --verbose none %s \ |
| 5 ; RUN: | llvm-mc -triple=i686-none-nacl -x86-asm-syntax=intel -filetype=obj \ |
| 6 ; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s |
| 7 ; RUN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s |
| 8 |
| 9 ; Setjmp is a function with the "returns twice" attribute. |
| 10 declare i32 @llvm.nacl.setjmp(i8*) |
| 11 |
| 12 declare i32 @other(i32) |
| 13 declare void @user(i32) |
| 14 |
| 15 define i32 @call_returns_twice(i32 %iptr_jmpbuf, i32 %x) { |
| 16 entry: |
| 17 %local = add i32 %x, 12345 |
| 18 %jmpbuf = inttoptr i32 %iptr_jmpbuf to i8* |
| 19 %y = call i32 @llvm.nacl.setjmp(i8* %jmpbuf) |
| 20 call void @user(i32 %local) |
| 21 %cmp = icmp eq i32 %y, 0 |
| 22 br i1 %cmp, label %Zero, label %NonZero |
| 23 Zero: |
| 24 %other_local = add i32 %x, 54321 |
| 25 call void @user(i32 %other_local) |
| 26 ret i32 %other_local |
| 27 NonZero: |
| 28 ret i32 1 |
| 29 } |
| 30 |
| 31 ; CHECK-LABEL: call_returns_twice |
| 32 ; CHECK: add [[REG1:.*]], 12345 |
| 33 ; CHECK: mov dword ptr [esp + [[OFF:.*]]], [[REG1]] |
| 34 ; CHECK: add [[REG2:.*]], 54321 |
| 35 ; There should not be sharing of the stack slot. |
| 36 ; CHECK-NOT: mov dword ptr [esp + [[OFF]]], [[REG2]] |
| 37 |
| 38 define i32 @no_call_returns_twice(i32 %iptr_jmpbuf, i32 %x) { |
| 39 entry: |
| 40 %local = add i32 %x, 12345 |
| 41 %y = call i32 @other(i32 %x) |
| 42 call void @user(i32 %local) |
| 43 %cmp = icmp eq i32 %y, 0 |
| 44 br i1 %cmp, label %Zero, label %NonZero |
| 45 Zero: |
| 46 %other_local = add i32 %x, 54321 |
| 47 call void @user(i32 %other_local) |
| 48 ret i32 %other_local |
| 49 NonZero: |
| 50 ret i32 1 |
| 51 } |
| 52 |
| 53 ; CHECK-LABEL: no_call_returns_twice |
| 54 ; CHECK: add [[REG1:.*]], 12345 |
| 55 ; CHECK: mov dword ptr [esp + [[OFF:.*]]], [[REG1]] |
| 56 ; CHECK: add [[REG2:.*]], 54321 |
| 57 ; Now there should be sharing of the stack slot (OFF is the same). |
| 58 ; CHECK: mov dword ptr [esp + [[OFF]]], [[REG2]] |
| 59 |
| 60 ; ERRORS-NOT: ICE translation error |
OLD | NEW |