OLD | NEW |
(Empty) | |
| 1 ; Test that for calls returning a floating-point value, the calling |
| 2 ; ABI with respect to the x87 floating point stack is honored. In |
| 3 ; particular, the top-of-stack must be popped regardless of whether |
| 4 ; its value is used. |
| 5 |
| 6 ; RUN: %llvm2ice -O2 --verbose none %s \ |
| 7 ; RUN: | llvm-mc -triple=i686-none-nacl -x86-asm-syntax=intel -filetype=obj \ |
| 8 ; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s |
| 9 ; RUN: %llvm2ice -Om1 --verbose none %s \ |
| 10 ; RUN: | llvm-mc -triple=i686-none-nacl -x86-asm-syntax=intel -filetype=obj \ |
| 11 ; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s |
| 12 ; RUN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s |
| 13 ; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s |
| 14 ; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \ |
| 15 ; RUN: | FileCheck --check-prefix=DUMP %s |
| 16 |
| 17 define float @dummy() { |
| 18 entry: |
| 19 ret float 0.000000e+00 |
| 20 } |
| 21 ; CHECK-LABEL: dummy |
| 22 |
| 23 ; The call is ignored, but the top of the FP stack still needs to be |
| 24 ; popped. |
| 25 define i32 @ignored_fp_call() { |
| 26 entry: |
| 27 %ignored = call float @dummy() |
| 28 ret i32 0 |
| 29 } |
| 30 ; CHECK-LABEL: ignored_fp_call |
| 31 ; CHECK: call dummy |
| 32 ; CHECK: fstp |
| 33 |
| 34 ; The top of the FP stack is popped and subsequently used. |
| 35 define i32 @converted_fp_call() { |
| 36 entry: |
| 37 %fp = call float @dummy() |
| 38 %ret = fptosi float %fp to i32 |
| 39 ret i32 %ret |
| 40 } |
| 41 ; CHECK-LABEL: converted_fp_call |
| 42 ; CHECK: call dummy |
| 43 ; CHECK: fstp |
| 44 ; CHECK: cvttss2si |
| 45 |
| 46 ; The top of the FP stack is ultimately passed through as the return |
| 47 ; value. Note: the translator could optimized by not popping and |
| 48 ; re-pushing, in which case the test would need to be changed. |
| 49 define float @returned_fp_call() { |
| 50 entry: |
| 51 %fp = call float @dummy() |
| 52 ret float %fp |
| 53 } |
| 54 ; CHECK-LABEL: returned_fp_call |
| 55 ; CHECK: call dummy |
| 56 ; CHECK: fstp |
| 57 ; CHECK: fld |
| 58 |
| 59 ; ERRORS-NOT: ICE translation error |
| 60 ; DUMP-NOT: SZ |
OLD | NEW |