diff --git a/src/abi.rs b/src/abi.rs index 92872a14359..0fa546f50e5 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -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); diff --git a/src/lib.rs b/src/lib.rs index fb23522738d..cdaabcf9a39 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,6 +40,7 @@ mod debuginfo; mod driver; mod intrinsics; mod linkage; +mod llvm_intrinsics; mod main_shim; mod metadata; mod pretty_clif; diff --git a/src/llvm_intrinsics.rs b/src/llvm_intrinsics.rs new file mode 100644 index 00000000000..63627c41a2c --- /dev/null +++ b/src/llvm_intrinsics.rs @@ -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>, + 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."); + } +}