[MC] Emit 'S' augmentation for .debug_frame signal frames (#246795)
.cfi_signal_frame is only encoded in .eh_frame CIEs ("zRS");
.debug_frame CIEs currently get no augmentation while GCC emits "S" for
these frames (comparison: https://godbolt.org/z/3bvxh7Pse).
Emit "S" for non-EH signal frames and include IsSignalFrame in the
non-EH CIEKey, otherwise a signal and normal frame with the same return
register can share a CIE.
Adds a small MC/ELF test checking the two CIE augmentations.
Co-authored-by: Evalyn Goemer <git at evalyngoemer.com>
Co-authored-by: Fangrui Song <i at maskray.me>
[DAG] Generalize sign-bit extraction in visitAND to low-bit masks (#248920)
Generalize (and (srl X, C), 1) to masks with B low bits set. Fold the
shift and mask to (srl X, BW - B) when C < BW - B and all bits from C
through the MSB are copies of the sign bit.
For masks wider than one bit, require a scalar SRL with a single use.
Preserve the existing one-bit fold for vectors and multi-use shifts.
Update code generation checks across several targets. The main benefit
is that some sdiv and srem cases need fewer instructions to compute
the bias.
[sanitizer] report libbacktrace errors on verbose mode (#243083)
Those errors could give clues why a backtrace is missing. Hence, log
them but only when verbose > 1.
Issue: https://github.com/llvm/llvm-project/issues/243075
[AMDGPU] Fold add into integer wmma accumulator (#248304)
Integer wmma and swmmac wrap on overflow when clamp is off, so adding X
to the result is the same as adding X to the accumulator. Fold the add
when the accumulator is zero or both are constants. Because wmma is
convergent, the call is only moved to the add when both are in the same
block.
```llvm
%d = call <8 x i32> @llvm.amdgcn.wmma.i32.16x16x16.iu8.v8i32.v2i32(i1 0, <2 x i32> %a, i1 0, <2 x i32> %b, <8 x i32> zeroinitializer, i1 0)
%r = add <8 x i32> %d, %x
-->
%r = call <8 x i32> @llvm.amdgcn.wmma.i32.16x16x16.iu8.v8i32.v2i32(i1 0, <2 x i32> %a, i1 0, <2 x i32> %b, <8 x i32> %x, i1 0)
```
[sanitizer] don't pass initial filename to libbacktrace (#243082)
Libbacktrace knows how to find the executable name for its supported
platforms. Passing an initial filename prevents this lookup phase.
Issue: https://github.com/llvm/llvm-project/issues/243075
[DAGCombiner] Don't treat bitcast+extract_subvector as a truncate on big-endian (#245146)
Fixes #244527
`(zext/aext (and (bitcast (extract_subvector vNi1, 0) to iK), cst))` was
folded into an AND on the wider bitcast, which assumes
`bitcast(extract_subvector(X, 0))` is `trunc(bitcast(X))`. That only
holds on little-endian: per LangRef a `<N x i1>` bitcast follows the
element order of the target, so on big-endian lane 0 is the most
significant bit and the masked low bits select the last K lanes. On
aarch64_be the reproducer read lanes 24..31 instead of 8..15, and mips
and s390x do the same.
Guards that branch in both folds with
`DAG.getDataLayout().isLittleEndian()` and leaves big-endian to the
generic lowering, which is already correct. The truncate branch is
untouched.
Test: `bitcast-extract-subvector-and-zext.ll` covers both folds for
[8 lines not shown]
[AArch64] Fix big-endian SVE truncation of fixed-length vectors (#246756)
On big-endian AArch64, lowering a fixed-length integer vector `trunc`
through SVE can keep the high half of each element. The generic
`BITCAST` reverses bytes when the element width changes, so `UZP1` can
select the wrong half.
Use `AArch64ISD::NVCAST` before each `UZP1` to preserve the register
layout and select the low half. The regression test reproduces the bug
on `main` with a plain `trunc` from `<8 x i64>` to `<8 x i8>`,
exercising all three narrowing steps.
I found this while testing the 32- and 64-lane mask optimization in
#246755 on big-endian SVE.
[NVPTX] Add support for lround and llround intrinsics for f16 and bf16 (#240078)
add support for lround and llround intrinsics for f16 and bf16 by
promoting them to f32.
fixes #239041
used claude for writing code comments
[sanitizer_common][lsan] Keep the original allocation alive when realloc fails (#222849)
CombinedAllocator::Reallocate() deallocated the original chunk even when
the replacement allocation failed, and __lsan::Reallocate() unregistered
the pointer before asking for that replacement. A failing realloc()
therefore released memory the caller still owned: a free hook fired for
a
live pointer, and a later malloc() handed the same chunk out again.
Return early in the allocator, and in LSan allocate the replacement
before releasing the original, the way ASan and HWASan already do it.
Going through __lsan::Allocate() also makes realloc() honor
allocator_may_return_null, and tracks realloc(NULL, 0) as the malloc(0)
it is rather than as a zero-sized allocation.
Assisted-by: Claude Opus 5
---------
Co-authored-by: Vitaly Buka <vitalybuka at google.com>
[Clang] Use the last macro prefix map for duplicate prefixes (#249124)
Use the last destination when multiple macro prefix maps have the same
source prefix. This makes repeated -ffile-prefix-map options consistent
with their debug and coverage mappings.
Fixes #157721
Assisted-by: OpenAI Codex
[mlir][affine] Load the memref dialect in affine-super-vectorize (#247728)
Since #243425, -affine-super-vectorize masks transfers on dynamic
memrefs with memref.dim, but the pass doesn't load the memref dialect.
If the input has no memref ops, it crashes:
```mlir
func.func @f(%src: memref<?xf32>, %dst: memref<64xf32>) {
affine.for %i = 0 to 64 {
%v = affine.load %src[%i] : memref<?xf32>
affine.store %v, %dst[%i] : memref<64xf32>
}
return
}
```
```
$ mlir-opt f.mlir -affine-super-vectorize=virtual-vector-size=8
LLVM ERROR: Building op `memref.dim` but it isn't known in this MLIRContext: the dialect may not be loaded or this operation hasn't been added by the dialect. See also https://mlir.llvm.org/getting_started/Faq/#registered-loaded-dependent-whats-up-with-dialects-management
```
[7 lines not shown]
[clang] Cover vectorize_width recovery with an undeclared width (#248809)
A hint like `vectorize_width(undeclared,)` has both an undeclared width
and a missing second argument. With the recovery from #246804, Clang
diagnoses both errors and resumes parsing at the following loop.
[msan] Enable -msan-with-comdat by default on ELF targets (#238678)
Place `msan.module_ctor` in a COMDAT section by default on ELF targets
(matching ASan). Without COMDAT deduplication, every translation unit
emits its own `msan.module_ctor` function and `.init_array` entry into
the linked binary. The old GNU gold bug (PR19002) that kept
`-msan-with-comdat` off by default was fixed in binutils 2.26, and ASan
and HWASan already place their module constructors in COMDAT by default.
This reduces `.text` size by ~0.05% on average. Related to
https://github.com/rust-lang/rust/issues/165040 (reducing MSan binary
size to offset the size overhead of fixing that issue).
Assisted-by: Gemini
[clang-repl] Load the HIP runtime from the detected ROCm installation (#246462)
This PR fixes #231783. It changes clang-repl to load the HIP
runtime(`libamdhip64.so`) from the ROCm installation that clang detects.
If no HIP installation is found, it loads the library by name.
The logic for loading CUDA runtime remains unchanged.
[GVN] Align MayAlias load handling between MDA and MemorySSA
A monotonic load with MayAlias is skipped in MDA, while it is
treated as a clobber in the MemorySSA path.
As a result, we synchronize the behavior by making MayAlias loads
go through the same checks as NoAlias loads.
Assisted-by: Claude # Test
[GVN][NFC] Add tests for MayAlias atomic loads with MemorySSA
Also run PRE/atomic.ll with gvn<memoryssa>, and add tests where a
monotonic or acquire load that may alias the loaded location sits
between two loads of the same pointer.
Assisted-by: Claude # Test
[KnownFPClass] Add `KnownFPClass::fsub(CLHS, y)` to rule out subnormal results (#245855)
Add KnownFPClass::fsub(CLHS, y) to rule out subnormal results when the
CLHS is normal and abs(CLHS) > 2^(expMin + precision - 1). Use this
overload in ValueTracking. Share the constant refinement logic with
KnownFPClass::fadd(x, CRHS).
Follow-up on #237966, which added KnownFPClass::fadd(x, CRHS) to fix
#234364.
[libc++] Implement LWG4397: Improve `span(R&& r)` (#248408)
Note that currently Clang has not implemented P2280R4 in pre-C++23 modes
(see also https://llvm.org/PR129646), so the _Mandates_ is not available
with Clang in C++20 mode.
[NVPTX] promote lrint and llrint for bf16 and expand for f16 (#242967)
fixes `(l)lrint` crash on f16 and bf16.
- f16 is now Expand, FRINT is legal on f16 everywhere.
- bf16 is promoted to f32 below SM90. On SM90+ it stays Expand, since
the bf16 rounding and integer conversions are native there.
- also adds LRINT/LLRINT to the `PromoteNode` opcodes that take the
promoted type from operand 0, so the float input is promoted and not the
integer result.
- tests cover lrint (i32/i64) and llrint (i64) for f16 and bf16.
from #240078
claude helped me with the code comment and correctness.
[NFC][sanitizer_common] Remove unused RTSanitizerCommonNoLibc (#235573)
The libc-independent sanitizer_common split and
`RTSanitizerCommonNoLibc`
were originally introduced for `clang_rt.dfsan-libc` (5cbab07d02a3) to
support instrumenting `libc.so` without circular libc dependencies (as
confirmed by pcc).
All consumers of `RTSanitizerCommonNoLibc` have since been removed:
- DFSan `clang_rt.dfsan-libc` build (b6a604aea5a6)
- SafeStack runtime (f5ce42c040c5)
- GWP-ASan/Scudo options parser test dependencies (6a42cbf6d211)
All remaining sanitizer runtimes link `RTSanitizerCommonLibc`. Remove
`RTSanitizerCommonNoLibc`, `sanitizer_common_nolibc.cpp`, and the
`Sanitizer-*-Test-Nolibc` test.
Assisted-by: Gemini