Skip to content

Commit b24babe

Browse files
committed
Auto merge of #146747 - a4lg:codegen-llvm-feature-float-tidying, r=petrochenkov
rustc_codegen_llvm: Tidying of `update_target_reliable_float_cfg` This PR simplifies floating type handling through `update_target_reliable_float_cfg` based on several facts: 1. Major changes in behavior normally occurs only on the major LLVM upgrade. 2. The first release of LLVM 20.x.x is 20.1.0. Due to the first fact, we can normally ignore minor and patch releases of LLVM and we can remove obscure variables like `lt_xx_x_x`. The second fact is missed when the minimum LLVM version is raised to LLVM 20 (cf. #145071) and one "fixed in LLVM 20" case can be safely removed (another cannot be removed since it's fixed on LLVM 20.1.1). It also reorders certain `match` clauses by the architecture when there's no problems reordering it. Note that, an LLVM issue on MIPS is fixed on LLVM 20.1.**0** and another on AArch64 is fixed on LLVM 20.1.**1**. Originally, they are both considered fixed on LLVM 20.1.**1** but the author separated them into two cases (so that the MIPS bug checking can be removed).
2 parents d0835ad + 42d9f09 commit b24babe

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -364,25 +364,25 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
364364
let target_abi = &sess.target.options.abi;
365365
let target_pointer_width = sess.target.pointer_width;
366366
let version = get_version();
367-
let lt_20_1_1 = version < (20, 1, 1);
368-
let lt_21_0_0 = version < (21, 0, 0);
367+
let (major, _, _) = version;
369368

370369
cfg.has_reliable_f16 = match (target_arch, target_os) {
371-
// LLVM crash without neon <https://github.com/llvm/llvm-project/issues/129394> (fixed in llvm20)
370+
// LLVM crash without neon <https://github.com/llvm/llvm-project/issues/129394> (fixed in LLVM 20.1.1)
372371
(Arch::AArch64, _)
373-
if !cfg.target_features.iter().any(|f| f.as_str() == "neon") && lt_20_1_1 =>
372+
if !cfg.target_features.iter().any(|f| f.as_str() == "neon")
373+
&& version < (20, 1, 1) =>
374374
{
375375
false
376376
}
377377
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
378378
(Arch::Arm64EC, _) => false,
379379
// Selection failure <https://github.com/llvm/llvm-project/issues/50374> (fixed in llvm21)
380-
(Arch::S390x, _) if lt_21_0_0 => false,
380+
(Arch::S390x, _) if major < 21 => false,
381381
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
382382
(Arch::X86_64, Os::Windows) if *target_env == Env::Gnu && *target_abi != Abi::Llvm => false,
383383
// Infinite recursion <https://github.com/llvm/llvm-project/issues/97981>
384384
(Arch::CSky, _) => false,
385-
(Arch::Hexagon, _) if lt_21_0_0 => false, // (fixed in llvm21)
385+
(Arch::Hexagon, _) if major < 21 => false, // (fixed in llvm21)
386386
(Arch::PowerPC | Arch::PowerPC64, _) => false,
387387
(Arch::Sparc | Arch::Sparc64, _) => false,
388388
(Arch::Wasm32 | Arch::Wasm64, _) => false,
@@ -393,23 +393,23 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
393393
};
394394

395395
cfg.has_reliable_f128 = match (target_arch, target_os) {
396+
// Unsupported https://github.com/llvm/llvm-project/issues/121122
397+
(Arch::AmdGpu, _) => false,
396398
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
397399
(Arch::Arm64EC, _) => false,
398-
// Selection bug <https://github.com/llvm/llvm-project/issues/96432> (fixed in llvm20)
399-
(Arch::Mips64 | Arch::Mips64r6, _) if lt_20_1_1 => false,
400+
// Selection bug <https://github.com/llvm/llvm-project/issues/96432> (fixed in LLVM 20.1.0)
401+
(Arch::Mips64 | Arch::Mips64r6, _) if version < (20, 1, 0) => false,
400402
// Selection bug <https://github.com/llvm/llvm-project/issues/95471>. This issue is closed
401403
// but basic math still does not work.
402404
(Arch::Nvptx64, _) => false,
403-
// Unsupported https://github.com/llvm/llvm-project/issues/121122
404-
(Arch::AmdGpu, _) => false,
405405
// ABI bugs <https://github.com/rust-lang/rust/issues/125109> et al. (full
406406
// list at <https://github.com/rust-lang/rust/issues/116909>)
407407
(Arch::PowerPC | Arch::PowerPC64, _) => false,
408408
// ABI unsupported <https://github.com/llvm/llvm-project/issues/41838>
409409
(Arch::Sparc, _) => false,
410410
// Stack alignment bug <https://github.com/llvm/llvm-project/issues/77401>. NB: tests may
411411
// not fail if our compiler-builtins is linked. (fixed in llvm21)
412-
(Arch::X86, _) if lt_21_0_0 => false,
412+
(Arch::X86, _) if major < 21 => false,
413413
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
414414
(Arch::X86_64, Os::Windows) if *target_env == Env::Gnu && *target_abi != Abi::Llvm => false,
415415
// There are no known problems on other platforms, so the only requirement is that symbols

0 commit comments

Comments
 (0)