Generate llvm.sideeffect at function entry instead of call
This commit is contained in:
parent
10c668190c
commit
e9acfa306f
4 changed files with 12 additions and 6 deletions
|
@ -124,7 +124,6 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
|
||||||
self.call(expect, &[args[0].immediate(), self.const_bool(false)], None)
|
self.call(expect, &[args[0].immediate(), self.const_bool(false)], None)
|
||||||
}
|
}
|
||||||
"try" => {
|
"try" => {
|
||||||
self.sideeffect();
|
|
||||||
try_intrinsic(self,
|
try_intrinsic(self,
|
||||||
args[0].immediate(),
|
args[0].immediate(),
|
||||||
args[1].immediate(),
|
args[1].immediate(),
|
||||||
|
@ -818,6 +817,7 @@ fn codegen_msvc_try(
|
||||||
) {
|
) {
|
||||||
let llfn = get_rust_try_fn(bx, &mut |mut bx| {
|
let llfn = get_rust_try_fn(bx, &mut |mut bx| {
|
||||||
bx.set_personality_fn(bx.eh_personality());
|
bx.set_personality_fn(bx.eh_personality());
|
||||||
|
bx.sideeffect();
|
||||||
|
|
||||||
let mut normal = bx.build_sibling_block("normal");
|
let mut normal = bx.build_sibling_block("normal");
|
||||||
let mut catchswitch = bx.build_sibling_block("catchswitch");
|
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
|
// expected to be `*mut *mut u8` for this to actually work, but that's
|
||||||
// managed by the standard library.
|
// managed by the standard library.
|
||||||
|
|
||||||
|
bx.sideeffect();
|
||||||
|
|
||||||
let mut then = bx.build_sibling_block("then");
|
let mut then = bx.build_sibling_block("then");
|
||||||
let mut catch = bx.build_sibling_block("catch");
|
let mut catch = bx.build_sibling_block("catch");
|
||||||
|
|
||||||
|
|
|
@ -364,7 +364,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
FnType::of_instance(&bx, drop_fn))
|
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,
|
helper.do_call(self, &mut bx, fn_ty, drop_fn, args,
|
||||||
Some((ReturnDest::Nothing, target)),
|
Some((ReturnDest::Nothing, target)),
|
||||||
unwind);
|
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 fn_ty = FnType::of_instance(&bx, instance);
|
||||||
let llfn = bx.get_fn(instance);
|
let llfn = bx.get_fn(instance);
|
||||||
|
|
||||||
bx.sideeffect();
|
|
||||||
// Codegen the actual panic invoke/call.
|
// Codegen the actual panic invoke/call.
|
||||||
helper.do_call(self, &mut bx, fn_ty, llfn, &args, None, cleanup);
|
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 fn_ty = FnType::of_instance(&bx, instance);
|
||||||
let llfn = bx.get_fn(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.
|
// Codegen the actual panic invoke/call.
|
||||||
helper.do_call(
|
helper.do_call(
|
||||||
self,
|
self,
|
||||||
|
@ -820,7 +821,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
_ => span_bug!(span, "no llfn for call"),
|
_ => 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,
|
helper.do_call(self, &mut bx, fn_ty, fn_ptr, &llargs,
|
||||||
destination.as_ref().map(|&(_, target)| (ret_dest, target)),
|
destination.as_ref().map(|&(_, target)| (ret_dest, target)),
|
||||||
cleanup);
|
cleanup);
|
||||||
|
|
|
@ -204,6 +204,8 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
bx.set_personality_fn(cx.eh_personality());
|
bx.set_personality_fn(cx.eh_personality());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bx.sideeffect();
|
||||||
|
|
||||||
let cleanup_kinds = analyze::cleanup_kinds(&mir);
|
let cleanup_kinds = analyze::cleanup_kinds(&mir);
|
||||||
// Allocate a `Block` for every basic block, except
|
// Allocate a `Block` for every basic block, except
|
||||||
// the start block, if nothing loops back to it.
|
// the start block, if nothing loops back to it.
|
||||||
|
|
|
@ -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 instance = ty::Instance::mono(bx.tcx(), def_id);
|
||||||
let r = bx.cx().get_fn(instance);
|
let r = bx.cx().get_fn(instance);
|
||||||
bx.sideeffect();
|
|
||||||
let call = bx.call(r, &[llsize, llalign], None);
|
let call = bx.call(r, &[llsize, llalign], None);
|
||||||
let val = bx.pointercast(call, llty_ptr);
|
let val = bx.pointercast(call, llty_ptr);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue