[mlir][ODS] Include header required by generated dialect interface declarations
Generated dialect interface declarations derive from
`mlir::DialectInterface::Base` but did not include the header declaring
it. They therefore relied on the surrounding source file to include it
first.
The dialect interface declarations now include `DialectInterface.h`.
Headers that only included it for the generated code no longer need to
and drop the include. Includes of headers that the hand-written code uses
directly are kept, even when the generated code includes them as well.
Similar to #236155 and #238735 but for the dialect interface generator.
Co-authored-by: Claude <noreply at anthropic.com>
[ThinLTO] Use .llvm. prefix when promoting split-LTO internals (#240699)
Under `-fsplit-lto-unit` (enabled by CFI), internal-linkage functions
and
globals promoted across split ThinLTO/RegularLTO boundaries received a
bare `.<md5>` module suffix without `.llvm.`, preventing SamplePGO,
InstrProfSymtab, FunctionImport, and MemProf canonicalization from
stripping the promotion suffix.
Co-authored-by: Benedict Schlüter <bschlueter at google.com>
Assisted-by: Gemini
[libc][cmake] Indent hanging CMake lines by 4 spaces (#240832)
Indenting wrapped control-flow headers and header-line keyword lists by
2 spaces makes continuation lines visually indistinguishable from child
control blocks and sibling 2-space keyword sub-stanzas beneath them.
Updated cmake_format.py to indent wrapped control-flow headers and
header-line keyword items by 4 spaces when sibling keywords exist in the
command schema, while keeping positional arguments and single-keyword
property calls at 2 spaces. Corrected elseif base indentation so wrapped
conditions indent 4 spaces rather than 6, and reformatted the libc CMake
files.
Assisted-by: Automated tooling, human reviewed.
[LoongArch] Select [x]vbitset/[x]vbitrev for or/xor of bitcasted shl(splat(1), y)
When the shift of splat(1) is performed in a narrower element type than
the or/xor, e.g.
```llvm
%s = shl <8 x i16> splat (i16 1), %y
%m = bitcast <8 x i16> %s to <2 x i64>
%r = xor <2 x i64> %x, %m
```
the existing [x]vbitset.{b/h/w} and [x]vbitrev.{b/h/w} patterns fail to
match and we emit vrepli + vsll + vor.v/vxor.v.
Fold OP(bitcast(shl(splat(1), y)), x) into
bitcast(OP(shl(splat(1), y), bitcast(x))) for OP in {or, xor} so that
the operation is done in the shift's element type and selected as a
single [x]vbitset or [x]vbitrev.
Assisted-By: LLM
[LoongArch][NFC] Pre-commit tests for [x]vbitset/[x]vbitrev through bitcast
Add tests where the shift of splat(1) is done in a narrower element type
and then bitcast to the type of the or/xor operation.
Assisted-By: LLM
[LoongArch] Select [x]vbitclr for and-not of bitcasted shl(splat(1), y)
When the shift of splat(1) is performed in a narrower element type than
the and-not, e.g.
```llvm
%s = shl <8 x i16> splat (i16 1), %y
%m = bitcast <8 x i16> %s to <2 x i64>
%n = xor <2 x i64> %m, splat (i64 -1)
%r = and <2 x i64> %x, %n
```
the VANDN node is created in v2i64 with a bitcast operand, so the
existing [x]vbitclr.{b/h/w} patterns fail to match and we emit
vrepli + vsll + vandn.v.
Fold VANDN(bitcast(shl(splat(1), y)), x) into
bitcast(VANDN(shl(splat(1), y), bitcast(x))) so that the operation is
done in the shift's element type and selected as a single [x]vbitclr.
[2 lines not shown]
[LoongArch][NFC] Pre-commit tests for [x]vbitclr through bitcast
Add tests where the shift of splat(1) is done in a narrower element type
and then bitcast to the type of the and-not operation.
Assisted-By: LLM
[LangRef] Make VP intrinsics with EVL > num elements non-UB
For the remaining VP intrinsics which don't access memory:
- vp.merge
- vp.reduce.*
- vp.cttz.elts
- vp.splice
- vp.reverse
These are marked as speculatable. However the LangRef states that if the EVL > the number of elements in the vector then the behaviour is undefined. The two are inconsistent, so this PR tightens the result in this scenario to be poison.
As a result the vp.reverse expansion needs to be updated to clamp the EVL so it doesn't read outside of the stack object.
vp.udiv/vp.sdiv/vp.urem/vp.srem are also included here even though they're not speculatable. They can still cause UB if division by zero or overflow occurs on any lane even when EVL > number of elts, so I've added lines to clarify this.
VP intrinsics that read/write memory need to remain UB to match how backends lower them, they just use the EVL verbatim without any clamping or checks.
AMDGPU: Clear v_cmpx source kill flags locally (#240682)
clearKillFlags is potentially expensive and should be avoided. When
the v_cmp is folded into a v_cmpx at the saveexec, only kills of
registers overlapping the compare sources between the v_cmp and the
saveexec become invalid. Clear those directly when applying the fold,
instead of collecting candidate kills during matching and then
clearing every kill of the sources in the function.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[ProfileData] Strip .cfi suffix in InstrProfSymtab (#240955)
Under CFI jump tables, `LowerTypeTests` renames function definitions to
`<name>.cfi`. `InstrProfSymtab::getCanonicalName` did not strip `.cfi`,
preventing canonical GUID lookups from matching `.cfi` function
definitions.
Co-authored-by: Benedict Schlüter <bschlueter at google.com>
Assisted-by: Gemini
[SLP] Merge redundant input operands of binary-operator nodes (#208670)
Replaces the merged-input machinery of the preceding commits, kept in
the branch history for reference. Load-only, and restricted to
power-of-two pools: otherwise the gathered-loads path may decline the
wide load and leave the operand stuck as a gather.
Co-authored-by: Cursor <cursoragent at cursor.com>
Co-authored-by: Alexey Bataev <a.bataev at outlook.com>
[BPF] Fix use-after-free in bpf-aspace-simplify (#240996)
BPFASpaceCastSimplifyPass rewrites
`addrspacecast M->N (getelementptr (addrspacecast N->M p))` to
`getelementptr p`. When the inner cast has no other uses, the rewrite
erases it. That cast can also be the outer cast of another chain that is
still in the worklist. The pass then reads the erased cast. Clang
crashes on this code:
```c
#define __arena __attribute__((address_space(1)))
struct hdr { int len; int flags; };
int use(int *p);
int f(void __arena *buf, long off)
{
struct hdr __arena *h = (struct hdr __arena *)((char *)buf + off);
return use((int *)&h->flags);
[22 lines not shown]
[lldb][NFC] A small cleanup in Process::ReadModuleFromMemory (#241137)
I added a check for "if corefile" right after a "if live process"
conditional. Initialize both variables in the same cond expr.