[MLIR] Fix clang-tidy fixes for llvm-prefer-isa-or-dyn-cast-in-conditionals in AMDGPUToROCDL.cpp (NFC)
The cast can't fail, the `if` checks are spurious.
Thread Safety Analysis: Add more cast pointer-alias tests (#172638)
Add 2 tests for cast pointer aliases, with the cleanup pattern being a
real pattern that is considered to be used in the Linux kernel:
https://lore.kernel.org/all/aUGBff8Oko5O8EsP@elver.google.com/
This works today, but let's test it to make sure there are no
regressions.
NFC.
[lldb][ObjC][NFCI] Replace StringLexer with llvm::StringRef (#172466)
We had a dedicated `StringLexer` class that pretty much just replicates
the `llvm::StringRef` interface. This patch removes the `StringLexer` in
favour of just using `llvm::StringRef`. Much of the string parsing can
be cleaned up, but I tried to keep the changes a small as possible so
just kept the logic and replaced the APIs calls. The only awkward
side-effect of this is that we have to pass a `llvm::StringRef &`
around.
There were some gaps in the API, so added two helper methods to
consume/pop off characters from the front of the StringRef (maybe those
can be added to `llvm::StringRef` in the future).
The `StringLexer` also had a roll-back mechanism used in two places.
That can be handled by just saving a copy of the `StringRef`.
[AMDGPU][SIInsertWaitCnt] Optimize loadcnt insertion at function boundaries (#169647)
On GFX12+, GLOBAL_INV increments the loadcnt counter but does not write
results to any VGPRs. Previously, we unconditionally inserted
s_wait_loadcnt 0 at function returns even when the only pending loadcnt
was from GLOBAL_INV instructions.
This patch optimizes waitcnt insertion by skipping the loadcnt wait at
function boundaries when no VGPRs have pending loads. This is determined
by checking if any VGPR has a score greater than the lower bound for
LOAD_CNT - if not, the pending loadcnt must be from non-VGPR-writing
instructions like GLOBAL_INV.
The optimization is limited to GFX12+ targets where GLOBAL_INV exists
and uses the extended wait count instructions.
This is a follow-up optimization to PR #135340 which added tracking for
GLOBAL_INV in the waitcnt pass.
[Polly] Recalculate dependencies after import-jscop (#172640)
The new access functions may have different dependencies than the
original ones. Invalidate the dependency analysis after an jscop-import.
[AArch64][llvm-objdump] Fix arm64_32 symbolization (#171164)
llvm-objdump was missing "literal pool symbol address" comments for
arm64_32 stub disassembly. Fixed by adding 32-bit instruction support
(LDRWui, ADDWri, LDRWl) to AArch64ExternalSymbolizer and aarch64_32
architecture checks to MachODump.cpp symbolization code.
Fixes #49288
[AArch64][llvm-objdump] Add missing arm64_32 architecture checks (#171638)
Use the same code paths as arm64 since arm64_32 has the same instruction
encoding and register usage.
[SLSR] Allow implicit truncation for element size
Ideally we'd reject too large types in the IR verifier, but for now
we should follow the usual sext-or-trunc GEP semantics here.
[IR] Update `PHINode::removeIncomingValueIf()` to use the swap strategy like `PHINode::removeIncomingValue()`
As suggested in https://github.com/llvm/llvm-project/pull/171963, update
`PHINode::removeIncomingValueIf()` to use the swap strategy too.
[CGExprScalar] Allow implicit truncation for CharacterLiteral
The value is always stored as an unsigned number, even if the
char type is signed, so we have to allow truncation here.
[DA] Introduce OverflowSafeSignedAPInt to prevent potential overflow (#171991)
In Exact SIV and Exact RDIV tests, there are multiple `APInt` arithmetic
operations which can overflow. These overflows are currently not
checked, which may lead to incorrect analysis results. However, adding
overflow checks for each operation can clutter the code and make it
harder to read.
This patch introduces a new wrapper class `OverflowSafeSignedAPInt` that
encapsulates a `std::optional<APInt>` and provides arithmetic operations
with built-in overflow checking. If an arithmetic operation overflows,
the internal `std::optional<APInt>` is set to `std::nullopt`, indicating
an invalid result. Also, if any operand of an arithmetic operation is
invalid, the result will also be invalid. By using this wrapper class in
the Exact SIV and Exact RDIV tests, now overflows are handled properly
while keeping the readability of the code.
Fixes the test added in #171990.