[Clang] Fix assertion failure when classifying a dependent call to a builtin (#210524)
## Summary
Fix an assertion failure when Clang classifies a built-in call with
type-dependent arguments before template instantiation, e.g., while
deducing an `auto` non-type template parameter:
For example:
```cpp
template <auto> struct S {};
template <typename T>
using Alias = S<__builtin_constant_p(T::x)>;
```
```
Assertion failed: (isa<T>(CanonicalType)), function castAs, file
TypeBase.h, line 9349.
#9 clang::Type::castAs<clang::FunctionType>() const
#10 clang::CallExpr::getCallReturnType(clang::ASTContext const&) const
[19 lines not shown]
[mlir][ods] Fix string interpolation at end of description (#209744)
Updates the error streaming string logic to handle the case where string
interpolation used at the end of the description. Previously this could
generate malformed code that would not compile e.g.:
```
"' failed to satisfy constraint: another attribute " << reformat(attr)";
```
With this change the above example would now generate:
```
"' failed to satisfy constraint: another attribute " << reformat(attr) << "";
```
[analyzer][NFC] Add StackFrame parent-chain range helpers (#210938)
Walking a StackFrame's parent chain was open-coded across the Analysis
library and Static Analyzer as hand-rolled loops of the form `for (const
StackFrame *SF = X; SF; SF = SF->getParent())`.
Add range-based traversal helpers and convert the applicable loops:
* StackFrame::parents() - strict ancestors (excludes *this)
* StackFrame::parentsIncludingSelf() - *this then all ancestors
Both are built on a small forward `parent_iterator` that dereferences to
`const StackFrame &` and advances via getParent(), with a null
past-the-end sentinel.
For the common case of obtaining the current frame from an ExplodedNode
or CheckerContext, add a self-inclusive `stackframes()` convenience on
each that delegates to `getStackFrame()->parentsIncludingSelf()`.
[3 lines not shown]
[libc++][pstl] Default implementation of parallel std::adjacent_difference (#207585)
This PR adds a "one-liner" default implementation of parallel
`std::adjacent_difference` on top of parallel binary `std::transform`.
The implementation builds two iterator ranges out of the input one, so
that a zip of these ranges yields adjacent pairs. Then performs a binary
transform to calculate and output the adjacent differences.
Part of https://github.com/llvm/llvm-project/issues/99938
[libc++] Implement P0493R5: Atomic minimum/maximum (#180333)
Closes #105418.
Since gcc does not currently support `__atomic_fetch_min/max`, we use a
CAS loop in `atomic_ref` and `support/gcc.h`.
---------
Co-authored-by: Louis Dionne <ldionne.2 at gmail.com>
[libc++] Strip cv-refs in __desugars_to specialization for integral types (#208950)
This PR passes the argument type through `__remove_cvref_t` before
passing to `is_integral`.
Fixes #208236
[libc++][NFC] Re-order availability mapping to `_LIBCPP_INTRODUCED_IN_LLVM_{N}` (#210694)
Noticed that the new additions (from 16f692338cf and 8a531c3608c) were placed
rather randomly. Put the mapping back to reverse chronological order, see
783fd2f9d.
[ADT] Add single-pass merge for ImmutableSet/ImmutableMap (#209807)
The immutable-set/map dataflow joins merged two containers by inserting
the
elements of one into the other one at a time, costing O(|B| * log|A|)
and
re-copying shared spine nodes on every insert.
Add a single-pass, structure-sharing tree merge on ImutAVLFactory
(mergeTrees), exposed as ImmutableSet::Factory::unionSets and
ImmutableMap::Factory::mergeWith. It recurses over the larger operand
and
splits the smaller at each key, returning non-overlapping subtrees
unchanged,
so each spine node is copied at most once: O(|B| * log(|A|/|B| + 1)).
Two flags tune it for the different joins:
* KeepUnmatched - keep keys unique to one side (set union / a lattice
join
[37 lines not shown]
AMDGPU: Reland: Codegen for v_dual_dot2acc_f32_f16/bf16 from VOP3
For V_DOT2_F32_F16 and V_DOT2_F32_BF16 add their VOPDName and mark
them with usesCustomInserter which will be used to add pre-RA register
allocation hints to preferably assign dst and src2 to the same physical
register. When the hint is satisfied, canMapVOP3PToVOPD recognises the
instruction as eligible for VOPD pairing by checking if it is VOP2 like:
dst==src2, no source modifiers, no clamp, and src1 is a register.
Mark both instructions as commutable to allow a literal in src1 to be
moved to src0, since VOPD only permits a literal in src0.
Original patch had a bug where it did not check if physical src
registers match register class of appropriate operand in fullVOPD
instructions, check is now done via isValidVOPDSrc.
AMDGPU: Validate VOPD/VOPD3 physical source registers against operand RC
Replace isVGPR checks with isValidVOPDSrc that validates physical source
registers against the actual combined VOPD/VOPD3 instruction's operand
register classes. Now we also validate operands for VOPD instructions.
[libc++] Compose the test suite Lit site config from harness and installation substitutions (#209638)
This patch restructures how libc++'s Lit site config is generated.
Instead of relying on the user-selected configuration file to include
the CMake bridge, it composes a site configuration from multiple
independent bits.
Importantly, it splits substitutions that pertain to the harness setup
(e.g. where to find Python) and substitutions that pertain to libc++
itself (e.g. the path to libc++ headers). This split and the top-level
composition of a site config file are incremental steps towards
decoupling the test suite from libc++'s own build.
[libc++][NFC] Fix synopsis comment for error_condition::message() (#210724)
The method was marked as noexcept in the synopsis, but it's neither
marked noexcept in the spec nor in our implementation.
[flang][PFT-to-MLIR] lazily allocate label-target blocks in branch lowering
Problem
-------
Under -mmlir --wrap-unstructured-constructs-in-execute-region, branch
lowering can hit a null Evaluation::block for a branch target. For
example, genMultiwayBranch trips
Bridge.cpp: Assertion `block && "missing multiway branch block"' failed
and genFIR(SelectCaseStmt) trips
Bridge.cpp: Assertion `e->block && "missing CaseStmt block"' failed
The wrap machinery decides an unstructured DO/IF is wrappable and
therefore stops propagating its isUnstructured flag to the enclosing
construct. The enclosing construct's isUnstructured stays false, so the
top-level createEmptyBlocks does not recurse into its body. If that
enclosing construct's lowering then takes over the body itself instead
[14 lines not shown]
[VPlan] Detect contiguous accesses in outer loop VPlan path. (#203790)
Use SCEV analysis on VPValue pointer operands to detect stride-1 memory
accesses in the outer loop vectorization path. When a load or store
address is an affine AddRec w.r.t. the vectorized outer loop with stride
equal to the element size, mark it as consecutive so it generates a wide
load/store instead of a gather/scatter.
For example, in the column-scaling pattern:
```
for (i = 0; i < N; i++) // outer: vectorized
for (j = 0; j < M; j++) // inner: uniform
A[i*M+j] *= scale[i];
```
The access scale[i] is now correctly identified as contiguous and
generates a vector load instead of a masked gather.
PR: https://github.com/llvm/llvm-project/pull/203790
[SelectionDAG] Fold VECREDUCE_AND/OR/XOR of a constant BUILD_VECTOR (#210883)
Follows up on #207560 and #210126
Adds constant folding for `ISD::VECREDUCE_AND`, `ISD::VECREDUCE_OR`, and
`ISD::VECREDUCE_XOR` in SelectionDAG::FoldConstantArithmetic when the
input is a BUILD_VECTOR of integer constants. Does not fold undef/poison
elements.
Fixes #209108
[VPlan] Move lowering transforms to VPlanLowering.cpp (NFC) (#209885)
Following up to https://github.com/llvm/llvm-project/pull/209883,
move transformations related to lowering/preparing for execution
to VPlanLowering.cpp
This moves materialize*, convertToConcreteRecipes,
dissolveLoopRegions, expandBranchOnTwoConds,
replaceWideCanonicalIVWithWideIV, expandSCEVsToVPInstructions,
addBranchWeightToMiddleTerminator and the alias-mask materialization helpers.
The createScalarIVSteps and scalarizeVPWidenPointerInduction are
promoted to vputils.
Depends on https://github.com/llvm/llvm-project/pull/209883
[llvm-ir2vec] Adding metadata for llvm-ir2vec python binding wheel builds (#194222)
The next step is to setup the metadata for the wheel building process,
and subsequently follow it up with workflow jobs that can automate this.
Revert "[RISCV] Run EarlyMachineLICM before VLOptimizer to hoist constant splats" (#210937)
Reverts llvm/llvm-project#210028
I've bisected the hangs on rva20 to this commit:
https://lab.llvm.org/buildbot/#/builders/210/builds/11806
[clang] Add flag for making pointer subtraction defined (#196392)
The C and C++ standards require both operands of pointer subtraction to
refer to elements of the same array object. Clang/LLVM currently relies
on this rule in several optimizations:
- `inbounds` GEP introduces UB assumptions once the computed address
escapes the originating object bounds.
- `sdiv exact` assumes %op1 is divisable by %op2 otherwise it is a
poison value.
The first issue may be addressed with -fwrapv-pointer command line
option, however there is no option in clang to mitigate the second
issue. Patch adds a new -fdefined-pointer-subtraction to address this.
[lldb][NFC] Remove Stream::Printf calls with constant strings in Target/* (#210287)
`Stream::Printf` needs to call various other (variadic) functions, needs
to parse the input string and potentially handle too-long format
outputs. Calling in with a constant string is wasting a lot of
instruction on doing nothing.
assisted-by: claude
[lldb][NFC] Remove Stream::Printf calls with constants in Commands/ (#210291)
`Stream::Printf` needs to call various other (variadic) functions, needs
to parse the input string and potentially handle too-long format
outputs. Calling in with a constant string is wasting a lot of
instruction on doing nothing.
assisted-by: claude
[lldb][NFC] Remove Stream::Printf calls with constant strings in Interpreter/* (#210289)
`Stream::Printf` needs to call various other (variadic) functions, needs
to parse the input string and potentially handle too-long format
outputs. Calling in with a constant string is wasting a lot of
instruction on doing nothing.
assisted-by: claude