[HIP] Address review nits: drop unused REQUIRES, add MSVC ordering test
- Drop amdgpu-registered-target from hip-include-path-preprocess.hip
since both RUN lines are host-only and pass with an X86-only build.
- Add an MSVC target test to hip-include-path.hip verifying that ROCm
toolkit headers appear before system headers (resource dir / INCLUDE
env var paths) on Windows, confirming the late-hook ordering is
intentional on MSVC.
Co-Authored-By: Claude Opus 4.6 <noreply at anthropic.com>
[DAG][X86] Do not narrow trunc(select) to an undesirable type
DAGCombiner rewrites trunc(select c, a, b) as select c, (trunc a),
(trunc b) when truncating is free. X86 has no 8-bit CMOV, so LowerSELECT
widens an i8 select to i32 through ANY_EXTENDs that become MOVZX
(isolate_msb_i128 in bit-manip-i128.ll):
orb $64, %cl orl $64, %ecx
testq %rsi, %rsi testq %rsi, %rsi
movzbl %cl, %ecx cmovneq %rax, %rcx
cmovnel %eax, %ecx
Gate the fold on isTypeDesirableForOp(ISD::SELECT, VT) and have X86
report i8 as undesirable when CMOV is available. Without CMOV the select
becomes a branch, so nothing changes there. The hook's default rejects
every illegal type, so it is only asked about legal ones and narrowing
to an illegal type is unchanged. A select of two constants is still
narrowed: it becomes i8 setcc arithmetic that needs no zero extension.
[6 lines not shown]
[X86] Enable SlotIndexes compaction by default
Compacting SlotIndexes before greedy allocation drops the entries of
erased instructions, so live range sizes and instruction distances
reflect the code being allocated rather than how much was erased
before it. AMDGPU has done this since #235806; do the same for X86.
Codegen changes only through allocation: no new crashes, verifier
errors or allocation failures in the lit suites, including
EXPENSIVE_CHECKS, and a stage-2 build of LLVM, clang and lld with
-verify-machineinstrs passes its own tests. On llvm-test-suite at -O3,
spills drop 0.3% and .text 0.06%, with compile time unchanged.
Most test updates are regenerated checks. misched-matmul now inserts
20 spills instead of 24. live-debug-vars-stale-slotindexes.mir gets
one more use of %27 so that accumulate_fit still reaches the stale
index path it was written for. reloc-opt.ll gets an NF add that keeps
its source live, because compaction compresses the existing one to the
legacy form. inline-spiller-hoist-folded-copy.ll gets four empty asm
[2 lines not shown]
[ctxprof] Write flat profiles for non-rootable functions
Functions that cannot become roots, such as those containing musttail calls, have their CtxRoot field initialized to the non-rootable sentinel. When serializing flat profiles, check whether a function is an active root rather than requiring CtxRoot to be null and rootable, so flat profiles collected for non-rootable functions are not dropped.
[AMDGPU][GlobalISel] Recognize canonical update.dpp results (#247744)
Teach GlobalISel to recognize canonical `llvm.amdgcn.update.dpp` results
so the post-legalizer combiner can remove redundant `G_FCANONICALIZE`
instructions.
The source must be canonical. If either mask is partial or zero fill is
disabled, the old value must also be canonical because some lanes can
retain it.
[AMDGPU] Scalarize packed FP math with fabs sources and update cost model (#236584)
Packed math instructions (v_pk_add, v_pk_mul, v_pk_fma, v_pk_min_num and
v_pk_max_num) have no abs source modifier, so an fabs feeding one must
be materialized as a real and per element. Scalarizing the packed operation
instead lets the abs fold back into a source modifier, trading the packed
instruction plus N ands for N scalar instructions.
Update the TTI cost model to match: fabs stays free, and a packed
f32/f64 fadd/fsub/fmul, fma/fmuladd or f64 minimumnum/maximumnum with a
single-use fabs source (looking through fneg) is priced as one scalar instruction
per element instead of a packed instruction. When queried by the SLP vectorizer, the
operands of the scalar instruction representing the lanes are checked.
Fixes: LCOMPILER-2919
---------
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[lldb] Escape non-printable characters in thread and queue names (#248151)
The inferior sets thread and queue names and can put any bytes in them.
The thread.name and thread.queue format entities printed them verbatim,
so a name could send control sequences to the terminal.
Escape both with StringPrinter, as string summaries already do.
Printable UTF-8 is unchanged, while double quotes and backslashes are
escaped too.
rdar://187191695
Assisted-by: Claude
[Attributor] Fold lookupAAForImpl into lookupAAFor
Also use isAllowed in checkAndQueryIRAttr.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[bazel] Enable include scanning (#248169)
This scans source files to determine what headers need to be inputs to
their compilation actions. This massively reduces network traffic when
using remote execution. In my testing a full build without remote
execution transfers ~12gb of source files, and with include scanning it
transfers ~1gb
This is only enabled for first party code. If a file isn't included
because of its include not being regexable, for example if it's
included via a define:
```
#define FOO "bar.h"
#include FOO
```
It can be added to `additional_compiler_inputs` in order to get scanned.
If there's a larger problem individual targets can set `features =
["-cc_include_scanning"]`
[WPD] Don't treat a call that passes a vtable slot as a virtual call (#245870)
findCallsAtConstantOffset recorded every call or invoke that used the
function pointer loaded from a vtable slot, including one that only
passes it as an argument. Devirtualizing such a call hit the
"devirtualizing direct call?" assertion in applySingleImplDevirt or,
without assertions, rewrote the callee or folded the result of an
unrelated direct call.
This happens when hot/cold splitting outlines the indirect call into a
function that takes the loaded slot as an argument; the WPD run for
-fdevirtualize-speculatively comes after it.
Record only calls whose callee is the slot pointer, and treat any other
call use as a non-call use.
Assisted-by: Claude Code
[flang-rt][cuda] Add reduce.cpp to the supported files (#248183)
Add `reduce.cpp` to the list of supported files for the CUDA build so we
can support `reduce` in compute region.
```
!$acc parallel loop copyin(a) copyout(r)
do i = 1, 8
r(i) = reduce(a(:, i), iadd)
end do
```
[clang][deps] Add dependency scanning support for #embed
Teach the dependency directive lexer to scan #embed like we do for #include,
and the dependency scanner to record the dependencies from #embed and
__has_embed. Modules work by virtue of the embedded files being input files to
the scanner pcms. Incidentally fix the strict context hash to include embed
directories.
Claude Opuse helped with the tests.
[mlir][mem2reg][NFCI] Only scan blocks that interact with the promoted slot (#244298)
`promoteInBlock` walks every operation of every block in the slot's
region, once per promoted slot, so promotion cost grows with slots times
operations even when each slot is used in a few blocks.
Only blocks holding a blocking use or a region to promote can read or
redefine the slot. `promoteSlot` now collects those blocks, and
`promoteInBlock` forwards the reaching definition through any other
block without visiting its operations. The interface docs now state two
properties every in-tree implementation already has and this relies on:
`storesTo` implies a blocking use, and `setupPromotion` does not move
operations across blocks.
`mlir-opt --mem2reg`, one function with 6,000 allocas over 3,000
diamonds (9,001 blocks), median of 5 runs, byte-identical output:
| Input | Before | After |
|--------------|---------|--------|
[4 lines not shown]
[clang] Rebuild implicit modules when #embed files change
Files embedded are intentionally not sloc entries, so explicitly track the
embedded files and add them to the AST's input files in ASTWriter. This
ensures implicit modules are rebuilt correctly when they change.
Claude Opus helped with the tests.
[lldb][Windows] Invalidate the ARM64 register cache when a thread runs (#248084)
Since #197385, `NativeRegisterContextWindows_arm64` caches the thread's
`CONTEXT`.
Stops and register writes drop the cache but not resumes. Therefore,
exception handlers in `NativeProcessWindows` that read registers before
calling `StopThread()` get stale values.
This patch drops the cache when a thread resumes, and when a debug
exception arrives for it.
This fixes the flakes in `TestMultipleBreakpoints`.
[Internalize] Internalize GlobalIFunc symbols (#247949)
InternalizePass previously iterated over functions, globals, and
aliases, leaving GlobalIFunc symbols exported even when not in the
public API list. This broke the internal sanitizer symbolizer build on
https://lab.llvm.org/buildbot/#/builders/sanitizer-x86_64-linux after
#215813 added std::__new_at_least as a gnu::ifunc in libc++.
Assisted-by: Gemini
[DAGCombiner] Don't fold fsub of identical fmul operands into FMA (#247293)
visitFSUBForFMACombine has no guard for identical operands, unlike
visitFADDForFMACombine. When the target enables aggressive FMA fusion
(e.g. AArch64 A64FX, ThunderX2/3, Apple A14), fsub(m, m) with m = fmul
x, y is folded to fma(x, y, -m), i.e. fmul + fnmsub. The fused form
computes the rounding error of the product instead of 0.0, and it is
never beneficial: the fmul must still be computed for the addend, and
the fsub is replaced by a more complex instruction with higher latency
and register pressure.
Skip the fold when both operands are the same node.
[SampleProf] Address review feedback
- Move DataAccessProf.h include from SampleProf.h to
SampleProfReader.h and SampleProfWriter.h.
- Expand DataAccessProfData::merge documentation and
add readability improvements.
- Add comments to RUN groups in
sample-data-access-profile.test.
[lld][MachO] Error out on string tables over 4 GiB
Symbol string table offsets (`n_strx`) and the table's size (`strsize`) are
32 bits wide, but `StringTableSection` tracks its size in a `size_t` and
silently truncates offsets past 4 GiB, producing a corrupt symbol table.
This PR reports an error once all strings have been added instead. The test
reaches 4 GiB cheaply by linking one object with a 1 MiB local symbol name
4096 times under `-no-deduplicate-symbol-strings`.
Assisted by Claude.
[DAG][X86] Do not narrow trunc(select) to a type undesirable for SELECT
DAGCombiner rewrites trunc(select c, a, b) as select c, (trunc a),
(trunc b) when truncating is free. X86 has no 8-bit CMOV, so LowerSELECT
widens an i8 select to i32 through ANY_EXTENDs that become MOVZX
(isolate_msb_i128 in bit-manip-i128.ll):
orb $64, %cl orl $64, %ecx
testq %rsi, %rsi testq %rsi, %rsi
movzbl %cl, %ecx cmovneq %rax, %rcx
cmovnel %eax, %ecx
Gate the fold on isTypeDesirableForOp(ISD::SELECT, VT) and have X86
report i8 as undesirable when CMOV is available. Without CMOV the select
becomes a branch, so nothing changes there. The hook's default rejects
every illegal type, so it is only asked about legal ones and narrowing
to an illegal type is unchanged. A select of two constants is still
narrowed: it becomes i8 setcc arithmetic that needs no zero extension.
[6 lines not shown]
[lld][MachO] Reuse symbol string offsets in STABS (#246781)
`SymtabSection::emitStabs()` calls `stringTableSection.addString()` for
every defined symbol's name, even though
`SymtabSection::finalizeContents()` already added those exact strings to
the string table for the ordinary symbol table. On large debug links,
repeating the hash and `DenseMap` probe for every STABS symbol accounts
for a substantial share (7-23%) of `__LINKEDIT` finalization.
This PR carries each symbol's existing `strx` alongside its `fileId` in
`symbolsNeedingStabs` (fitting in the existing struct padding) and
reuses it directly in `emitStabs()`.
Note that we reuse `strx` unconditionally, including under
`-no-deduplicate-symbol-strings`. That flag was added in #123874 as a
link-time speedup trade-off, not to force STABS entries to duplicate
ordinary symbol names. In fact, most of the size impact of deduplicating
symbol strings was coming from deduplicating these STABS; with this PR,
the impact of `-no-deduplicate-symbol-strings` on output binary size
[6 lines not shown]
[X86][ACEV1] Drop the fixed shape from the managed-RA intrinsics
Palette 2 fixes every ACE tile at 16 rows of 64 bytes, so the two
leading shape arguments were always 16 and 64, and X86TileConfig
already refused to write them into the descriptor. They reached the
binary as two unread movw.
Remove them from the 19 internal builtins and intrinsics, and give
the passes that asked for a ShapeT an ACE path, since ShapeT holds
MachineOperands and cannot hold a constant. MayLiveAcrossBlocks is
sized by a guess the ACE reload already outgrew, so grow it on
demand. The header API is unchanged.
[X86][ACEV1] Keep ACE tiles off the AMX shape paths
ACE tiles are a fixed 16x64 and carry no Row/Col, so they must never reach
a path that reads a shape. This fixes the places where they did:
- Zero tiles: ACE zero tiles now lower to the operand-free
x86_acev1_tilezero_internal before any shape is asked for.
- Bitcasts: vector/tile bitcasts with an ACE producer or consumer lower a
row at a time instead of becoming an AMX tileloadd/tilestored.
- PHIs: hasACEIncomingValue now looks through PHIs of PHIs, and the dead
ACE pseudos are dropped from X86RegisterInfo::getTileShape.
- Mix diagnostic: tilezero now records its AMX model during selection, so
a PHI or direct tilezero next to ACE tiles errors instead of compiling.
Tests cover zero tiles, raw bitcasts, PHI zero edges and PHIs of PHIs, the AMX
tcvtrow shape, and the managed and direct tilezero mixes.
[DAG] Add trunc(select) narrowing tests (NFC) (#248034)
DAGCombiner::visitTRUNCATE narrows trunc(select c, a, b) to
select c, (trunc a), (trunc b) when truncating is free. These tests pin
its current output for #223763, which stops it for i8 on X86 with CMOV.
All test IR is what opt -O2 produces for x86-64, s390x and amdgcn with
their real datalayouts, so it is IR the backend can see. InstCombine
already narrows a trunc of a select with a constant arm, so that case
only comes from truncates the DAG creates, here a shift amount.
X86 (x86-64, i686 with and without CMOV):
- trunc_select_i8: computed arms of an i32 select truncated to i8. With
CMOV, LowerSELECT widens the i8 select with a MOVZX of each arm
computed in i8.
- trunc_select_i32: an i64 select truncated to i32, which has a CMOV of
its own width.
- trunc_select_i7: an illegal type, legalized to i8.
- trunc_select_shift_amount: a select of two constant shift amounts,
[13 lines not shown]