Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c211076

Browse files
committedApr 5, 2025·
Auto merge of rust-lang#139275 - cuviper:min-llvm-19, r=nikic
Update the minimum external LLVM to 19 With this change, we'll have stable support for LLVM 19 and 20. For reference, the previous increase to LLVM 18 was rust-lang#130487. cc `@rust-lang/wg-llvm` r? nikic
2 parents 5e17a2a + 12167d7 commit c211076

File tree

70 files changed

+222
-1911
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+222
-1911
lines changed
 

‎compiler/rustc_codegen_llvm/src/abi.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ use rustc_target::callconv::{
1717
use rustc_target::spec::SanitizerSet;
1818
use smallvec::SmallVec;
1919

20-
use crate::attributes::llfn_attrs_from_instance;
20+
use crate::attributes::{self, llfn_attrs_from_instance};
2121
use crate::builder::Builder;
2222
use crate::context::CodegenCx;
2323
use crate::llvm::{self, Attribute, AttributePlace};
2424
use crate::type_::Type;
2525
use crate::type_of::LayoutLlvmExt;
2626
use crate::value::Value;
27-
use crate::{attributes, llvm_util};
2827

2928
trait ArgAttributesExt {
3029
fn apply_attrs_to_llfn(&self, idx: AttributePlace, cx: &CodegenCx<'_, '_>, llfn: &Value);
@@ -437,7 +436,6 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
437436

438437
let apply_range_attr = |idx: AttributePlace, scalar: rustc_abi::Scalar| {
439438
if cx.sess().opts.optimize != config::OptLevel::No
440-
&& llvm_util::get_version() >= (19, 0, 0)
441439
&& matches!(scalar.primitive(), Primitive::Int(..))
442440
// If the value is a boolean, the range is 0..2 and that ultimately
443441
// become 0..0 when the type becomes i1, which would be rejected
@@ -571,19 +569,6 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
571569
}
572570
_ => {}
573571
}
574-
if bx.cx.sess().opts.optimize != config::OptLevel::No
575-
&& llvm_util::get_version() < (19, 0, 0)
576-
&& let BackendRepr::Scalar(scalar) = self.ret.layout.backend_repr
577-
&& matches!(scalar.primitive(), Primitive::Int(..))
578-
// If the value is a boolean, the range is 0..2 and that ultimately
579-
// become 0..0 when the type becomes i1, which would be rejected
580-
// by the LLVM verifier.
581-
&& !scalar.is_bool()
582-
// LLVM also rejects full range.
583-
&& !scalar.is_always_valid(bx)
584-
{
585-
bx.range_metadata(callsite, scalar.valid_range(bx));
586-
}
587572
for arg in self.args.iter() {
588573
match &arg.mode {
589574
PassMode::Ignore => {}

‎compiler/rustc_codegen_llvm/src/attributes.rs

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -407,30 +407,28 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
407407
// Do not set sanitizer attributes for naked functions.
408408
to_add.extend(sanitize_attrs(cx, codegen_fn_attrs.no_sanitize));
409409

410-
if llvm_util::get_version() >= (19, 0, 0) {
411-
// For non-naked functions, set branch protection attributes on aarch64.
412-
if let Some(BranchProtection { bti, pac_ret }) =
413-
cx.sess().opts.unstable_opts.branch_protection
414-
{
415-
assert!(cx.sess().target.arch == "aarch64");
416-
if bti {
417-
to_add.push(llvm::CreateAttrString(cx.llcx, "branch-target-enforcement"));
418-
}
419-
if let Some(PacRet { leaf, pc, key }) = pac_ret {
420-
if pc {
421-
to_add.push(llvm::CreateAttrString(cx.llcx, "branch-protection-pauth-lr"));
422-
}
423-
to_add.push(llvm::CreateAttrStringValue(
424-
cx.llcx,
425-
"sign-return-address",
426-
if leaf { "all" } else { "non-leaf" },
427-
));
428-
to_add.push(llvm::CreateAttrStringValue(
429-
cx.llcx,
430-
"sign-return-address-key",
431-
if key == PAuthKey::A { "a_key" } else { "b_key" },
432-
));
410+
// For non-naked functions, set branch protection attributes on aarch64.
411+
if let Some(BranchProtection { bti, pac_ret }) =
412+
cx.sess().opts.unstable_opts.branch_protection
413+
{
414+
assert!(cx.sess().target.arch == "aarch64");
415+
if bti {
416+
to_add.push(llvm::CreateAttrString(cx.llcx, "branch-target-enforcement"));
417+
}
418+
if let Some(PacRet { leaf, pc, key }) = pac_ret {
419+
if pc {
420+
to_add.push(llvm::CreateAttrString(cx.llcx, "branch-protection-pauth-lr"));
433421
}
422+
to_add.push(llvm::CreateAttrStringValue(
423+
cx.llcx,
424+
"sign-return-address",
425+
if leaf { "all" } else { "non-leaf" },
426+
));
427+
to_add.push(llvm::CreateAttrStringValue(
428+
cx.llcx,
429+
"sign-return-address-key",
430+
if key == PAuthKey::A { "a_key" } else { "b_key" },
431+
));
434432
}
435433
}
436434
}
@@ -510,12 +508,6 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
510508
InstructionSetAttr::ArmA32 => "-thumb-mode".to_string(),
511509
InstructionSetAttr::ArmT32 => "+thumb-mode".to_string(),
512510
}))
513-
// HACK: LLVM versions 19+ do not have the FPMR feature and treat it as always enabled
514-
// It only exists as a feature in LLVM 18, cannot be passed down for any other version
515-
.chain(match &*cx.tcx.sess.target.arch {
516-
"aarch64" if llvm_util::get_version().0 == 18 => vec!["+fpmr".to_string()],
517-
_ => vec![],
518-
})
519511
.collect::<Vec<String>>();
520512

521513
if cx.tcx.sess.target.is_like_wasm {

0 commit comments

Comments
 (0)
This repository has been archived.