diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs index 057e275945498..4f9b86ec20a7b 100644 --- a/compiler/rustc_codegen_llvm/src/builder.rs +++ b/compiler/rustc_codegen_llvm/src/builder.rs @@ -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; @@ -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]); + } } } diff --git a/tests/assembly/stack-protector/stack-protector-heuristics-effect.rs b/tests/assembly/stack-protector/stack-protector-heuristics-effect.rs index 91b218c7a3cfb..e46b902df0795 100644 --- a/tests/assembly/stack-protector/stack-protector-heuristics-effect.rs +++ b/tests/assembly/stack-protector/stack-protector-heuristics-effect.rs @@ -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"] diff --git a/tests/codegen/issue-97217.rs b/tests/codegen/issue-97217.rs index 5558447cd1781..af7345442fc51 100644 --- a/tests/codegen/issue-97217.rs +++ b/tests/codegen/issue-97217.rs @@ -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) diff --git a/tests/codegen/unwind-landingpad-cold.rs b/tests/codegen/unwind-landingpad-cold.rs index 53d0a01a9523c..3a902a7d71238 100644 --- a/tests/codegen/unwind-landingpad-cold.rs +++ b/tests/codegen/unwind-landingpad-cold.rs @@ -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 diff --git a/tests/codegen/unwind-landingpad-inline.rs b/tests/codegen/unwind-landingpad-inline.rs index a65d6f202f6f4..0774cefdd2d1a 100644 --- a/tests/codegen/unwind-landingpad-inline.rs +++ b/tests/codegen/unwind-landingpad-inline.rs @@ -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"]