Skip to content

Commit 0b37b58

Browse files
committed
rustc_codegen_ssa: take the &FnAbi directly in call/invoke, for attributes.
1 parent a297a5b commit 0b37b58

File tree

9 files changed

+77
-56
lines changed

9 files changed

+77
-56
lines changed

compiler/rustc_codegen_llvm/src/abi.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -601,11 +601,7 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
601601
}
602602
}
603603

604-
impl AbiBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
605-
fn apply_attrs_callsite(&mut self, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, callsite: Self::Value) {
606-
fn_abi.apply_attrs_callsite(self, callsite)
607-
}
608-
604+
impl AbiBuilderMethods for Builder<'_, '_, '_> {
609605
fn get_param(&self, index: usize) -> Self::Value {
610606
llvm::get_param(self.llfn(), index as c_uint)
611607
}

compiler/rustc_codegen_llvm/src/asm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ fn inline_asm_call(
402402
alignstack,
403403
llvm::AsmDialect::from_generic(dia),
404404
);
405-
let call = bx.call(v, inputs, None);
405+
let call = bx.call(v, inputs, None, None);
406406

407407
// Store mark in a metadata node so we can map LLVM errors
408408
// back to source locations. See #17552.

compiler/rustc_codegen_llvm/src/builder.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::abi::FnAbiLlvmExt;
12
use crate::common::Funclet;
23
use crate::context::CodegenCx;
34
use crate::llvm::{self, BasicBlock, False};
@@ -18,6 +19,7 @@ use rustc_hir::def_id::DefId;
1819
use rustc_middle::ty::layout::TyAndLayout;
1920
use rustc_middle::ty::{self, Ty, TyCtxt};
2021
use rustc_span::Span;
22+
use rustc_target::abi::call::FnAbi;
2123
use rustc_target::abi::{self, Align, Size};
2224
use rustc_target::spec::{HasTargetSpec, Target};
2325
use std::borrow::Cow;
@@ -209,14 +211,15 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
209211
then: &'ll BasicBlock,
210212
catch: &'ll BasicBlock,
211213
funclet: Option<&Funclet<'ll>>,
214+
fn_abi_for_attrs: Option<&FnAbi<'tcx, Ty<'tcx>>>,
212215
) -> &'ll Value {
213216
debug!("invoke {:?} with args ({:?})", llfn, args);
214217

215218
let args = self.check_call("invoke", llfn, args);
216219
let bundle = funclet.map(|funclet| funclet.bundle());
217220
let bundle = bundle.as_ref().map(|b| &*b.raw);
218221

219-
unsafe {
222+
let invoke = unsafe {
220223
llvm::LLVMRustBuildInvoke(
221224
self.llbuilder,
222225
llfn,
@@ -227,7 +230,11 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
227230
bundle,
228231
UNNAMED,
229232
)
233+
};
234+
if let Some(fn_abi) = fn_abi_for_attrs {
235+
fn_abi.apply_attrs_callsite(self, invoke);
230236
}
237+
invoke
231238
}
232239

233240
fn unreachable(&mut self) {
@@ -374,7 +381,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
374381
};
375382

376383
let intrinsic = self.get_intrinsic(&name);
377-
let res = self.call(intrinsic, &[lhs, rhs], None);
384+
let res = self.call(intrinsic, &[lhs, rhs], None, None);
378385
(self.extract_value(res, 0), self.extract_value(res, 1))
379386
}
380387

@@ -684,7 +691,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
684691
let int_width = self.cx.int_width(dest_ty);
685692
let name = format!("llvm.fptoui.sat.i{}.f{}", int_width, float_width);
686693
let intrinsic = self.get_intrinsic(&name);
687-
return Some(self.call(intrinsic, &[val], None));
694+
return Some(self.call(intrinsic, &[val], None, None));
688695
}
689696

690697
None
@@ -697,7 +704,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
697704
let int_width = self.cx.int_width(dest_ty);
698705
let name = format!("llvm.fptosi.sat.i{}.f{}", int_width, float_width);
699706
let intrinsic = self.get_intrinsic(&name);
700-
return Some(self.call(intrinsic, &[val], None));
707+
return Some(self.call(intrinsic, &[val], None, None));
701708
}
702709

703710
None
@@ -732,7 +739,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
732739
};
733740
if let Some(name) = name {
734741
let intrinsic = self.get_intrinsic(name);
735-
return self.call(intrinsic, &[val], None);
742+
return self.call(intrinsic, &[val], None, None);
736743
}
737744
}
738745
}
@@ -755,7 +762,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
755762
};
756763
if let Some(name) = name {
757764
let intrinsic = self.get_intrinsic(name);
758-
return self.call(intrinsic, &[val], None);
765+
return self.call(intrinsic, &[val], None, None);
759766
}
760767
}
761768
}
@@ -1130,22 +1137,27 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
11301137
llfn: &'ll Value,
11311138
args: &[&'ll Value],
11321139
funclet: Option<&Funclet<'ll>>,
1140+
fn_abi_for_attrs: Option<&FnAbi<'tcx, Ty<'tcx>>>,
11331141
) -> &'ll Value {
11341142
debug!("call {:?} with args ({:?})", llfn, args);
11351143

11361144
let args = self.check_call("call", llfn, args);
11371145
let bundle = funclet.map(|funclet| funclet.bundle());
11381146
let bundle = bundle.as_ref().map(|b| &*b.raw);
11391147

1140-
unsafe {
1148+
let call = unsafe {
11411149
llvm::LLVMRustBuildCall(
11421150
self.llbuilder,
11431151
llfn,
11441152
args.as_ptr() as *const &llvm::Value,
11451153
args.len() as c_uint,
11461154
bundle,
11471155
)
1156+
};
1157+
if let Some(fn_abi) = fn_abi_for_attrs {
1158+
fn_abi.apply_attrs_callsite(self, call);
11481159
}
1160+
call
11491161
}
11501162

11511163
fn zext(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
@@ -1374,7 +1386,7 @@ impl Builder<'a, 'll, 'tcx> {
13741386
let lifetime_intrinsic = self.cx.get_intrinsic(intrinsic);
13751387

13761388
let ptr = self.pointercast(ptr, self.cx.type_i8p());
1377-
self.call(lifetime_intrinsic, &[self.cx.const_u64(size), ptr], None);
1389+
self.call(lifetime_intrinsic, &[self.cx.const_u64(size), ptr], None, None);
13781390
}
13791391

13801392
pub(crate) fn phi(

0 commit comments

Comments
 (0)