Skip to content

Commit 0348509

Browse files
committed
Pass PlaceRef rather than Bx::Value to codegen_intrinsic_call
1 parent 8ad6957 commit 0348509

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/intrinsic/mod.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use rustc_codegen_ssa::traits::{
2222
};
2323
use rustc_middle::bug;
2424
#[cfg(feature = "master")]
25-
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt};
25+
use rustc_middle::ty::layout::FnAbiOf;
2626
use rustc_middle::ty::layout::{HasTypingEnv, LayoutOf};
2727
use rustc_middle::ty::{self, Instance, Ty};
2828
use rustc_span::{Span, Symbol, sym};
@@ -202,7 +202,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
202202
instance: Instance<'tcx>,
203203
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
204204
args: &[OperandRef<'tcx, RValue<'gcc>>],
205-
llresult: RValue<'gcc>,
205+
result: PlaceRef<'tcx, RValue<'gcc>>,
206206
span: Span,
207207
) -> Result<(), Instance<'tcx>> {
208208
let tcx = self.tcx;
@@ -221,7 +221,6 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
221221
let name_str = name.as_str();
222222

223223
let llret_ty = self.layout_of(ret_ty).gcc_type(self);
224-
let result = PlaceRef::new_sized(llresult, fn_abi.ret.layout);
225224

226225
let simple = get_simple_intrinsic(self, name);
227226
let simple_func = get_simple_function(self, name);
@@ -271,7 +270,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
271270
args[0].immediate(),
272271
args[1].immediate(),
273272
args[2].immediate(),
274-
llresult,
273+
result,
275274
);
276275
return Ok(());
277276
}
@@ -1230,14 +1229,13 @@ fn try_intrinsic<'a, 'b, 'gcc, 'tcx>(
12301229
try_func: RValue<'gcc>,
12311230
data: RValue<'gcc>,
12321231
_catch_func: RValue<'gcc>,
1233-
dest: RValue<'gcc>,
1232+
dest: PlaceRef<'tcx, RValue<'gcc>>,
12341233
) {
12351234
if bx.sess().panic_strategy() == PanicStrategy::Abort {
12361235
bx.call(bx.type_void(), None, None, try_func, &[data], None, None);
12371236
// Return 0 unconditionally from the intrinsic call;
12381237
// we can never unwind.
1239-
let ret_align = bx.tcx.data_layout.i32_align.abi;
1240-
bx.store(bx.const_i32(0), dest, ret_align);
1238+
OperandValue::Immediate(bx.const_i32(0)).store(bx, dest);
12411239
} else {
12421240
if wants_msvc_seh(bx.sess()) {
12431241
unimplemented!();
@@ -1261,12 +1259,12 @@ fn try_intrinsic<'a, 'b, 'gcc, 'tcx>(
12611259
// functions in play. By calling a shim we're guaranteed that our shim will have
12621260
// the right personality function.
12631261
#[cfg(feature = "master")]
1264-
fn codegen_gnu_try<'gcc>(
1265-
bx: &mut Builder<'_, 'gcc, '_>,
1262+
fn codegen_gnu_try<'gcc, 'tcx>(
1263+
bx: &mut Builder<'_, 'gcc, 'tcx>,
12661264
try_func: RValue<'gcc>,
12671265
data: RValue<'gcc>,
12681266
catch_func: RValue<'gcc>,
1269-
dest: RValue<'gcc>,
1267+
dest: PlaceRef<'tcx, RValue<'gcc>>,
12701268
) {
12711269
let cx: &CodegenCx<'gcc, '_> = bx.cx;
12721270
let (llty, func) = get_rust_try_fn(cx, &mut |mut bx| {
@@ -1322,8 +1320,7 @@ fn codegen_gnu_try<'gcc>(
13221320
// Note that no invoke is used here because by definition this function
13231321
// can't panic (that's what it's catching).
13241322
let ret = bx.call(llty, None, None, func, &[try_func, data, catch_func], None, None);
1325-
let i32_align = bx.tcx().data_layout.i32_align.abi;
1326-
bx.store(ret, dest, i32_align);
1323+
OperandValue::Immediate(ret).store(bx, dest);
13271324
}
13281325

13291326
// Helper function used to get a handle to the `__rust_try` function used to

0 commit comments

Comments
 (0)