Skip to content

Commit 5bcf4f2

Browse files
committedOct 2, 2023
Limit to LLVM 17.0.2 to work around WinEH codegen bug
1 parent ebbc687 commit 5bcf4f2

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed
 

‎compiler/rustc_codegen_llvm/src/builder.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::attributes;
33
use crate::common::Funclet;
44
use crate::context::CodegenCx;
55
use crate::llvm::{self, AtomicOrdering, AtomicRmwBinOp, BasicBlock, False, True};
6+
use crate::llvm_util;
67
use crate::type_::Type;
78
use crate::type_of::LayoutLlvmExt;
89
use crate::value::Value;
@@ -1226,10 +1227,15 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
12261227
}
12271228

12281229
fn apply_attrs_to_cleanup_callsite(&mut self, llret: &'ll Value) {
1229-
// Cleanup is always the cold path.
1230-
let cold_inline = llvm::AttributeKind::Cold.create_attr(self.llcx);
1231-
1232-
attributes::apply_to_callsite(llret, llvm::AttributePlace::Function, &[cold_inline]);
1230+
if llvm_util::get_version() < (17, 0, 2) {
1231+
// Work around https://github.com/llvm/llvm-project/issues/66984.
1232+
let noinline = llvm::AttributeKind::NoInline.create_attr(self.llcx);
1233+
attributes::apply_to_callsite(llret, llvm::AttributePlace::Function, &[noinline]);
1234+
} else {
1235+
// Cleanup is always the cold path.
1236+
let cold_inline = llvm::AttributeKind::Cold.create_attr(self.llcx);
1237+
attributes::apply_to_callsite(llret, llvm::AttributePlace::Function, &[cold_inline]);
1238+
}
12331239
}
12341240
}
12351241

‎tests/assembly/stack-protector/stack-protector-heuristics-effect.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// [basic] compile-flags: -Z stack-protector=basic
1010
// [none] compile-flags: -Z stack-protector=none
1111
// compile-flags: -C opt-level=2 -Z merge-functions=disabled
12+
// min-llvm-version: 17.0.2
1213

1314
#![crate_type = "lib"]
1415

‎tests/codegen/issue-97217.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// compile-flags: -C opt-level=3
22
// ignore-debug: the debug assertions get in the way
3+
// min-llvm-version: 17.0.2
34
#![crate_type = "lib"]
45

56
// Regression test for issue 97217 (the following should result in no allocations)

‎tests/codegen/unwind-landingpad-cold.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// compile-flags: -Cno-prepopulate-passes
22
// needs-unwind
3+
// min-llvm-version: 17.0.2
34
#![crate_type = "lib"]
45

56
// This test checks that drop calls in unwind landing pads

‎tests/codegen/unwind-landingpad-inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// min-llvm-version: 15.0.0
1+
// min-llvm-version: 17.0.2
22
// compile-flags: -Copt-level=3
33
// ignore-debug: the debug assertions get in the way
44
#![crate_type = "lib"]

0 commit comments

Comments
 (0)
Please sign in to comment.