Replace llvm intrinsics with runtime trap
This commit is contained in:
parent
90f2b12d47
commit
1a26891170
@ -643,6 +643,11 @@ pub fn codegen_terminator_call<'a, 'tcx: 'a>(
|
||||
let instance =
|
||||
ty::Instance::resolve(fx.tcx, ty::ParamEnv::reveal_all(), def_id, substs).unwrap();
|
||||
|
||||
if fx.tcx.symbol_name(instance).as_str().starts_with("llvm.") {
|
||||
crate::llvm_intrinsics::codegen_llvm_intrinsic_call(fx, &fx.tcx.symbol_name(instance).as_str(), substs, args, destination);
|
||||
return;
|
||||
}
|
||||
|
||||
match instance.def {
|
||||
InstanceDef::Intrinsic(_) => {
|
||||
crate::intrinsics::codegen_intrinsic_call(fx, def_id, substs, args, destination);
|
||||
|
@ -40,6 +40,7 @@ mod debuginfo;
|
||||
mod driver;
|
||||
mod intrinsics;
|
||||
mod linkage;
|
||||
mod llvm_intrinsics;
|
||||
mod main_shim;
|
||||
mod metadata;
|
||||
mod pretty_clif;
|
||||
|
21
src/llvm_intrinsics.rs
Normal file
21
src/llvm_intrinsics.rs
Normal file
@ -0,0 +1,21 @@
|
||||
use crate::prelude::*;
|
||||
|
||||
use rustc::ty::subst::SubstsRef;
|
||||
|
||||
pub fn codegen_llvm_intrinsic_call<'a, 'tcx: 'a>(
|
||||
fx: &mut FunctionCx<'a, 'tcx, impl Backend>,
|
||||
intrinsic: &str,
|
||||
substs: SubstsRef<'tcx>,
|
||||
args: Vec<CValue<'tcx>>,
|
||||
destination: Option<(CPlace<'tcx>, BasicBlock)>,
|
||||
) {
|
||||
fx.tcx.sess.warn(&format!("unsupported llvm intrinsic {}; replacing with trap", intrinsic));
|
||||
crate::trap::trap_unimplemented(fx, intrinsic);
|
||||
|
||||
if let Some((_, dest)) = destination {
|
||||
let ret_ebb = fx.get_ebb(dest);
|
||||
fx.bcx.ins().jump(ret_ebb, &[]);
|
||||
} else {
|
||||
trap_unreachable(fx, "[corruption] Diverging intrinsic returned.");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user