Skip to content

Commit 915af4f

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 be36d2f commit 915af4f

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
@@ -1622,7 +1622,7 @@ impl<'a, 'll, CX: Borrow<SCx<'ll>>> GenericBuilder<'a, 'll, CX> {
16221622
ret.expect("LLVM does not have support for catchret")
16231623
}
16241624

1625-
fn check_call<'b>(
1625+
pub(crate) fn check_call<'b>(
16261626
&mut self,
16271627
typ: &str,
16281628
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,
@@ -661,7 +663,20 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
661663
}
662664
}
663665

664-
let llret = self.call(fn_ty, None, None, fn_ptr, &llargs, None, None);
666+
debug!("call intrinsic {:?} with args ({:?})", instance, llargs);
667+
let args = self.check_call("call", fn_ty, fn_ptr, &llargs);
668+
let llret = unsafe {
669+
llvm::LLVMBuildCallWithOperandBundles(
670+
self.llbuilder,
671+
fn_ty,
672+
fn_ptr,
673+
args.as_ptr() as *const &llvm::Value,
674+
args.len() as c_uint,
675+
ptr::dangling(),
676+
0,
677+
c"".as_ptr(),
678+
)
679+
};
665680
if is_cleanup {
666681
self.apply_attrs_to_cleanup_callsite(llret);
667682
}

0 commit comments

Comments
 (0)