[clang] create local instantiation scope for matching template template parameters
This fixes a bug where a partial substitution from the enclosing scope
is used to prepopulate an unrelated template argument deduction.
Fixes #181166
[lldb][DWARFASTParserClang][NFC] Make ParsedDWARFTypeAttributes parameter a const-ref (#183024)
In https://github.com/llvm/llvm-project/pull/182956 we stopped using
access specifiers from DWARF for most Clang decls we create. This
parameter no longer needs to be modified and we can make it a
`const-ref`.
[MLIR][XeGPU] Enable one-step subgroup distribution of cross-lane reduction to shuffle op (#182698)
This PR simplifies the current two-step distribution implementation for
vector.multi-reduction op on cross-lane reduction. Instead of first
lowering to vector.reduction op and further distribution, it directly
lowers to shuffles op. This removes the complexity of setting xegpu
layout for the intermediate operations (extract/insert/reduction)
generated on the fly during subgroup distribution pass.
[NFC] Thread `DataLayout` through helper function signatures for aggregate construction
Add `const DataLayout *DL` parameter to helper functions and classes that
construct aggregate constants but previously had no access to `DataLayout`. This
is the final preparatory step before the `ConstantPointerNull` semantic change,
ensuring aggregate collapse-to-`ConstantAggregateZero` checks have `DataLayout`
awareness in all remaining call sites.
[NFC] Pass `DataLayout` to aggregate constant factory call sites
Update callers of `ConstantArray::get`, `ConstantStruct::get`/`getAnon`,
`ConstantVector::get`, and `ConstantVector::getSplat` to pass the `DataLayout`
pointer where available.
This is preparatory work for the `ConstantPointerNull` semantic change. After
that change, aggregates containing pointer-null elements need `DataLayout` to
correctly determine whether they can collapse to `ConstantAggregateZero`.
Threading `DL` through callers now (NFC) ensures the eventual semantic change
does not break aggregate collapse for zero-null targets.
[NFCI][IR] Thread `DataLayout` through aggregate construction for collapse checks
Add `const DataLayout *DL = nullptr` to `ConstantArray::get`,
`ConstantStruct::get`, `ConstantVector::get`, and `ConstantVector::getSplat`
so the collapse-to-`ConstantAggregateZero` check uses `isZeroValue(DL)`
instead of `isZeroValue()`.
This is preparatory work for the upcoming `ConstantPointerNull` semantic
change, where `getZeroValue(ptrTy)` will diverge from
`ConstantPointerNull`. Without DL-aware collapse, aggregates containing
CPN would stop collapsing to CAZ, causing widespread test churn. With
this change, callers that pass DL will see correct collapse behavior,
while callers without DL fall back to a conservative identity check.
[DataLayout] Add null pointer value infrastructure
Add support for specifying the null pointer bit representation per
address space in DataLayout via new pointer spec flags:
- 'z': null pointer is all-zeros (assumed if unspecified)
- 'o': null pointer is all-ones
- 'c': custom/unknown null value (LLVM will not fold)
This adds:
- `std::optional<APInt> NullPtrValue` field to `PointerSpec`
- Parsing of z/o/c flags in pointer spec strings
- `getNullPtrValue(unsigned AS)` query API
- `isNullPointerAllZeroes(unsigned AS)` convenience method
- LangRef documentation for the new flags
- Unit tests for all new functionality
No target DataLayout strings are updated in this change. This is
pure infrastructure for a future ConstantPointerNull semantic change
to support targets with non-zero null pointers (e.g. AMDGPU).
[NFCI][IR] Add DataLayout-aware `isZeroValue`/`getNullValue` and `getZeroValue` APIs
Modify `Constant::isZeroValue()` and `Constant::getNullValue()` to accept an
optional `const DataLayout *DL = nullptr` parameter, and add a new
`Constant::getZeroValue()` factory method. This establishes the API
distinction between "null value" (semantic null pointer, which may be
non-zero on some targets) and "zero value" (all-zero bits).
When DataLayout is provided:
- `isZeroValue()` checks `ConstantPointerNull` against the target's null
pointer bit pattern via `DL->isNullPointerAllZeroes(AS)`, returning
false for address spaces where null is not zero.
- `getNullValue()` constructs aggregates element-by-element when they
contain pointer elements in non-zero-null address spaces, preserving
ConstantPointerNull instead of collapsing to ConstantAggregateZero.
When DataLayout is not provided, both functions behave identically to
their previous implementations, ensuring full backward compatibility.
[3 lines not shown]
[NFCI][IR] Thread `DataLayout` through `ConstantFold`; fix CAZ extraction and aggregate collapse
Prepare the constant folding infrastructure for the `ConstantPointerNull`
semantic change, where null may have a non-zero bit pattern.
Thread `const DataLayout *DL = nullptr` through `ConstantFoldCastInstruction`,
`ConstantFoldCompareInstruction`, and `ConstantFoldGetElementPtr`. When DL is
present and the null pointer is not zero for the relevant address space,
pointer-involving folds (e.g., ptrtoint null -> 0, icmp uge X null -> true)
are deferred to the DL-aware folder instead of producing incorrect results.
Without DL, behavior is unchanged.
Fix `ConstantAggregateZero` element extraction to return `getZeroValue` (not
`getNullValue`), ensuring CAZ always yields all-zero-bit elements regardless
of the address space's null pointer value.
Fix aggregate collapse checks to use `isZeroValue()` instead of `isNullValue()`.
This correctly prevents collapsing aggregates of FP -0.0 (non-zero bit
pattern) into `ConstantAggregateZero`, and will prevent incorrect collapse of
non-zero-null `ConstantPointerNull` after the semantic change.
[NFCI] Use `DataLayout::getNullPtrValue` in codegen and analysis paths
Replace hardcoded 0 for null pointer materialization with
`DataLayout::getNullPtrValue(AS)` across codegen, analysis, and
transform paths. This prepares these paths for a future semantic
change where `ConstantPointerNull` may represent a non-zero null
pointer value on certain targets.
NFC because all address spaces currently have all-zero null pointer
values, so `getNullPtrValue` returns 0 for every address space.
[SPIRV] Add Intermediate cast when Vector From/To types are of different element size and type (#182166)
fixes https://github.com/llvm/llvm-project/issues/177838
- Replaced assert(TargetTypeSize == SourceTypeSize) with a conditional:
when sizes differ, compute a BitcastType with the target's element type
but sized to match the source's total bitwidth
- Instead of unconditionally returning after bitcast, only return early
if BitcastType == TargetType (same-size case), otherwise fall through to
the shuffle logic
- Updated the final assert to use AssignValue->getType() since that may
now be the intermediate type rather than SourceType
[Flang][mlir][OpenMP] Support affinity clause codegen in Flang
This patch translate flang ast to OpenMP dialect for affinity clause
including the iterator modifier.
Fix based on feedback
- omp.iterators -> omp.iterator
- add return type in verifier
- Use OpenMP_LoopRelatedClause in omp.iterator for consistent bounds
definition
[mlir][OpenMP] Introduce 'omp.iterator' for OpenMP iterator modifier
`omp.iterator` provides information of induction variables and iterator
range in OpenMP iterator modifier.
Example:
```
%it = omp.iterator(%i0: index, %i1: index) =
(%lb0 to %ub0 step %st0,
%lb1 to %ub1 step %st1) {
omp.yield(%i0, %i1 : index, index)
} -> !omp.iterated<!llvm.struct<(!llvm.ptr, i64)>>
```
Here's how we can use the omp.iteraters to generate multi-dimensional
loop in llvm ir:
```
// Induction variables can be translated from the block arguments
// in omp.iterator.
[8 lines not shown]
[flang][mlir][OpenMP] Allow for flexible typing of linear step variables (#182816)
This PR allows for flexible typing of linear step variables. The format
of the linear clause is also changed to: `linear(linear_var : type =
linear_step : type)`; this format closely follows the formatting of the
allocate/allocators clauses.
Fixes https://github.com/llvm/llvm-project/issues/178793
Co-authored-by: urvi-rav <urvi.rav at hpe.com>
Fix based on feedback
- omp.iterators -> omp.iterator
- add return type in verifier
- Use OpenMP_LoopRelatedClause in omp.iterator for consistent bounds
definition
[lldb] Disable shared build for TestHiddenIvars.py and TestObjCIvarStripped.py (#183188)
These tests sporadically fail on Green Dragon. My hypothesis is that one
test is rebuilding while another is trying to load a dSYM leading to a
mismatch.