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.
[clang][ssaf] Add SummaryName handle type (#172474)
This will be the type to connect different components, such as:
- to refer to the data of some analysis
- to name a builder to construct an analysis
- to name an analysis to build from a command-line flag
- to bind an analysis result to a TU summary, which will house multiple such analysis results
I don't expect to construct one of these too often. We would need one of
these when actually building an analysis, or when an analysis wants to
commit its results to the TU Summary.
[DTLTO] Remove temporary files on abnormal exit, e.g. CTRL-C (#172280)
Ensure that DTLTO temporary files are removed when the
link exits due to CTRL-C or comparable interrupt events.
Fixes: https://github.com/llvm/llvm-project/issues/171778
[AArch64][SME] Add pass remarks to the MachineSMEABIPass (#170277)
This patch implements SME ABI pass remarks for when:
* a lazy ZA save is set up
* a full/agnostic ZA save is set up
* a ZT0 spill is emitted
These remarks can be enabled with `--pass-remarks-analysis=sme` (like
the current SME remarks).
The remarks work by noting where the save/spill was emitted, then
pointing out calls later in the function that require the save. The
remarks stop at the first call found along any path.
For example:
```
7: void merge_paths(bool a) __arm_inout("za") {
[14 lines not shown]
Reapply "[clang][analyzer] Format macro expansions" (#172479)
This reverts commit ed5589b0dcec40e25675812a330e171ed0587644.
We missed a link dependency so we had to revert this change.
Now that is fixed, let's see if this one sticks.