Skip to content

Commit e9acfa3

Browse files
committed
Generate llvm.sideeffect at function entry instead of call
1 parent 10c6681 commit e9acfa3

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

src/librustc_codegen_llvm/intrinsic.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
124124
self.call(expect, &[args[0].immediate(), self.const_bool(false)], None)
125125
}
126126
"try" => {
127-
self.sideeffect();
128127
try_intrinsic(self,
129128
args[0].immediate(),
130129
args[1].immediate(),
@@ -818,6 +817,7 @@ fn codegen_msvc_try(
818817
) {
819818
let llfn = get_rust_try_fn(bx, &mut |mut bx| {
820819
bx.set_personality_fn(bx.eh_personality());
820+
bx.sideeffect();
821821

822822
let mut normal = bx.build_sibling_block("normal");
823823
let mut catchswitch = bx.build_sibling_block("catchswitch");
@@ -941,6 +941,8 @@ fn codegen_gnu_try(
941941
// expected to be `*mut *mut u8` for this to actually work, but that's
942942
// managed by the standard library.
943943

944+
bx.sideeffect();
945+
944946
let mut then = bx.build_sibling_block("then");
945947
let mut catch = bx.build_sibling_block("catch");
946948

src/librustc_codegen_ssa/mir/block.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
364364
FnType::of_instance(&bx, drop_fn))
365365
}
366366
};
367-
bx.sideeffect();
367+
helper.maybe_sideeffect(self.mir, &mut bx, &[target]);
368368
helper.do_call(self, &mut bx, fn_ty, drop_fn, args,
369369
Some((ReturnDest::Nothing, target)),
370370
unwind);
@@ -464,7 +464,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
464464
let fn_ty = FnType::of_instance(&bx, instance);
465465
let llfn = bx.get_fn(instance);
466466

467-
bx.sideeffect();
468467
// Codegen the actual panic invoke/call.
469468
helper.do_call(self, &mut bx, fn_ty, llfn, &args, None, cleanup);
470469
}
@@ -584,7 +583,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
584583
let fn_ty = FnType::of_instance(&bx, instance);
585584
let llfn = bx.get_fn(instance);
586585

587-
bx.sideeffect();
586+
if let Some((_, target)) = destination.as_ref() {
587+
helper.maybe_sideeffect(self.mir, &mut bx, &[*target]);
588+
}
588589
// Codegen the actual panic invoke/call.
589590
helper.do_call(
590591
self,
@@ -820,7 +821,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
820821
_ => span_bug!(span, "no llfn for call"),
821822
};
822823

823-
bx.sideeffect();
824+
if let Some((_, target)) = destination.as_ref() {
825+
helper.maybe_sideeffect(self.mir, &mut bx, &[*target]);
826+
}
824827
helper.do_call(self, &mut bx, fn_ty, fn_ptr, &llargs,
825828
destination.as_ref().map(|&(_, target)| (ret_dest, target)),
826829
cleanup);

src/librustc_codegen_ssa/mir/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
204204
bx.set_personality_fn(cx.eh_personality());
205205
}
206206

207+
bx.sideeffect();
208+
207209
let cleanup_kinds = analyze::cleanup_kinds(&mir);
208210
// Allocate a `Block` for every basic block, except
209211
// the start block, if nothing loops back to it.

src/librustc_codegen_ssa/mir/rvalue.rs

-1
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
486486
};
487487
let instance = ty::Instance::mono(bx.tcx(), def_id);
488488
let r = bx.cx().get_fn(instance);
489-
bx.sideeffect();
490489
let call = bx.call(r, &[llsize, llalign], None);
491490
let val = bx.pointercast(call, llty_ptr);
492491

0 commit comments

Comments
 (0)