[SVE ACLE] Add svcount support to llvm.aarch64.sve.psel intrinsic. (#217360)
PSEL has genuine support for predicate-as-counter, so it seems fair for
its equivalent intrinsic to have matching support rather than indirect
support using the svbool variant.
[ConstraintElim] Derive facts for negative-step post-decrement cmps. (#218437)
Update addInfoForInductions to also add facts for negative step
inductions when comparing a post-inc induction.
The negative step support currently requires a step of -1, so the only
difference is the predicate of the precondition: for post-inc compares,
we exit at PN == B + 1, so strict predicates (B < StartValue) is used.
Helps to simplify a number of branches end-to-end in real world
workloads:
https://github.com/dtcxzyw/llvm-opt-benchmark-nightly/pull/1025.
Note that there is one case where we now fail to runtime-unroll, as the
removed branch pessimizes SCEV, but I think this is a pre-existing
issue, and the vast majority of changes are improvements.
Alive2 Proofs: https://alive2.llvm.org/ce/z/LbJYNA
PR: https://github.com/llvm/llvm-project/pull/218437
[Lifetime Safety] Normalize call arguments in AnyCall (#217838)
`AnyCall::arguments()` now returns a normalized argument list.
For instance member calls, the implicit object argument is included as
argument 0. For static `operator()` calls, the syntactic object operand
is excluded so the result matches the actual callable parameters.
LifetimeSafety now uses this normalized `AnyCall` argument list through
a small `FunctionCallInfo` helper, avoiding duplicated call argument
setup while keeping argument normalization in `AnyCall`.
Tests were added for:
- ordinary member calls with implicit object arguments
- non-static `operator()` calls where the object is already present
- static `operator()` calls where the object operand should be excluded
Follow-up to PR #206337
[3 lines not shown]
[clang-tools-extra] Unify python shebangs (#187287)
As per PEP-0394[1], there is no real concensus over what binary names
Python has, specifically 'python' could be Python 3, Python 2, or not
exist.
However, everyone has a python3 interpreter and the scripts are all
written for Python 3. Unify the shebangs so that the ~50% of shebangs
that use python now use python3.
[1] https://peps.python.org/pep-0394/
[mlir:doc] Clarify requirements on `RewritePatterns`. (#218351)
This PR clarifies and extends the documentation of what
`RewritePattern`s and folders are allowed to do. The most noteworthy
addition is the requirement that they must produce verifiable IR. While
this is enforced by `MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS`, it has
not been mentioned in the markdown docs yet. The other changes are
clarifications on edge cases that I have seen people misunderstand or
overlook. The change also adds a note to the build flag that enables the
API checks.
---------
Signed-off-by: Ingo Müller <ingomueller at google.com>
[analyzer] Implement potential underflow warnings (#216077)
The `security.ArrayBound` checker is able to report potential
out-of-bounds access when it detects that the accessed offset is tainted
(potentially attacker-controlled).
However, until now this only reported cases where _overflow_ was
possible with the tainted offset. (This is probably an accidental
oversight -- in the old implementation it was easy to forget adding a
second check that would report the "potential underflow with tainted
offset" case.)
This commit corrects this oversight and ensures that potential underflow
with a tainted offset is also correctly reported.
Co-authored-by: Balázs Benics <benicsbalazs at gmail.com>
[ORC] Use a weak recordAddr in runSymbolIfExists (#218591)
COFFPlatform::runSymbolIfExists resolved the symbol as required, then
swallowed the resulting SymbolsNotFound error. Use a weakly-referenced
recordAddr and test the address instead. This was the last non-test
caller of lookupAndRecordAddrs.
[libc++] Remove _LIBCPP_SHORT_WCHAR (#207562)
We can just check for `sizeof(wchar_t)` in most places instead. The only
place that seems problematic is `test_macros.h`, where we can use
`__SIZEOF_WCHAR_T__` instead.
[libc++] Optimize vector::erase (#213916)
This optimization is for trivially relocatable types. Instead of move
assigning the tail and then destroying the last N elements, we now
destroy the elements that are erased and then relocate the tail forward.
[NFC][analyzer] Remove class 'NodeBuilderContext' (#218442)
The class `NodeBuilderContext` was heavily distorted during the ad hoc
development of the analyzer: it was not actually that useful for
building nodes (it could have been replaced by a single pointer to the
`CoreEngine`), but it gained a second unrelated role that it was
involved in the only way to query the current `CFGBlock`. This class had
no actual advantage, but until the start of this year it was widely used
in low quality parts of the engine code.
After dozens of cleanup commits I was finally able to remove
`NodeBuilder` in 3a8697fab84c8d61e7fc4370c19bdd5023391716, so now I can
remove `NodeBuilderContext` in this commit.
[lldb] Evaluate DW_OP_mod with unsigned arithmetic (#218383)
LLDB currently passes the signed `Scalar` values produced by
`DW_OP_consts`
directly to `Scalar::operator%`. As a result, the issue expression
evaluates
`-1 % 2` as signed remainder `-1` instead of interpreting the all-one
address-sized value modulo 2 as `1`.
Make local copies of the `DW_OP_mod` dividend and divisor unsigned
before
applying the existing modulo operator. The change is contained entirely
in
the opcode evaluator and does not alter the global `Scalar`
implementation.
Update the `DW_OP_mod` unit test with the issue reproducer.
Tests:
[8 lines not shown]
[Clang][docs] Tweaks entries for recent DRs (#189187)
1. According to WG21 N5031, P3868R1 is also a DR.
2. Consistently add one space between the link and `(`.
3. Show the "Yes" status in a green cell (`class="full"`).
[LoopUtils] Return 0 for estimated zero trip count loops. (#217330)
getLoopEstimatedTripCount previously returned std::nullopt for loops
with estimated tip counts of zero. This was historically due to some
callers expecting trip counts > 0.
After auditing all callers, it looks like only one call in LoopVectorize
cannot handle zero trip counts (would lead to divide by 0). Updating the
code there to explicitly check for 0 allows us to update
getEstimatedTripCount to return 0 instead of std::nullopt.
This allows us to properly preserve branch weights in the remainder
loops when vectorizing the loop, for cases where the remainder does not
execute per the estimate via updateLoopMetadataAndProfileInfo.
This fixes ~120 prof-check failures in the LoopVectorizer tests.
PR: https://github.com/llvm/llvm-project/pull/217330
[Clang] Fix C++26 fold expression normalization of PackIndexingExpr (#218577)
It turns out that PackIndexingExpr doesn't create any PackExpansionTypes
for unexpanded packs and thus we don't have to remove the packs during
the normalization.
This also reverts the previous attempt f3fd5b2dd9 that doesn't
completely solve the problem.
Fixes #218548
[flang][driver] Honour the toolchain default DWARF version (#217610)
The driver only rendered -dwarf-version= when the user named a version
explicitly with -gdwarf-N. With plain -g the option was omitted, and the
backend fell back to dwarf::DWARF_VERSION. As a result `flang -g` always
produced DWARF 4 while `clang -g` produced the toolchain default for the
same target..
The fix is to generate the "-dwarf-version" flag when either the debug
information is enabled or an explicit -gdwarf-N is given.
---------
Co-authored-by: Cursor <cursoragent at cursor.com>
Co-authored-by: Tarun Prabhu <tarunprabhu at gmail.com>
[AMDGPU] Add synthetic apertures and use them for barriers
Define what a synthetic aperture is, and adjust the barrier AS
to use this new system. This makes the barrier AS even safer to
use as now we can use all 32 bits of it without ever risking
hitting a valid address of any kind (LDS or outside LDS).