1
Fork 0

Generate llvm.sideeffect at function entry instead of call

This commit is contained in:
Xiang Fan 2019-09-28 07:14:21 +08:00
parent 10c668190c
commit e9acfa306f
4 changed files with 12 additions and 6 deletions

View file

@ -124,7 +124,6 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
self.call(expect, &[args[0].immediate(), self.const_bool(false)], None)
}
"try" => {
self.sideeffect();
try_intrinsic(self,
args[0].immediate(),
args[1].immediate(),
@ -818,6 +817,7 @@ fn codegen_msvc_try(
) {
let llfn = get_rust_try_fn(bx, &mut |mut bx| {
bx.set_personality_fn(bx.eh_personality());
bx.sideeffect();
let mut normal = bx.build_sibling_block("normal");
let mut catchswitch = bx.build_sibling_block("catchswitch");
@ -941,6 +941,8 @@ fn codegen_gnu_try(
// expected to be `*mut *mut u8` for this to actually work, but that's
// managed by the standard library.
bx.sideeffect();
let mut then = bx.build_sibling_block("then");
let mut catch = bx.build_sibling_block("catch");

View file

@ -364,7 +364,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
FnType::of_instance(&bx, drop_fn))
}
};
bx.sideeffect();
helper.maybe_sideeffect(self.mir, &mut bx, &[target]);
helper.do_call(self, &mut bx, fn_ty, drop_fn, args,
Some((ReturnDest::Nothing, target)),
unwind);
@ -464,7 +464,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
let fn_ty = FnType::of_instance(&bx, instance);
let llfn = bx.get_fn(instance);
bx.sideeffect();
// Codegen the actual panic invoke/call.
helper.do_call(self, &mut bx, fn_ty, llfn, &args, None, cleanup);
}
@ -584,7 +583,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
let fn_ty = FnType::of_instance(&bx, instance);
let llfn = bx.get_fn(instance);
bx.sideeffect();
if let Some((_, target)) = destination.as_ref() {
helper.maybe_sideeffect(self.mir, &mut bx, &[*target]);
}
// Codegen the actual panic invoke/call.
helper.do_call(
self,
@ -820,7 +821,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
_ => span_bug!(span, "no llfn for call"),
};
bx.sideeffect();
if let Some((_, target)) = destination.as_ref() {
helper.maybe_sideeffect(self.mir, &mut bx, &[*target]);
}
helper.do_call(self, &mut bx, fn_ty, fn_ptr, &llargs,
destination.as_ref().map(|&(_, target)| (ret_dest, target)),
cleanup);

View file

@ -204,6 +204,8 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx.set_personality_fn(cx.eh_personality());
}
bx.sideeffect();
let cleanup_kinds = analyze::cleanup_kinds(&mir);
// Allocate a `Block` for every basic block, except
// the start block, if nothing loops back to it.

View file

@ -486,7 +486,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
};
let instance = ty::Instance::mono(bx.tcx(), def_id);
let r = bx.cx().get_fn(instance);
bx.sideeffect();
let call = bx.call(r, &[llsize, llalign], None);
let val = bx.pointercast(call, llty_ptr);