1
Fork 0

Remove the -Zinsert-sideeffect

This removes all of the code we had in place to work-around LLVM's
handling of forward progress. From this removal excluded is a workaround
where we'd insert a `sideeffect` into clearly infinite loops such as
`loop {}`. This code remains conditionally effective when the LLVM
version is earlier than 12.0, which fixed the forward progress related
miscompilations at their root.
This commit is contained in:
Simonas Kazlauskas 2021-03-08 01:59:10 +02:00
parent 861872bc45
commit 0517acd543
11 changed files with 52 additions and 87 deletions

View file

@ -334,8 +334,11 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
self.call(expect, &[cond, self.const_bool(expected)], None)
}
fn sideeffect(&mut self, unconditional: bool) {
if unconditional || self.tcx.sess.opts.debugging_opts.insert_sideeffect {
fn sideeffect(&mut self) {
// This kind of check would make a ton of sense in the caller, but currently the only
// caller of this function is in `rustc_codegen_ssa`, which is agnostic to whether LLVM
// codegen backend being used, and so is unable to check the LLVM version.
if unsafe { llvm::LLVMRustVersionMajor() } < 12 {
let fnname = self.get_intrinsic(&("llvm.sideeffect"));
self.call(fnname, &[], None);
}
@ -390,7 +393,6 @@ fn codegen_msvc_try(
) {
let llfn = get_rust_try_fn(bx, &mut |mut bx| {
bx.set_personality_fn(bx.eh_personality());
bx.sideeffect(false);
let mut normal = bx.build_sibling_block("normal");
let mut catchswitch = bx.build_sibling_block("catchswitch");
@ -552,9 +554,6 @@ fn codegen_gnu_try(
// (%ptr, _) = landingpad
// call %catch_func(%data, %ptr)
// ret 1
bx.sideeffect(false);
let mut then = bx.build_sibling_block("then");
let mut catch = bx.build_sibling_block("catch");
@ -614,9 +613,6 @@ fn codegen_emcc_try(
// %catch_data[1] = %is_rust_panic
// call %catch_func(%data, %catch_data)
// ret 1
bx.sideeffect(false);
let mut then = bx.build_sibling_block("then");
let mut catch = bx.build_sibling_block("catch");