Skip to content

Commit d9c6c1f

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 a0af29d commit d9c6c1f

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -335,26 +335,25 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
335335
let target_abi = sess.target.options.abi.as_ref();
336336
let target_pointer_width = sess.target.pointer_width;
337337
let version = get_version();
338-
let lt_20_1_0 = version < (20, 1, 0);
339-
let lt_20_1_1 = version < (20, 1, 1);
340-
let lt_21_0_0 = version < (21, 0, 0);
338+
let (major, _, _) = version;
341339

342340
cfg.has_reliable_f16 = match (target_arch, target_os) {
343341
// LLVM crash without neon <https://github.com/llvm/llvm-project/issues/129394> (fixed in LLVM 20.1.1)
344342
("aarch64", _)
345-
if !cfg.target_features.iter().any(|f| f.as_str() == "neon") && lt_20_1_1 =>
343+
if !cfg.target_features.iter().any(|f| f.as_str() == "neon")
344+
&& version < (20, 1, 1) =>
346345
{
347346
false
348347
}
349348
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
350349
("arm64ec", _) => false,
351350
// Selection failure <https://github.com/llvm/llvm-project/issues/50374> (fixed in llvm21)
352-
("s390x", _) if lt_21_0_0 => false,
351+
("s390x", _) if major < 21 => false,
353352
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
354353
("x86_64", "windows") if target_env == "gnu" && target_abi != "llvm" => false,
355354
// Infinite recursion <https://github.com/llvm/llvm-project/issues/97981>
356355
("csky", _) => false,
357-
("hexagon", _) if lt_21_0_0 => false, // (fixed in llvm21)
356+
("hexagon", _) if major < 21 => false, // (fixed in llvm21)
358357
("powerpc" | "powerpc64", _) => false,
359358
("sparc" | "sparc64", _) => false,
360359
("wasm32" | "wasm64", _) => false,
@@ -367,8 +366,6 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
367366
cfg.has_reliable_f128 = match (target_arch, target_os) {
368367
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
369368
("arm64ec", _) => false,
370-
// Selection bug <https://github.com/llvm/llvm-project/issues/96432> (fixed in llvm20)
371-
("mips64" | "mips64r6", _) if lt_20_1_0 => false,
372369
// Selection bug <https://github.com/llvm/llvm-project/issues/95471>. This issue is closed
373370
// but basic math still does not work.
374371
("nvptx64", _) => false,
@@ -381,7 +378,7 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
381378
("sparc", _) => false,
382379
// Stack alignment bug <https://github.com/llvm/llvm-project/issues/77401>. NB: tests may
383380
// not fail if our compiler-builtins is linked. (fixed in llvm21)
384-
("x86", _) if lt_21_0_0 => false,
381+
("x86", _) if major < 21 => false,
385382
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
386383
("x86_64", "windows") if target_env == "gnu" && target_abi != "llvm" => false,
387384
// There are no known problems on other platforms, so the only requirement is that symbols

0 commit comments

Comments
 (0)