Skip to content

Commit 539a6a4

Browse files
committed
Inline BuilderMethods::call for intrinsics
Intrinsics only need a fraction of the functionality offered by BuilderMethods::call and in particular don't need the FnAbi to be computed other than (currently) as step towards computing the function value type.
1 parent e5dd38b commit 539a6a4

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

compiler/rustc_codegen_llvm/src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1682,7 +1682,7 @@ impl<'a, 'll, CX: Borrow<SCx<'ll>>> GenericBuilder<'a, 'll, CX> {
16821682
ret.expect("LLVM does not have support for catchret")
16831683
}
16841684

1685-
fn check_call<'b>(
1685+
pub(crate) fn check_call<'b>(
16861686
&mut self,
16871687
typ: &str,
16881688
fn_ty: &'ll Type,

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use std::assert_matches::assert_matches;
22
use std::cmp::Ordering;
3+
use std::ffi::c_uint;
4+
use std::ptr;
35

46
use rustc_abi::{
57
Align, BackendRepr, ExternAbi, Float, HasDataLayout, Primitive, Size, WrappingRange,
@@ -652,7 +654,20 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
652654
}
653655
}
654656

655-
let llret = self.call(fn_ty, None, None, fn_ptr, &llargs, None, None);
657+
debug!("call intrinsic {:?} with args ({:?})", instance, llargs);
658+
let args = self.check_call("call", fn_ty, fn_ptr, &llargs);
659+
let llret = unsafe {
660+
llvm::LLVMBuildCallWithOperandBundles(
661+
self.llbuilder,
662+
fn_ty,
663+
fn_ptr,
664+
args.as_ptr() as *const &llvm::Value,
665+
args.len() as c_uint,
666+
ptr::dangling(),
667+
0,
668+
c"".as_ptr(),
669+
)
670+
};
656671
if is_cleanup {
657672
self.apply_attrs_to_cleanup_callsite(llret);
658673
}

0 commit comments

Comments
 (0)