Attributor: Fix build with older GCC after AAKindSet (#240975)
Older GCC versions cannot compare the addresses of distinct static
members in constant expressions, so computing the AAKindSet bits
failed. Compare the IDs as template arguments instead, and construct
the sets with AAKindSet::get from the IDs as template arguments.
Fixes cbc7d9da9b06.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[OpenMP][OMPIRBuilder] Propagate custom mapper errors from createTarget
When a custom mapper callback failed while emitting the kernel launch of a
target region, emitTargetCall wrapped the error in cantFail and crashed,
although createTarget already reports errors to its caller. MLIR
translation hits this when an omp.target uses a declare mapper that it
cannot translate yet, such as one with iterator map entries, while
omp.target_data reports the same mapper as not yet implemented.
Return the error from emitTargetCall and pass it on from createTarget, so
callers report it instead of crashing. When emitIfClause stops on such an
error, it now inserts the blocks it has not emitted yet into the function,
so they are not leaked.
Assisted with Claude Opus 5.5.
[lldb] Skip debugserver launch tests with a system debugserver (#240978)
TestDebugserverLaunchArch, added in 3e7841ef1d6f, exercises the
debugserver built from this tree. An out-of-tree debugserver that
predates that change launches the arm64e slice for arm64, so test_arm64
fails on bots using the system debugserver.
SafeStack: Take libcall declarations from RuntimeLibcallsInfo (#240445)
Stop declaring __stack_chk_fail and __safestack_pointer_address
manually and construct them with the correct type automatically.
A function with the variable's name is now reported as not being a
global variable, rather than a renamed copy of the variable being
inserted. -safestack-use-pointer-address now requires
__safestack_pointer_address to be available for the target, instead of
unconditionally emitting a call to it. The tests using it on
non-Android triples move to Android.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[AMDGPU] Ignore debug instructions when lowering a VGPR copy into a physical SGPR (#239751)
`SIInstrInfo::handleCopyToPhysHelper` scans the rest of the block for
the readers of a VGPR copied
into a physical SGPR: a call that takes the SGPR as an argument is
waterfalled, and any other reader
keeps the copy. A `DBG_VALUE` of the SGPR counted as such a reader, so
with debug info the illegal
VGPR-to-SGPR copy stayed in the loop. The scan now skips debug
instructions, and stops where the
register is clobbered, by a regmask as well as a def.
[TableGen] Get depfile dependencies from SrcMgr instead of TGLexer. NFCI. (#240925)
TGLexer recorded the path of every included file in a set that was only
used by TableGenMain to write the -d dependency file. SrcMgr already has
this information: every buffer after the main file was added by an
include directive, and its identifier is the resolved path. Build the
dependency list from SrcMgr instead, and remove the set and its
accessors from TGLexer and TGParser.
The depfile contents are unchanged. This removes the last use of the
parser after parsing has finished.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[flang][OpenACC] Convert DO loop controls to the induction variable kind (#240591)
F2023 11.1.7.4.1 requires the initial, terminal, and incrementation
parameters of a DO loop to have the same kind as the do-variable. Flang
lowered an implicit or explicit acc.loop with the controls in their
source kinds, so an i32 induction variable could get an i64 upper bound
or step.
Lowering now converts each control to the induction variable's type, and
an omitted step is the constant 1 of that type. Controls already of that
type are unchanged, so existing loops without a kind mismatch lower the
same as before.
Add acc-loop-integer-kind.f90 to check the converted controls for tile,
omitted step, integer(8) bounds and step, DO CONCURRENT, and the
matching i64 case that should not gain converts. Update the comment in
acc-loop-real-bounds.f90 to match.
[Hexagon] Add instruction-selection support for HLX (#240950)
Add instruction-selection and lowering support for the Hexagon HLX
(eLementwise eXtension) instructions, building on the HLX MC and
intrinsics support.
This adds:
- the HLX type-legalization helpers on HexagonSubtarget
(getHLXVectorLength, getHLXElementTypes, isHLXElementType,
isHLXVectorType, isTypeForHLX), so that HLX vector types are kept out of
the HVX legalization path;
- HexagonISelLoweringHLX.cpp, which registers the HLX vector types, sets
the legal operations for them, and lowers masked load/store and vector
select;
- the DetectUseSxth/DetectUseZxth complex-pattern matchers used to fold
i16 sign/zero extensions into the HLX widening operations;
- HexagonPatternsHLX.td, the HLX instruction-selection patterns for
arithmetic, multiply, shift, compare, min/max, absolute difference,
average, load/store, splat, select, and extend/truncate.
[8 lines not shown]
[flang][OpenMP] Lower iterator modifiers in map and motion clauses
An iterator modifier on a MAP, TO, or FROM clause expands each list item into
one locator per iterator value, so a single clause can map or update
scattered elements such as `a(idx(i))` without listing them or transferring
the whole array. The OpenMP dialect represents these entries since #197047;
this patch lowers them from Flang for TARGET DATA, TARGET ENTER/EXIT DATA,
and TARGET UPDATE.
For example, `!$omp target update to(iterator(i=1:n): a(i), b)` becomes:
entries = omp.iterator(i = 1 to n) {
yield map_info(base = a, bounds = element i)
}
target_update(iterated_maps = entries, ordinary_maps = [b])
Each locator is expanded only over the iterators it references, and locators
without one are mapped as before. Keeping the array base and selecting
elements or sections through map bounds handles explicit-shape and
[12 lines not shown]
[flang][OpenMP][NFC] - Add combinatorial device tests for locality specifiers (#238979)
Add end-to-end device tests for locality specifier combinations:
- local_init_reduce_device.f90: LOCAL_INIT + REDUCE on device
- shared_local_init_device.f90: SHARED + LOCAL_INIT on device
These complement the existing host-only combinatorial tests and verify
the full target teams distribute parallel do structure is generated
correctly with mixed locality specifiers.
Co-authored-by: Claude Opus 4 (1M context) <noreply at anthropic.com>
[CodeGen] Add verify<machine-dom-tree> (#240960)
Similar to the middle-end equivalent. Makes it easier to write tests
around analysis invalidation/correct preservation.
Assisted-By: LLM
LibcallLoweringInfo: Use unique_ptr for map entries. (#240015)
ModuleLibcallLoweringInfo stored each context's LibcallLoweringInfo by
value in a DenseMap, so returned references dangled once a later
insertion grew the map. Current users look the entry up again for each
function, but future changes will introduce long lived references.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[CIR][NFC] Move maximum work-group size attribute to common definitions (#240922)
Move `MaxWorkGroupSizeAttr`, introduced in #227715, and its name
accessor alongside common CIR attributes to reflect their use by HIP
kernels.
Assisted-by: Codex / GPT-6
[lld][MachO] Batch command-line object files and archive member scanning in parallel
This is part of the ld64.lld performance improvements tracked by
Currently, command-line object files and archive member symbol tables
are still parsed and scanned one file at a time as Driver::processFile()
encounters them.
This change splits ObjFile::parseLazy() into scanLazy() and
registerLazy(), and queues command-line object files and archive members
via parseLater(). parseBatch() runs scanLazy() and parsePrepare() in
parallel across the batch before running registerLazy() and
parseFinish() serially in command-line order, flushing before any other
input type.
Locally, this shows an ~8% link-time performance improvement over the
baseline.
AI use: this change is based off a prototype developed by an LLM.
[2 lines not shown]
[AMDGPU][GlobalISel] Pre-commit tests for split s.buffer.load offset overflow
Add divergent-offset ptr.s.buffer.load tests where the 256- and 512-bit
loads are split into 128-bit pieces at an offset of 4092, causing
overflow on the immediate field.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[AMDGPU][GlobalISel] Fix immediate offset overflow when splitting s.buffer.load
When we're splitting a very large (>128 bit) s.buffer.load into
128-bit buffer loads, we add offsets to each split load. Currently,
when dealing with ptr.s.buffer.load, the code wouldn't subtract enough
from the immediate offset, so that when we added that +128 or +256,
we'd overflow the 12-bit immediate, causing silent overflow.
This commit fixes the issue by correctly calling the offset
splitter with a "alignment" that ensures that all those intermediate
loads don't overflow.
This matches the behavior in SDag and RegisterBankInfo.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[AMDGPU] Reduce resource align when shrinking buffer loads
Since the `align` on buffer intrinsics includes the offset argument,
the demand, `simplifyAMDGCNMemoryIntrinsicDemanded` needs to account
for the value added to that offset, which might reduce the alignment
of the load.
AI disclosure: Claude wrote the code, I looked at it and wrote the
commit message.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[AMDGPU] Pre-commit tests for buffer load shrinking with align
Buffer load demanded elements analysis isn't shrinking the `align`
annotated on the intrinsic correctly.
AI disclosure: Claude wrote these, I wrote this message
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
Attributor: Fix build with older GCC after AAKindSet
Older GCC versions cannot compare the addresses of distinct static
members in constant expressions, so computing the AAKindSet bits
failed. Compare the IDs as template arguments instead, and construct
the sets with AAKindSet::get from the IDs as template arguments.
Fixes cbc7d9da9b06.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
Attributor: Preserve the function analyses in the light module pass (#240714)
AttributorLightPass preserved FunctionAnalysisManagerCGSCCProxy, which
is meaningless for a module pass, instead of
FunctionAnalysisManagerModuleProxy. When the pass changed anything,
the module proxy was invalidated, which clears all cached function
analyses, so e.g. IPSCCP recomputed the assumption cache, TTI and TLI
of every function. The pass neither adds nor removes functions, and it
already invalidates the analyses of the functions it changes.
CTMark instructions:u with -attributor-enable=light changes by O3
-0.02%,
ThinLTO -0.10% (kimwitu++ -0.50%, sqlite3 -0.38%).
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[libc][test] Align custom matchers with GoogleMock (#240616)
LibcTest custom matchers implemented stateful match(T) and
explainError()
methods writing directly to tlog, whereas GoogleMock's polymorphic
is_gtest_matcher protocol expects const MatchAndExplain(T,
MatchResultListener *), DescribeTo, and DescribeNegationTo methods.
Add a hermetic MatchResultListener wrapper around TestLogger in
LibcTest.h, allow the GoogleTest/GoogleMock hook method names in
libc/.clang-tidy, and update custom matchers across libc/test and
libc/utils to implement MatchAndExplain(..., MatchResultListener *)
const
so they work directly with GoogleMock's EXPECT_THAT and ASSERT_THAT
without macro redefinitions.
Part of #91630
Assisted-by: Gemini
[flang][OpenMP] Lower iterator modifiers in map and motion clauses
Iterator modifiers in the MAP clauses of TARGET DATA and TARGET ENTER/EXIT
DATA, and in the TO/FROM clauses of TARGET UPDATE, were reported as not yet
implemented.
Lower each locator that references an iterator to an omp.iterator that yields
its map entry, expanded only over the iterators the locator uses. The entry
keeps the array base and selects elements or sections through map bounds, so
descriptor-backed arrays are handled like fixed-size ones. Locators that do
not reference an iterator are mapped as before. Map info finalization leaves
the entries inside omp.iterator alone, and the temporary descriptor warning
no longer applies to iterator-dependent locators.
TARGET constructs, DECLARE MAPPER, derived type member locators, and reference
or attach modifiers are still reported as not yet implemented, as is LLVM IR
translation of iterated map entries.
Assisted with Claude Opus 5.5.
[lld][MachO] Split ObjFile::parse() and parse extracted archive rounds in parallel
This is part of the ld64.lld performance improvements tracked by
#222068 and #238938.
Currently, parsePendingExtracts() parses each extracted archive member
serially from start to finish, even though section creation, subsection
splitting, local symbol creation, and hashing external symbol names only
touch per-file state.
This change splits ObjFile::parse() into parsePrepare() and
parseFinish(), using makeThreadLocal() for per-file allocations.
parsePendingExtracts() now processes extracted members in rounds,
running parsePrepare() in parallel across each round and parseFinish()
serially in file order.
Locally, this shows a ~4% link-time performance improvement over the
baseline.
[3 lines not shown]
[SimplifyCFG] Fix and improve code size check when merging switches into predecessors (#240837)
The function `isValueEqualityComparison` had a surprising check
`incoming_edges * outgoing_edges < 128` to prevent code size explosion.
However it had two issues:
- The function was used in a few places that didn't need the check.
- It only considered `switch`, so conditional `br` wasn't considered.
Move the check to the only place where it's needed, and make it check
conditional `br`s as well. A conditional `br` is not different than a 2-way
switch, so it doesn't make sense to distinguish them.
Also fix the function documentation.
The function becomes easier to understand as it now does what it advertises: if
the instruction is a value equality comparison it returns the value being
compared. (with no surprise checks)
[7 lines not shown]
[CIR] Make cir.condition exit to the loop, not to itself
The loop-exit successor of `cir.condition` was
`RegionSuccessor(getOperation())`, which names the condition op instead
of the loop around it. An operation successor names the op that control
resumes after, and the loop's own `getSuccessorRegions` names the loop
for the same edge. MLIR's dataflow analyses use that op. DeadCodeAnalysis
recorded the exit as a predecessor of the point after `cir.condition`, so
dense analyses never saw control leave a `cir.while`, `cir.for` or
`cir.do` without a cleanup region. The forward state after such a loop
kept its initial value, and the backward state at the condition ignored
the code after the loop. The fix names the loop. The control-flow unit
test hid the mismatch because it compared op and terminator successors
by region only. It now compares whole successors, so it fails without
the fix.
Assisted-by: Claude Code (claude-opus-5-5).
[lld][MachO][NFC] Accept CachedHashStringRef in SymbolTable insertion methods
This is part of the ld64.lld performance improvements tracked by
Currently, SymbolTable::insert() constructs a CachedHashStringRef on the
serial insertion path. This change adds CachedHashStringRef overloads
for insert(), addDefined(), addUndefined(), addCommon(), and
addLazyObject() so callers can pre-hash symbol names in parallel, while
keeping StringRef wrappers for existing callers.
AI use: this change is based off a prototype developed by an LLM.
This commit is output-preserving.