[clang] allow canonicalizing assumed template names
Assumed template names are part of error recovery and encode just a
declaration name, making them always canonical. This patch allows
them to be canonicalized, which is trivial.
Fixes #183075
NAS-138973
Update and refactor 'stig mode' audit test.
Add test for trapping and reporting attempts to write to 'identity' type files,
e.g. /etc/shadow.
[Clang] Check the underlying type dependency in concept checking guards (#183010)
In the concept parameter mapping patch, we partially preserved sugar for
concept checking. However, in dependent contexts there may be
non-dependent aliases that still require concept checking to filter out
unwanted functions.
No release note because of being a regression.
Fixes https://github.com/llvm/llvm-project/issues/182344
[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.