Skip to content

Commit 41dbdbb

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.1. 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 and all "fixed in LLVM 20" cases can be safely removed.
1 parent 2f4dfc7 commit 41dbdbb

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -334,26 +334,18 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
334334
let target_env = sess.target.options.env.as_ref();
335335
let target_abi = sess.target.options.abi.as_ref();
336336
let target_pointer_width = sess.target.pointer_width;
337-
let version = get_version();
338-
let lt_20_1_1 = version < (20, 1, 1);
339-
let lt_21_0_0 = version < (21, 0, 0);
337+
let (major, _, _) = get_version();
340338

341339
cfg.has_reliable_f16 = match (target_arch, target_os) {
342-
// LLVM crash without neon <https://github.com/llvm/llvm-project/issues/129394> (fixed in llvm20)
343-
("aarch64", _)
344-
if !cfg.target_features.iter().any(|f| f.as_str() == "neon") && lt_20_1_1 =>
345-
{
346-
false
347-
}
348340
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
349341
("arm64ec", _) => false,
350342
// Selection failure <https://github.com/llvm/llvm-project/issues/50374> (fixed in llvm21)
351-
("s390x", _) if lt_21_0_0 => false,
343+
("s390x", _) if major < 21 => false,
352344
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
353345
("x86_64", "windows") if target_env == "gnu" && target_abi != "llvm" => false,
354346
// Infinite recursion <https://github.com/llvm/llvm-project/issues/97981>
355347
("csky", _) => false,
356-
("hexagon", _) if lt_21_0_0 => false, // (fixed in llvm21)
348+
("hexagon", _) if major < 21 => false, // (fixed in llvm21)
357349
("powerpc" | "powerpc64", _) => false,
358350
("sparc" | "sparc64", _) => false,
359351
("wasm32" | "wasm64", _) => false,
@@ -366,8 +358,6 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
366358
cfg.has_reliable_f128 = match (target_arch, target_os) {
367359
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
368360
("arm64ec", _) => false,
369-
// Selection bug <https://github.com/llvm/llvm-project/issues/96432> (fixed in llvm20)
370-
("mips64" | "mips64r6", _) if lt_20_1_1 => false,
371361
// Selection bug <https://github.com/llvm/llvm-project/issues/95471>. This issue is closed
372362
// but basic math still does not work.
373363
("nvptx64", _) => false,
@@ -380,7 +370,7 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
380370
("sparc", _) => false,
381371
// Stack alignment bug <https://github.com/llvm/llvm-project/issues/77401>. NB: tests may
382372
// not fail if our compiler-builtins is linked. (fixed in llvm21)
383-
("x86", _) if lt_21_0_0 => false,
373+
("x86", _) if major < 21 => false,
384374
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
385375
("x86_64", "windows") if target_env == "gnu" && target_abi != "llvm" => false,
386376
// There are no known problems on other platforms, so the only requirement is that symbols

0 commit comments

Comments
 (0)