[Sparc][MC] Don't report "unexpected token" after an operand error (#245208)
When an operand failed to parse, parseInstruction always reported
"unexpected token", even when the operand parser had already reported a
more specific error. So most operand errors were followed by a second,
less useful one, e.g.:
```
error: invalid register name
error: unexpected token
```
Make the operand parsers follow the ParseStatus convention, where
Failure means an error was reported and NoMatch means nothing was
consumed and no error was reported, and only report "unexpected token"
for NoMatch:
- parseSparcAsmOperand returns NoMatch for tokens it does not handle,
and Failure only after an error.
[19 lines not shown]
[msan][test] Show masked_store with zero mask incorrectly sets origin (#246161)
handleMaskedStore() unconditionally sets the origin, even in cases where
the mask ends up being zero (as evaluated at compile-time or runtime)
i.e., no bytes were stored. This PR adds a regression test case and a
TODO in the MSan instrumentation pass.
---------
Co-authored-by: Vitaly Buka <vitalybuka at google.com>
[ASan][test] Use %run in dlopen-mixed-c-cxx.c (#246215)
The test ran its binary directly, so it failed on targets that need an
emulator or a remote device.
Assisted-by: Claude Code
[analyzer][NFC] Memoize inferred symbol ranges per ProgramState
The inferred range of a symbol is a pure function of the ProgramState, yet
simplifying an SVal queries the range of every sub-expression again and again
against the same state. Memoize the ranges for the most recently queried
state in RangeConstraintManager (a DenseMap<SymbolRef, RangeSet> plus the
state it belongs to; it is cleared when a different state is queried).
SymbolicRangeInferrer takes the cache as an optional, nullable pointer; the
static inferRange() call sites pass none (a stack-local cache there never got
a lookup: 0 hits over 76406 instances on the corpus below).
Why this is safe: the cache holds a ProgramStateRef, so the state stays alive
and its address cannot be recycled for a different state while it is the
cache key. To make that hold at destruction time, ConstraintMgr is now
declared last in ProgramStateManager and is destroyed first, while the state
set, the allocator and the GDM contexts are still alive. ~ProgramStateManager
is declared out of line because the defaulted one needs the complete types
used by the members. Behavior is unchanged: the diagnostics are
byte-identical on every input below, and check-clang-analysis passes
[72 lines not shown]
[mlir][SPIR-V] Support Centroid and NonUniform decorations (#245443)
Adds serialization and deserialization support for the `Centroid` and
`NonUniform` SPIR-V unit decorations (both enums are already defined in
`SPIRVBase.td`).
Assisted by Google Antigravity Gemini 4.0 Neon Model
[mlir][SPIR-V] Add spirv.GL.Refract op (#245349)
Adds the `spirv.GL.Refract` op corresponding to `GLSL.std.450` extended
instruction `Refract` (opcode 72).
Per the `GLSL.std.450` specification:
- `I`, `N`, and the result must all have the same floating-point scalar
or vector type.
- `eta` must be a floating-point scalar.
Serialization and deserialization are automatically generated via
`SPIRV_GLOp`.
Assisted with Google Antigravity Gemini 4 Neon model
[mlir][SPIR-V] Add spirv.ArrayLength op (#245462)
This PR adds support for SPIR-V's `OpArrayLength` (opcode 68).
What changed:
Op definition & serialization: Registered `OpArrayLength` in
`SPIRVBase.td` and defined `SPIRV_ArrayLengthOp` in `SPIRVMemoryOps.td`
with binary serialization and deserialization.
Verification: Implemented `ArrayLengthOp::verify()` to ensure the
structure operand points to a struct ending in a RuntimeArrayType, and
that array_member correctly indexes that final member.
Assisted with Google Antigravity Gemini 4 Neon model
[lld][MachO] Avoid redundant work in Writer::scanRelocations()
During relocation scanning, `Writer::scanRelocations()` looks up
`target->getRelocAttrs(r.type)` up to three times per symbol relocation
(in `scanRelocations()`, `validateSymbolRelocation()`, and
`prepareSymbolRelocation()`), tests `r.referent` twice for symbol
referents, and makes an out-of-line call to `validateSymbolRelocation()`
on every symbol relocation even though it only rejects two rare
thread-local-variable cases.
Move `validateSymbolRelocation()` (whose only caller is
`Writer::scanRelocations()`) into `Writer.cpp`, split the rare TLV
validation logic into a `LLVM_ATTRIBUTE_NOINLINE` helper, and mark
`DylibSymbol` `final` so `dysym->isTlv()` avoids a virtual call on the
fast path. Fetch `RelocAttrs` once per relocation, pass it to
`validateSymbolRelocation()` and `prepareSymbolRelocation()`, hoist
loop-invariant `target->relocAttrs` and `config->emitChainedFixups`, and
dispatch on `r.referent` once for non-subtractor relocations.
[sanitizer] Ensure suppression files' buffer is null terminated. (#236826)
Function ReadFileToBuffer does not terminate string 'file_contents'.
SuppressionContext::Parse internal_strcspn expects a null-terminated
string.
The issue was found through static analysis.
[llvm] Remove unused forward declarations (NFC) (#246828)
This patch removes unused forward declarations of classes and structs
across llvm/ that are not referenced in the same file.
Assisted-by: Antigravity
[tsan] Intercept C11 mtx_* functions on glibc (#239670)
glibc implements the C11 mutex functions with its internal pthread_mutex
functions, so TSan doesn't see C11 mutexes being locked and unlocked and
reports false data races on the data they protect (#199585).
Intercept mtx_init, mtx_destroy, mtx_lock, mtx_trylock, mtx_timedlock
and mtx_unlock, forwarding to the real functions and doing what the
pthread_mutex interceptors do. mtx_recursive makes the mutex reentrant.
To avoid hardcoding C11 constants, forward mtx_plain, mtx_recursive and
mtx_timed enum values to sanitizer_platform_limits_posix.
Enable c11_mtx.c for TSan on glibc.
Assisted-by: Claude
[SanitizerCoverage] Use InstrumentationIRBuilder for gated callbacks (#244789)
Gated callback paths in InjectTraceForSwitch(), InjectTraceForCmp(), and
InjectCoverageAtBlock() used a plain IRBuilder instead of
InstrumentationIRBuilder, and InjectCoverageAtBlock() did not propagate
EntryLoc. When the split point has no debug location in a function with
a DISubprogram, the inserted runtime call lacked a !dbg location.
Assisted-by: Gemini
[LV] Expand runtime checks in SafeUDivMode. (#246863)
The SCEV predicate checks, memory runtime checks and alias-mask checks
are executed unconditionally before the vector loop, but may contain a
udiv that the original loop only evaluates in a predicated block, e.g.
for an address computed from a udiv under a condition that is never
true. Expanding it unguarded divides by zero or poison.
Expand them in SafeUDivMode, matching the expansion of
VPExpandSCEVRecipes. canExpandInIR no longer bails out in SafeUDivMode,
as it only accepts expressions that cannot cause UB, so hoisting of
memory checks out of outer loops is unchanged.
PR: https://github.com/llvm/llvm-project/pull/246863
[NFC][sanitizer_common] Flip the AIX build guard to positive (#246155)
https://github.com/llvm/llvm-project/pull/138606 added build guard
`SI_NOT_AIX`. It's a negative flag and easy to cause confusing on
double-negative.
This PR flips the flag to positive and updates all of the usages.
Assisted-by: Gemini
[Clang][CodeGen] Plumb SourceLocation to virtual dtor and thunk calls (#245522)
Forward the call or delete expression location through
EmitCXXDestructorCall
and EmitVirtualDestructorCall, and pass the method location from
getOrCreateVirtualFunctionPointerThunk to EmitCall.
Previously, these paths passed an empty SourceLocation to EmitCall,
causing
call-site diagnostics such as target-feature errors on virtual
destructors
(both Itanium and Microsoft ABIs) to be emitted without a file or line
number. This also prepares for passing call-site locations to UBSan kCFI
diagnostics in follow-up changes.
Assisted-by: Gemini
[CodeGen][MachineOutliner] Do not outline nomerge instructions (#245435)
Instructions carrying MachineInstr::NoMerge must retain distinct call or
trap addresses so crash reports and debuggers can attribute faults to
specific sites. Classify NoMerge instructions as Illegal in
TargetInstrInfo::getOutliningType so MachineOutliner does not merge them
into shared outlined functions.
Assisted-by: Gemini
[Attributor] Use call site values when the callee returns an argument
AAPotentialValuesCallSiteReturned takes the interprocedural values of a call
from the interprocedural return values of the callee. If the callee returns one
of its arguments, these values contain the arguments of all call sites, so each
call result also gets the values passed at all other call sites. This is not
necessary. If the callee has many call sites and the call results are passed to
other calls, the value sets also become very large.
If the callee returns only its arguments and constants, we just need to
translate these values to the call site for the interprocedural scope.
This PR was assisted by AI but I reviewed all the changes.
[test][SanitizerCoverage] Precommit gated-callbacks debug info test (#245528)
Add a gated-callbacks RUN line to missing_dbg.ll showing that gated
runtime calls currently drop !dbg locations in functions with debug
info.
Assisted-by: Gemini