Home | History | Annotate | Download | only in llvm2ice_tests
      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: %p2i --filetype=obj --disassemble -i %s --args -O2 \
      7 ; RUN:      -allow-externally-defined-symbols | FileCheck %s
      8 ; RUN: %p2i --filetype=obj --disassemble -i %s --args -Om1 \
      9 ; RUN:      -allow-externally-defined-symbols | FileCheck %s
     10 
     11 declare float @dummy()
     12 
     13 ; The call is ignored, but the top of the FP stack still needs to be
     14 ; popped.
     15 define i32 @ignored_fp_call() {
     16 entry:
     17   %ignored = call float @dummy()
     18   ret i32 0
     19 }
     20 ; CHECK-LABEL: ignored_fp_call
     21 ; CHECK: call {{.*}} R_{{.*}} dummy
     22 ; CHECK: fstp
     23 
     24 ; The top of the FP stack is popped and subsequently used.
     25 define i32 @converted_fp_call() {
     26 entry:
     27   %fp = call float @dummy()
     28   %ret = fptosi float %fp to i32
     29   ret i32 %ret
     30 }
     31 ; CHECK-LABEL: converted_fp_call
     32 ; CHECK: call {{.*}} R_{{.*}} dummy
     33 ; CHECK: fstp
     34 ; CHECK: cvttss2si
     35 
     36 ; The top of the FP stack is ultimately passed through as the return
     37 ; value.  Note: the translator could optimized by not popping and
     38 ; re-pushing, in which case the test would need to be changed.
     39 define float @returned_fp_call() {
     40 entry:
     41   %fp = call float @dummy()
     42   ret float %fp
     43 }
     44 ; CHECK-LABEL: returned_fp_call
     45 ; CHECK: call {{.*}} R_{{.*}} dummy
     46 ; CHECK: fstp
     47 ; CHECK: fld
     48