use test::black_box instead of ptr::*_volatile
both prevent LLVM from optimizing away the intrinsics but the former doesn't produce an `intrinsics` binary that segfaults
This commit is contained in:
parent
c82403551d
commit
96ddd4ed8d
|
@ -32,7 +32,7 @@ esac
|
||||||
# TODO(#79) fix the undefined references problem for debug-assertions+lto
|
# TODO(#79) fix the undefined references problem for debug-assertions+lto
|
||||||
case $1 in
|
case $1 in
|
||||||
thumb*)
|
thumb*)
|
||||||
RUSTFLAGS="-C debug-assertions=no" xargo rustc --features c --target $1 --bin intrinsics -- -C lto
|
RUSTFLAGS="-C debug-assertions=no -C link-arg=-nostartfiles" xargo rustc --features c --target $1 --bin intrinsics -- -C lto
|
||||||
xargo rustc --features c --target $1 --bin intrinsics --release -- -C lto
|
xargo rustc --features c --target $1 --bin intrinsics --release -- -C lto
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
|
@ -4,13 +4,14 @@
|
||||||
// to link due to the missing intrinsic (symbol).
|
// to link due to the missing intrinsic (symbol).
|
||||||
|
|
||||||
#![allow(unused_features)]
|
#![allow(unused_features)]
|
||||||
|
#![cfg_attr(thumb, no_main)]
|
||||||
#![deny(dead_code)]
|
#![deny(dead_code)]
|
||||||
|
#![feature(asm)]
|
||||||
#![feature(core_float)]
|
#![feature(core_float)]
|
||||||
#![feature(lang_items)]
|
#![feature(lang_items)]
|
||||||
#![feature(libc)]
|
#![feature(libc)]
|
||||||
#![feature(start)]
|
#![feature(start)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![cfg_attr(thumb, no_main)]
|
|
||||||
|
|
||||||
#[cfg(not(thumb))]
|
#[cfg(not(thumb))]
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
@ -302,68 +303,58 @@ mod intrinsics {
|
||||||
|
|
||||||
#[cfg(feature = "c")]
|
#[cfg(feature = "c")]
|
||||||
fn run() {
|
fn run() {
|
||||||
use core::ptr;
|
|
||||||
use intrinsics::*;
|
use intrinsics::*;
|
||||||
|
|
||||||
// We use volatile load/stores to prevent LLVM from optimizing away the intrinsics during LTO
|
// A copy of "test::black_box". Used to prevent LLVM from optimizing away the intrinsics during LTO
|
||||||
macro_rules! arg {
|
fn bb<T>(dummy: T) -> T {
|
||||||
() => {
|
unsafe { asm!("" : : "r"(&dummy)) }
|
||||||
ptr::read_volatile(0x0 as *const _)
|
dummy
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! ret {
|
bb(aeabi_d2f(bb(2.)));
|
||||||
($e:expr) => {
|
bb(aeabi_d2i(bb(2.)));
|
||||||
unsafe {
|
bb(aeabi_d2l(bb(2.)));
|
||||||
ptr::write_volatile(0x0 as *mut _, $e)
|
bb(aeabi_d2uiz(bb(2.)));
|
||||||
}
|
bb(aeabi_d2ulz(bb(2.)));
|
||||||
}
|
bb(aeabi_dadd(bb(2.), bb(3.)));
|
||||||
}
|
bb(aeabi_dcmpeq(bb(2.), bb(3.)));
|
||||||
|
bb(aeabi_dcmpgt(bb(2.), bb(3.)));
|
||||||
ret!(aeabi_d2f(arg!()));
|
bb(aeabi_dcmplt(bb(2.), bb(3.)));
|
||||||
ret!(aeabi_d2i(arg!()));
|
bb(aeabi_ddiv(bb(2.), bb(3.)));
|
||||||
ret!(aeabi_d2l(arg!()));
|
bb(aeabi_dmul(bb(2.), bb(3.)));
|
||||||
ret!(aeabi_d2uiz(arg!()));
|
bb(aeabi_dsub(bb(2.), bb(3.)));
|
||||||
ret!(aeabi_d2ulz(arg!()));
|
bb(aeabi_f2d(bb(2.)));
|
||||||
ret!(aeabi_dadd(arg!(), arg!()));
|
bb(aeabi_f2iz(bb(2.)));
|
||||||
ret!(aeabi_dcmpeq(arg!(), arg!()));
|
bb(aeabi_f2lz(bb(2.)));
|
||||||
ret!(aeabi_dcmpgt(arg!(), arg!()));
|
bb(aeabi_f2uiz(bb(2.)));
|
||||||
ret!(aeabi_dcmplt(arg!(), arg!()));
|
bb(aeabi_f2ulz(bb(2.)));
|
||||||
ret!(aeabi_ddiv(arg!(), arg!()));
|
bb(aeabi_fadd(bb(2.), bb(3.)));
|
||||||
ret!(aeabi_dmul(arg!(), arg!()));
|
bb(aeabi_fcmpeq(bb(2.), bb(3.)));
|
||||||
ret!(aeabi_dsub(arg!(), arg!()));
|
bb(aeabi_fcmpgt(bb(2.), bb(3.)));
|
||||||
ret!(aeabi_f2d(arg!()));
|
bb(aeabi_fcmplt(bb(2.), bb(3.)));
|
||||||
ret!(aeabi_f2iz(arg!()));
|
bb(aeabi_fdiv(bb(2.), bb(3.)));
|
||||||
ret!(aeabi_f2lz(arg!()));
|
bb(aeabi_fmul(bb(2.), bb(3.)));
|
||||||
ret!(aeabi_f2uiz(arg!()));
|
bb(aeabi_fsub(bb(2.), bb(3.)));
|
||||||
ret!(aeabi_f2ulz(arg!()));
|
bb(aeabi_i2d(bb(2)));
|
||||||
ret!(aeabi_fadd(arg!(), arg!()));
|
bb(aeabi_i2f(bb(2)));
|
||||||
ret!(aeabi_fcmpeq(arg!(), arg!()));
|
bb(aeabi_idiv(bb(2), bb(3)));
|
||||||
ret!(aeabi_fcmpgt(arg!(), arg!()));
|
bb(aeabi_idivmod(bb(2), bb(3)));
|
||||||
ret!(aeabi_fcmplt(arg!(), arg!()));
|
bb(aeabi_l2d(bb(2)));
|
||||||
ret!(aeabi_fdiv(arg!(), arg!()));
|
bb(aeabi_l2f(bb(2)));
|
||||||
ret!(aeabi_fmul(arg!(), arg!()));
|
bb(aeabi_ldivmod(bb(2), bb(3)));
|
||||||
ret!(aeabi_fsub(arg!(), arg!()));
|
bb(aeabi_lmul(bb(2), bb(3)));
|
||||||
ret!(aeabi_i2d(arg!()));
|
bb(aeabi_ui2d(bb(2)));
|
||||||
ret!(aeabi_i2f(arg!()));
|
bb(aeabi_ui2f(bb(2)));
|
||||||
ret!(aeabi_idiv(arg!(), arg!()));
|
bb(aeabi_uidiv(bb(2), bb(3)));
|
||||||
ret!(aeabi_idivmod(arg!(), arg!()));
|
bb(aeabi_uidivmod(bb(2), bb(3)));
|
||||||
ret!(aeabi_l2d(arg!()));
|
bb(aeabi_ul2d(bb(2)));
|
||||||
ret!(aeabi_l2f(arg!()));
|
bb(aeabi_ul2f(bb(2)));
|
||||||
ret!(aeabi_ldivmod(arg!(), arg!()));
|
bb(aeabi_uldivmod(bb(2), bb(3)));
|
||||||
ret!(aeabi_lmul(arg!(), arg!()));
|
bb(moddi3(bb(2), bb(3)));
|
||||||
ret!(aeabi_ui2d(arg!()));
|
bb(mulodi4(bb(2), bb(3)));
|
||||||
ret!(aeabi_ui2f(arg!()));
|
bb(powidf2(bb(2.), bb(3)));
|
||||||
ret!(aeabi_uidiv(arg!(), arg!()));
|
bb(powisf2(bb(2.), bb(3)));
|
||||||
ret!(aeabi_uidivmod(arg!(), arg!()));
|
bb(umoddi3(bb(2), bb(3)));
|
||||||
ret!(aeabi_ul2d(arg!()));
|
|
||||||
ret!(aeabi_ul2f(arg!()));
|
|
||||||
ret!(aeabi_uldivmod(arg!(), arg!()));
|
|
||||||
ret!(moddi3(arg!(), arg!()));
|
|
||||||
ret!(mulodi4(arg!(), arg!()));
|
|
||||||
ret!(powidf2(arg!(), arg!()));
|
|
||||||
ret!(powisf2(arg!(), arg!()));
|
|
||||||
ret!(umoddi3(arg!(), arg!()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "c", not(thumb)))]
|
#[cfg(all(feature = "c", not(thumb)))]
|
||||||
|
|
Loading…
Reference in New Issue