1
Fork 0

Limit to LLVM 17.0.2 to work around WinEH codegen bug

This commit is contained in:
Nikita Popov 2023-10-02 10:45:49 +02:00
parent ebbc68769d
commit 5bcf4f26ac
5 changed files with 14 additions and 5 deletions

View file

@ -3,6 +3,7 @@ use crate::attributes;
use crate::common::Funclet; use crate::common::Funclet;
use crate::context::CodegenCx; use crate::context::CodegenCx;
use crate::llvm::{self, AtomicOrdering, AtomicRmwBinOp, BasicBlock, False, True}; use crate::llvm::{self, AtomicOrdering, AtomicRmwBinOp, BasicBlock, False, True};
use crate::llvm_util;
use crate::type_::Type; use crate::type_::Type;
use crate::type_of::LayoutLlvmExt; use crate::type_of::LayoutLlvmExt;
use crate::value::Value; use crate::value::Value;
@ -1226,12 +1227,17 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
} }
fn apply_attrs_to_cleanup_callsite(&mut self, llret: &'ll Value) { fn apply_attrs_to_cleanup_callsite(&mut self, llret: &'ll Value) {
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. // Cleanup is always the cold path.
let cold_inline = llvm::AttributeKind::Cold.create_attr(self.llcx); let cold_inline = llvm::AttributeKind::Cold.create_attr(self.llcx);
attributes::apply_to_callsite(llret, llvm::AttributePlace::Function, &[cold_inline]); attributes::apply_to_callsite(llret, llvm::AttributePlace::Function, &[cold_inline]);
} }
} }
}
impl<'ll> StaticBuilderMethods for Builder<'_, 'll, '_> { impl<'ll> StaticBuilderMethods for Builder<'_, 'll, '_> {
fn get_static(&mut self, def_id: DefId) -> &'ll Value { fn get_static(&mut self, def_id: DefId) -> &'ll Value {

View file

@ -9,6 +9,7 @@
// [basic] compile-flags: -Z stack-protector=basic // [basic] compile-flags: -Z stack-protector=basic
// [none] compile-flags: -Z stack-protector=none // [none] compile-flags: -Z stack-protector=none
// compile-flags: -C opt-level=2 -Z merge-functions=disabled // compile-flags: -C opt-level=2 -Z merge-functions=disabled
// min-llvm-version: 17.0.2
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,5 +1,6 @@
// compile-flags: -C opt-level=3 // compile-flags: -C opt-level=3
// ignore-debug: the debug assertions get in the way // ignore-debug: the debug assertions get in the way
// min-llvm-version: 17.0.2
#![crate_type = "lib"] #![crate_type = "lib"]
// Regression test for issue 97217 (the following should result in no allocations) // Regression test for issue 97217 (the following should result in no allocations)

View file

@ -1,5 +1,6 @@
// compile-flags: -Cno-prepopulate-passes // compile-flags: -Cno-prepopulate-passes
// needs-unwind // needs-unwind
// min-llvm-version: 17.0.2
#![crate_type = "lib"] #![crate_type = "lib"]
// This test checks that drop calls in unwind landing pads // This test checks that drop calls in unwind landing pads

View file

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