Skip to content

Commit 3f43ee2

Browse files
committed
Merge apply_attrs_callsite into call and invoke
Some codegen backends are not able to apply callsite attrs after the fact.
1 parent 69a065e commit 3f43ee2

File tree

5 files changed

+32
-13
lines changed

5 files changed

+32
-13
lines changed

src/abi.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ use crate::intrinsic::ArgAbiExt;
1111
use crate::type_of::LayoutGccExt;
1212

1313
impl<'a, 'gcc, 'tcx> AbiBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
14-
fn apply_attrs_callsite(&mut self, _fn_abi: &FnAbi<'tcx, Ty<'tcx>>, _callsite: Self::Value) {
15-
// TODO(antoyo)
16-
}
17-
1814
fn get_param(&mut self, index: usize) -> Self::Value {
1915
let func = self.current_func();
2016
let param = func.get_param(index as i32);

src/asm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
498498
if options.contains(InlineAsmOptions::NORETURN) {
499499
let builtin_unreachable = self.context.get_builtin_function("__builtin_unreachable");
500500
let builtin_unreachable: RValue<'gcc> = unsafe { std::mem::transmute(builtin_unreachable) };
501-
self.call(self.type_void(), builtin_unreachable, &[], None);
501+
self.call(self.type_void(), None, builtin_unreachable, &[], None);
502502
}
503503

504504
// Write results to outputs.

src/builder.rs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,11 +444,23 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
444444
self.block.end_with_switch(None, value, default_block, &gcc_cases);
445445
}
446446

447-
fn invoke(&mut self, typ: Type<'gcc>, func: RValue<'gcc>, args: &[RValue<'gcc>], then: Block<'gcc>, catch: Block<'gcc>, _funclet: Option<&Funclet>) -> RValue<'gcc> {
447+
fn invoke(
448+
&mut self,
449+
typ: Type<'gcc>,
450+
fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>,
451+
func: RValue<'gcc>,
452+
args: &[RValue<'gcc>],
453+
then: Block<'gcc>,
454+
catch: Block<'gcc>,
455+
_funclet: Option<&Funclet>,
456+
) -> RValue<'gcc> {
448457
// TODO(bjorn3): Properly implement unwinding.
449-
let call_site = self.call(typ, func, args, None);
458+
let call_site = self.call(typ, None, func, args, None);
450459
let condition = self.context.new_rvalue_from_int(self.bool_type, 1);
451460
self.llbb().end_with_conditional(None, condition, then, catch);
461+
if let Some(_fn_abi) = fn_abi {
462+
// TODO(bjorn3): Apply function attributes
463+
}
452464
call_site
453465
}
454466

@@ -1227,16 +1239,27 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
12271239
// TODO(antoyo)
12281240
}
12291241

1230-
fn call(&mut self, _typ: Type<'gcc>, func: RValue<'gcc>, args: &[RValue<'gcc>], funclet: Option<&Funclet>) -> RValue<'gcc> {
1242+
fn call(
1243+
&mut self,
1244+
_typ: Type<'gcc>,
1245+
fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>,
1246+
func: RValue<'gcc>,
1247+
args: &[RValue<'gcc>],
1248+
funclet: Option<&Funclet>,
1249+
) -> RValue<'gcc> {
12311250
// FIXME(antoyo): remove when having a proper API.
12321251
let gcc_func = unsafe { std::mem::transmute(func) };
1233-
if self.functions.borrow().values().find(|value| **value == gcc_func).is_some() {
1252+
let call = if self.functions.borrow().values().find(|value| **value == gcc_func).is_some() {
12341253
self.function_call(func, args, funclet)
12351254
}
12361255
else {
12371256
// If it's a not function that was defined, it's a function pointer.
12381257
self.function_ptr_call(func, args, funclet)
1258+
};
1259+
if let Some(_fn_abi) = fn_abi {
1260+
// TODO(bjorn3): Apply function attributes
12391261
}
1262+
call
12401263
}
12411264

12421265
fn zext(&mut self, value: RValue<'gcc>, dest_typ: Type<'gcc>) -> RValue<'gcc> {

src/intrinsic/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
100100
_ if simple.is_some() => {
101101
// FIXME(antoyo): remove this cast when the API supports function.
102102
let func = unsafe { std::mem::transmute(simple.expect("simple")) };
103-
self.call(self.type_void(), func, &args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(), None)
103+
self.call(self.type_void(), None, func, &args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(), None)
104104
},
105105
sym::likely => {
106106
self.expect(args[0].immediate(), true)
@@ -341,7 +341,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
341341
fn abort(&mut self) {
342342
let func = self.context.get_builtin_function("abort");
343343
let func: RValue<'gcc> = unsafe { std::mem::transmute(func) };
344-
self.call(self.type_void(), func, &[], None);
344+
self.call(self.type_void(), None, func, &[], None);
345345
}
346346

347347
fn assume(&mut self, value: Self::Value) {
@@ -1124,7 +1124,7 @@ fn try_intrinsic<'gcc, 'tcx>(bx: &mut Builder<'_, 'gcc, 'tcx>, try_func: RValue<
11241124
// NOTE: the `|| true` here is to use the panic=abort strategy with panic=unwind too
11251125
if bx.sess().panic_strategy() == PanicStrategy::Abort || true {
11261126
// TODO(bjorn3): Properly implement unwinding and remove the `|| true` once this is done.
1127-
bx.call(bx.type_void(), try_func, &[data], None);
1127+
bx.call(bx.type_void(), None, try_func, &[data], None);
11281128
// Return 0 unconditionally from the intrinsic call;
11291129
// we can never unwind.
11301130
let ret_align = bx.tcx.data_layout.i32_align.abi;

src/intrinsic/simd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(bx: &mut Builder<'a, 'gcc, 'tcx>,
461461
let llvm_name = &format!("llvm.{0}.v{1}{2}", intr_name, in_len, elem_ty_str);
462462
let function = intrinsic::llvm::intrinsic(llvm_name, &bx.cx);
463463
let function: RValue<'gcc> = unsafe { std::mem::transmute(function) };
464-
let c = bx.call(fn_ty, function, &args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(), None);
464+
let c = bx.call(fn_ty, None, function, &args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(), None);
465465
Ok(c)
466466
}
467467

0 commit comments

Comments
 (0)