about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-07-27 03:20:34 +0000
committerbors <bors@rust-lang.org>2025-07-27 03:20:34 +0000
commit052114f0c5e8d49f62f8caba364b07017310ab09 (patch)
treea7a0d10c478dea6c11b264fc84e27ce02fbebade /compiler/rustc_codegen_llvm/src
parent283a0746a244a88503fed61844f44df925ccdbb6 (diff)
parent8aa3d41b8527f9f78e0f2459b50a6e13aea35144 (diff)
downloadrust-052114f0c5e8d49f62f8caba364b07017310ab09.tar.gz
rust-052114f0c5e8d49f62f8caba364b07017310ab09.zip
Auto merge of #144526 - jhpratt:rollup-1x1tyvn, r=jhpratt
Rollup of 13 pull requests

Successful merges:

 - rust-lang/rust#141840 (If `HOME` is empty, use the fallback instead)
 - rust-lang/rust#144359 (add codegen test for variadics)
 - rust-lang/rust#144379 (test using multiple c-variadic ABIs in the same program)
 - rust-lang/rust#144383 (disable cfg.has_reliable_f128 on amdgcn)
 - rust-lang/rust#144409 (Stop compilation early if macro expansion failed)
 - rust-lang/rust#144422 (library/windows_targets: Fix macro expansion error in 'link' macro)
 - rust-lang/rust#144429 (Enable outline-atomics for aarch64-unknown-linux-musl)
 - rust-lang/rust#144430 (tests: aarch64-outline-atomics: Remove hardcoded target)
 - rust-lang/rust#144445 (Fix `./x check bootstrap` (again))
 - rust-lang/rust#144453 (canonicalize build root in `tests/run-make/linker-warning`)
 - rust-lang/rust#144464 (Only run bootstrap tests in `x test` on CI)
 - rust-lang/rust#144470 (clif: Don't set the `compiler-builtins-no-f16-f128` feature)
 - rust-lang/rust#144480 (Revert "coverage: Enlarge empty spans during MIR instrumentation, not codegen")

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
-rw-r--r--compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/spans.rs28
-rw-r--r--compiler/rustc_codegen_llvm/src/llvm_util.rs2
2 files changed, 26 insertions, 4 deletions
diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/spans.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/spans.rs
index 574463be7ff..39a59560c9d 100644
--- a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/spans.rs
+++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/spans.rs
@@ -39,10 +39,7 @@ impl Coords {
 /// or other expansions), and if it does happen then skipping a span or function is
 /// better than an ICE or `llvm-cov` failure that the user might have no way to avoid.
 pub(crate) fn make_coords(source_map: &SourceMap, file: &SourceFile, span: Span) -> Option<Coords> {
-    if span.is_empty() {
-        debug_assert!(false, "can't make coords from empty span: {span:?}");
-        return None;
-    }
+    let span = ensure_non_empty_span(source_map, span)?;
 
     let lo = span.lo();
     let hi = span.hi();
@@ -73,6 +70,29 @@ pub(crate) fn make_coords(source_map: &SourceMap, file: &SourceFile, span: Span)
     })
 }
 
+fn ensure_non_empty_span(source_map: &SourceMap, span: Span) -> Option<Span> {
+    if !span.is_empty() {
+        return Some(span);
+    }
+
+    // The span is empty, so try to enlarge it to cover an adjacent '{' or '}'.
+    source_map
+        .span_to_source(span, |src, start, end| try {
+            // Adjusting span endpoints by `BytePos(1)` is normally a bug,
+            // but in this case we have specifically checked that the character
+            // we're skipping over is one of two specific ASCII characters, so
+            // adjusting by exactly 1 byte is correct.
+            if src.as_bytes().get(end).copied() == Some(b'{') {
+                Some(span.with_hi(span.hi() + BytePos(1)))
+            } else if start > 0 && src.as_bytes()[start - 1] == b'}' {
+                Some(span.with_lo(span.lo() - BytePos(1)))
+            } else {
+                None
+            }
+        })
+        .ok()?
+}
+
 /// If `llvm-cov` sees a source region that is improperly ordered (end < start),
 /// it will immediately exit with a fatal error. To prevent that from happening,
 /// discard regions that are improperly ordered, or might be interpreted in a
diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs
index 8edbae115bf..53899da183a 100644
--- a/compiler/rustc_codegen_llvm/src/llvm_util.rs
+++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs
@@ -405,6 +405,8 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
         ("mips64" | "mips64r6", _) => false,
         // Selection bug <https://github.com/llvm/llvm-project/issues/95471>
         ("nvptx64", _) => false,
+        // Unsupported https://github.com/llvm/llvm-project/issues/121122
+        ("amdgpu", _) => false,
         // ABI bugs <https://github.com/rust-lang/rust/issues/125109> et al. (full
         // list at <https://github.com/rust-lang/rust/issues/116909>)
         ("powerpc" | "powerpc64", _) => false,