Skip to content

Commit a7c7f39

Browse files
tests/assembly: cross-compile x86-return-float
We choose to test for Linux and Windows instead of random other targets.
1 parent ee111b2 commit a7c7f39

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

Diff for: tests/assembly/x86-return-float.rs

+25-17
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
//@ assembly-output: emit-asm
2-
//@ only-x86
32
// FIXME(#114479): LLVM miscompiles loading and storing `f32` and `f64` when SSE is disabled.
43
// There's no compiletest directive to ignore a test on i586 only, so just always explicitly enable
54
// SSE2.
65
// Use the same target CPU as `i686` so that LLVM orders the instructions in the same order.
76
//@ compile-flags: -Ctarget-feature=+sse2 -Ctarget-cpu=pentium4
87
// Force frame pointers to make ASM more consistent between targets
9-
//@ compile-flags: -Copt-level=3 -C force-frame-pointers
8+
//@ compile-flags: -C force-frame-pointers
9+
// At opt-level=3, LLVM can merge two movss into one movsd, and we aren't testing for that.
10+
//@ compile-flags: -Copt-level=2
1011
//@ filecheck-flags: --implicit-check-not fld --implicit-check-not fst
11-
//@ revisions: normal win
12-
//@[normal] ignore-windows
13-
//@[win] only-windows
12+
//@ revisions: linux win
13+
//@ add-core-stubs
14+
//@ needs-llvm-components: x86
15+
//@[linux] compile-flags: --target i686-unknown-linux-gnu
16+
//@[win] compile-flags: --target i686-pc-windows-msvc
1417

1518
#![crate_type = "lib"]
1619
#![feature(f16, f128)]
20+
#![feature(no_core)]
21+
#![no_core]
22+
23+
extern crate minicore;
24+
use minicore::*;
1725

1826
// Tests that returning `f32` and `f64` with the "Rust" ABI on 32-bit x86 doesn't use the x87
1927
// floating point stack, as loading and storing `f32`s and `f64`s to and from the x87 stack quietens
@@ -190,8 +198,8 @@ pub unsafe fn call_f64_f64(x: &mut (f64, f64)) {
190198
}
191199
// CHECK: movl {{.*}}(%ebp), %[[PTR:.*]]
192200
// CHECK: calll {{()|_}}get_f64_f64
193-
// normal: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]]
194-
// normal-NEXT: movsd [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]]
201+
// linux: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]]
202+
// linux-NEXT: movsd [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]]
195203
// win: movsd (%esp), %[[VAL1:.*]]
196204
// win-NEXT: movsd 8(%esp), %[[VAL2:.*]]
197205
// CHECK-NEXT: movsd %[[VAL1]], (%[[PTR]])
@@ -207,12 +215,12 @@ pub unsafe fn call_f32_f64(x: &mut (f32, f64)) {
207215
}
208216
// CHECK: movl {{.*}}(%ebp), %[[PTR:.*]]
209217
// CHECK: calll {{()|_}}get_f32_f64
210-
// normal: movss [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]]
211-
// normal-NEXT: movsd [[#%d,OFFSET+4]](%ebp), %[[VAL2:.*]]
218+
// linux: movss [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]]
219+
// linux-NEXT: movsd [[#%d,OFFSET+4]](%ebp), %[[VAL2:.*]]
212220
// win: movss (%esp), %[[VAL1:.*]]
213221
// win-NEXT: movsd 8(%esp), %[[VAL2:.*]]
214222
// CHECK-NEXT: movss %[[VAL1]], (%[[PTR]])
215-
// normal-NEXT: movsd %[[VAL2]], 4(%[[PTR]])
223+
// linux-NEXT: movsd %[[VAL2]], 4(%[[PTR]])
216224
// win-NEXT: movsd %[[VAL2]], 8(%[[PTR]])
217225
*x = get_f32_f64();
218226
}
@@ -225,8 +233,8 @@ pub unsafe fn call_f64_f32(x: &mut (f64, f32)) {
225233
}
226234
// CHECK: movl {{.*}}(%ebp), %[[PTR:.*]]
227235
// CHECK: calll {{()|_}}get_f64_f32
228-
// normal: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]]
229-
// normal-NEXT: movss [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]]
236+
// linux: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]]
237+
// linux-NEXT: movss [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]]
230238
// win: movsd (%esp), %[[VAL1:.*]]
231239
// win-NEXT: movss 8(%esp), %[[VAL2:.*]]
232240
// CHECK-NEXT: movsd %[[VAL1]], (%[[PTR]])
@@ -257,8 +265,8 @@ pub unsafe fn call_f64_other(x: &mut (f64, usize)) {
257265
}
258266
// CHECK: movl {{.*}}(%ebp), %[[PTR:.*]]
259267
// CHECK: calll {{()|_}}get_f64_other
260-
// normal: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]]
261-
// normal-NEXT: movl [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]]
268+
// linux: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]]
269+
// linux-NEXT: movl [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]]
262270
// win: movsd (%esp), %[[VAL1:.*]]
263271
// win-NEXT: movl 8(%esp), %[[VAL2:.*]]
264272
// CHECK-NEXT: movsd %[[VAL1]], (%[[PTR]])
@@ -289,12 +297,12 @@ pub unsafe fn call_other_f64(x: &mut (usize, f64)) {
289297
}
290298
// CHECK: movl {{.*}}(%ebp), %[[PTR:.*]]
291299
// CHECK: calll {{()|_}}get_other_f64
292-
// normal: movl [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]]
293-
// normal-NEXT: movsd [[#%d,OFFSET+4]](%ebp), %[[VAL2:.*]]
300+
// linux: movl [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]]
301+
// linux-NEXT: movsd [[#%d,OFFSET+4]](%ebp), %[[VAL2:.*]]
294302
// win: movl (%esp), %[[VAL1:.*]]
295303
// win-NEXT: movsd 8(%esp), %[[VAL2:.*]]
296304
// CHECK-NEXT: movl %[[VAL1]], (%[[PTR]])
297-
// normal-NEXT: movsd %[[VAL2]], 4(%[[PTR]])
305+
// linux-NEXT: movsd %[[VAL2]], 4(%[[PTR]])
298306
// win-NEXT: movsd %[[VAL2]], 8(%[[PTR]])
299307
*x = get_other_f64();
300308
}

0 commit comments

Comments
 (0)