Skip to content

Commit 9d33e2e

Browse files
committed
rustc_codegen_llvm: Simplify update_target_reliable_float_cfg
This commit 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` (still, there is a case where checking for patch version is required). The second fact is missed when the minimum LLVM version is raised to LLVM 20 and one "fixed in LLVM 20" case can be safely removed.
1 parent abaac34 commit 9d33e2e

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -360,26 +360,25 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
360360
let target_abi = &sess.target.options.abi;
361361
let target_pointer_width = sess.target.pointer_width;
362362
let version = get_version();
363-
let lt_20_1_0 = version < (20, 1, 0);
364-
let lt_20_1_1 = version < (20, 1, 1);
365-
let lt_21_0_0 = version < (21, 0, 0);
363+
let (major, _, _) = version;
366364

367365
cfg.has_reliable_f16 = match (target_arch, target_os) {
368366
// LLVM crash without neon <https://github.com/llvm/llvm-project/issues/129394> (fixed in LLVM 20.1.1)
369367
(Arch::AArch64, _)
370-
if !cfg.target_features.iter().any(|f| f.as_str() == "neon") && lt_20_1_1 =>
368+
if !cfg.target_features.iter().any(|f| f.as_str() == "neon")
369+
&& version < (20, 1, 1) =>
371370
{
372371
false
373372
}
374373
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
375374
(Arch::Arm64EC, _) => false,
376375
// Selection failure <https://github.com/llvm/llvm-project/issues/50374> (fixed in llvm21)
377-
(Arch::S390x, _) if lt_21_0_0 => false,
376+
(Arch::S390x, _) if major < 21 => false,
378377
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
379378
(Arch::X86_64, Os::Windows) if *target_env == Env::Gnu && *target_abi != Abi::Llvm => false,
380379
// Infinite recursion <https://github.com/llvm/llvm-project/issues/97981>
381380
(Arch::CSky, _) => false,
382-
(Arch::Hexagon, _) if lt_21_0_0 => false, // (fixed in llvm21)
381+
(Arch::Hexagon, _) if major < 21 => false, // (fixed in llvm21)
383382
(Arch::PowerPC | Arch::PowerPC64, _) => false,
384383
(Arch::Sparc | Arch::Sparc64, _) => false,
385384
(Arch::Wasm32 | Arch::Wasm64, _) => false,
@@ -393,7 +392,7 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
393392
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
394393
(Arch::Arm64EC, _) => false,
395394
// Selection bug <https://github.com/llvm/llvm-project/issues/96432> (fixed in LLVM 20.1.0)
396-
(Arch::Mips64 | Arch::Mips64r6, _) if lt_20_1_0 => false,
395+
(Arch::Mips64 | Arch::Mips64r6, _) if version < (20, 1, 0) => false,
397396
// Selection bug <https://github.com/llvm/llvm-project/issues/95471>. This issue is closed
398397
// but basic math still does not work.
399398
(Arch::Nvptx64, _) => false,
@@ -406,7 +405,7 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
406405
(Arch::Sparc, _) => false,
407406
// Stack alignment bug <https://github.com/llvm/llvm-project/issues/77401>. NB: tests may
408407
// not fail if our compiler-builtins is linked. (fixed in llvm21)
409-
(Arch::X86, _) if lt_21_0_0 => false,
408+
(Arch::X86, _) if major < 21 => false,
410409
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
411410
(Arch::X86_64, Os::Windows) if *target_env == Env::Gnu && *target_abi != Abi::Llvm => false,
412411
// There are no known problems on other platforms, so the only requirement is that symbols

0 commit comments

Comments
 (0)