Skip to content

Commit

Permalink
Limit to LLVM 17.0.2 to work around WinEH codegen bug
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Oct 2, 2023
1 parent ebbc687 commit 5bcf4f2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
14 changes: 10 additions & 4 deletions compiler/rustc_codegen_llvm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::attributes;
use crate::common::Funclet;
use crate::context::CodegenCx;
use crate::llvm::{self, AtomicOrdering, AtomicRmwBinOp, BasicBlock, False, True};
use crate::llvm_util;
use crate::type_::Type;
use crate::type_of::LayoutLlvmExt;
use crate::value::Value;
Expand Down Expand Up @@ -1226,10 +1227,15 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
}

fn apply_attrs_to_cleanup_callsite(&mut self, llret: &'ll Value) {
// Cleanup is always the cold path.
let cold_inline = llvm::AttributeKind::Cold.create_attr(self.llcx);

attributes::apply_to_callsite(llret, llvm::AttributePlace::Function, &[cold_inline]);
if llvm_util::get_version() < (17, 0, 2) {
// Work around https://github.com/llvm/llvm-project/issues/66984.
let noinline = llvm::AttributeKind::NoInline.create_attr(self.llcx);
attributes::apply_to_callsite(llret, llvm::AttributePlace::Function, &[noinline]);
} else {
// Cleanup is always the cold path.
let cold_inline = llvm::AttributeKind::Cold.create_attr(self.llcx);
attributes::apply_to_callsite(llret, llvm::AttributePlace::Function, &[cold_inline]);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// [basic] compile-flags: -Z stack-protector=basic
// [none] compile-flags: -Z stack-protector=none
// compile-flags: -C opt-level=2 -Z merge-functions=disabled
// min-llvm-version: 17.0.2

#![crate_type = "lib"]

Expand Down
1 change: 1 addition & 0 deletions tests/codegen/issue-97217.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// compile-flags: -C opt-level=3
// ignore-debug: the debug assertions get in the way
// min-llvm-version: 17.0.2
#![crate_type = "lib"]

// Regression test for issue 97217 (the following should result in no allocations)
Expand Down
1 change: 1 addition & 0 deletions tests/codegen/unwind-landingpad-cold.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// compile-flags: -Cno-prepopulate-passes
// needs-unwind
// min-llvm-version: 17.0.2
#![crate_type = "lib"]

// This test checks that drop calls in unwind landing pads
Expand Down
2 changes: 1 addition & 1 deletion tests/codegen/unwind-landingpad-inline.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// min-llvm-version: 15.0.0
// min-llvm-version: 17.0.2
// compile-flags: -Copt-level=3
// ignore-debug: the debug assertions get in the way
#![crate_type = "lib"]
Expand Down

0 comments on commit 5bcf4f2

Please sign in to comment.