[Remarks] Reject remarks of type Unknown in the bitstream parser (#242617)
The bitstream remark parser only rejected type values above
`Type::Last`, so a record with type 0, `Type::Unknown`, parsed as a
valid remark. Writing such a remark as YAML reaches
`llvm_unreachable("Unknown remark type")` in `YAMLRemarkSerializer.cpp`,
which is how `llvm-remarkutil bitstream2yaml` crashes on a container
with a zeroed type field. The YAML parser already rejects a remark
without a type.
Reject type 0 with the existing "Unknown remark type." error. The new
test serializes a remark without a type and expects that error.
Assisted-by: Claude Code (Claude Fable 5.2)
[Mips] Report tail call support only where the backend makes tail calls (#241817)
The MIPS backend makes tail calls only with -mips-tail-calls, which is
off by default, and never in MIPS16 code, and a call marked `musttail`
that it can't make is a fatal error. `MipsTTIImpl` doesn't override
`supportsTailCalls`, though, so it reports tail calls as supported, and
CoroSplit marks the resume call of every symmetric transfer `musttail`.
Any C++20 coroutine that resumes another one by symmetric transfer, as
from an `await_suspend` that returns a `coroutine_handle`, then fails to
compile for every MIPS ABI, at every optimization level:
```
fatal error: error in backend: failed to perform tail call elimination on a call site marked musttail
```
#198943 closed #47971, an earlier report of this, by making the resume
functions use the C calling convention, but the backend refuses every
tail call without -mips-tail-calls.
[6 lines not shown]
[mlir][SPIR-V] Add ComplexToSPIRV lowering for complex.pow (#242263)
Decomposes complex.pow using its polar-form decomposition into the real
and imaginary components, following the same pattern as the other
transcendental complex ops in this file
[SCCP] Only invalidate calls of a function when its return value is reset (#241671)
Fixes #241244.
When FunctionSpecializer resets the lattice of a function's return
value, SCCPInstVisitor::invalidate added every user of the function to
the invalidation list. That includes uses that only pass the function's
address, like `call @g(ptr @k)`. Nothing solves such a call again, so
its result stayed undef and IPSCCP folded it to undef.
Only direct calls of the function whose signature matches depend on its
return value, so invalidate now walks only those. The walk is separate
from the one for ordinary values.
[RISCV][P-ext] Custom lower v8i8/v4i16 MUL on RV64. NFC (#242390)
Lower RV64 `v8i8`/`v4i16` multiplication through the existing
multiply-parts nodes and `PPAIRE`, extending the lowering used for
`v8i8` multiply-high operations. This replaces the nested machine
instructions in the TableGen patterns.
[llubi][NFC] Extract arithmetic and vector intrinsic helpers (#242610)
This PR factors division/remainder, vector reductions, and trailing-zero
element counting into dedicated helpers to make them reusable for later
VP implementation.
Extracted from #229351.
[Remarks] Return the error when the bitstream parser cannot enter a block
`BitstreamBlockParserHelperBase::enterBlock` tested the `Error` from `BitstreamCursor::EnterSubBlock` as a boolean and never consumed it. A container that ends right after a block header makes `EnterSubBlock` fail, and a build with `LLVM_ENABLE_ABI_BREAKING_CHECKS` then aborts with "Program aborted due to an unhandled Error" instead of reporting a parse error.
`enterBlock` now returns the error from `EnterSubBlock`, as the other bitstream readers do. The new test cuts a container written by the serializer after every 32-bit word and expects each prefix to fail. Without the fix it aborts in a build with ABI-breaking checks.
Assisted-by: Claude Code (Claude Fable 5.2)
[InstCombine] Fix miscompile in foldCmpLoadFromIndexedGlobal (#242608)
The index check `i & 8` to delay checking for out-of-bounds (for the bit
vector) indices causes miscompiles when a global larger than 64 elements have
interesting elements between e.g. indices 65 and the next time the condition is
checked, which is 73.
The guard was also slightly incorrect according to its documentation: it'd need
to be `i & 7` instead of `i & 8`.
It was also unnecessary: each iteration does constant evaluation and updates a
state machine represented as 6 variables. 5 integer checks at the end of such a
loop does not make it any more slower than it already is, and in the worst case
causes 7 extra constant evaluations and state machine updates before bailing
out.
[Remarks] Return the error when the bitstream parser cannot enter a block
`BitstreamBlockParserHelperBase::enterBlock` tested the `Error` from `BitstreamCursor::EnterSubBlock` as a boolean and never consumed it. A container that ends right after a block header makes `EnterSubBlock` fail, and a build with `LLVM_ENABLE_ABI_BREAKING_CHECKS` then aborts with "Program aborted due to an unhandled Error" instead of reporting a parse error.
`parseBlock` now calls `EnterSubBlock` itself and returns its error, as the other bitstream readers do. That leaves `enterBlock` without a job, so it is gone. The new test cuts a container written by the serializer after every 32-bit word and expects each prefix to fail. Without the fix it aborts in a build with ABI-breaking checks.
Assisted-by: Claude Code (Claude Fable 5.2)
[Remarks] Reject remarks of type Unknown in the bitstream parser
The bitstream remark parser only rejected type values above `Type::Last`, so a record with type 0, `Type::Unknown`, parsed as a valid remark. Writing such a remark as YAML reaches `llvm_unreachable("Unknown remark type")` in `YAMLRemarkSerializer.cpp`, which is how `llvm-remarkutil bitstream2yaml` crashes on a container with a zeroed type field. The YAML parser already rejects a remark without a type.
Reject type 0 with the existing "Unknown remark type." error. The new test serializes a remark without a type and expects that error.
Assisted-by: Claude Code (Claude Fable 5.2)
Verifier: Look up the AMDGPU metadata kinds once (#242573)
visitInstruction looked up two AMDGPU metadata kinds by name for every
instruction. Look up their IDs when constructing the Verifier.
O3 instructions in opt:
consumer-typeset z08.bc -0.34%, kimwitu++ k.bc -0.22%, sqlite3 -0.15%.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
Verifier: Check each metadata attachment of an instruction once (#242574)
visitInstruction looked up about 30 metadata kinds for every
instruction, followed by another getAllMetadata call. Collect the set
once and switch over the kinds.
instructions in opt: consumer-typeset z08.bc -0.94%,
kimwitu++ k.bc -0.64%, sqlite3 -0.43%, SPASS cnf.bc -0.09%.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
AArch64: Migrate to LastSubtargetCache in getSubtargetImpl (#242555)
These already reused the last subtarget for functions with the same
function attribute set. Use LastSubtargetCache to additionally filter
to the subtarget relevant attributes and work towards all targets
using a common pattern.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>