about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/builder.rs
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2023-10-02 10:45:49 +0200
committerNikita Popov <npopov@redhat.com>2023-10-02 11:06:38 +0200
commit5bcf4f26ac44284b0dbc9b53404fa5dd8a0db01a (patch)
treed3d51fb862e7cc41f5615f56aa044c52edb1b9c8 /compiler/rustc_codegen_llvm/src/builder.rs
parentebbc68769d1207e8036cfbff00e5b8016e9a16b7 (diff)
downloadrust-5bcf4f26ac44284b0dbc9b53404fa5dd8a0db01a.tar.gz
rust-5bcf4f26ac44284b0dbc9b53404fa5dd8a0db01a.zip
Limit to LLVM 17.0.2 to work around WinEH codegen bug
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/builder.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/builder.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs
index 057e2759454..4f9b86ec20a 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]);
+        }
     }
 }