[Attributor] Disable analysis-invalidation verification in light-preserved-analyses.ll (#242001)
0f7faf803fdd added light-preserved-analyses.ll, whose CHECK-NEXT chain
assumes nothing is printed between "Running pass: AttributorLightPass"
and the next RequireAnalysisPass. With EXPENSIVE_CHECKS (as on
clang-stage1-RA-expensive), -verify-analysis-invalidation defaults to
on, so the PreservedFunctionHashAnalysis/PreservedModuleHashAnalysis
helpers are invalidated by the pass and recomputed, adding extra
"Invalidating analysis"/"Running analysis" lines and breaking
CHECK-NEXT.
Pass -verify-analysis-invalidation=false in the RUN line, as other
-debug-pass-manager tests do (e.g.
LoopVersioning/preserved-analyses.ll), so the test no longer depends on
whether the build enables expensive checks.
rdar://192409356
Co-Authored-By: Claude Sonnet 5.5 <noreply at anthropic.com>
[SystemZ] Update clang lit tests for default trigraphs on z/OS (#238549)
Update the clang lit tests so they work (or marked as xfail) on z/OS
with trigraphs being on by default.
[SPARC] Treat RESTORE as a scheduling boundary (#240337)
The post-RA scheduler runs after the PEI pass that adds the RESTORE
instruction and could move instructions around the RESTORE so that they
accidentally use the caller's registers instead.
No SPARC processor currently enables post-RA scheduling.
Assisted-by: Claude
[ConstraintElim] Use ConstantInt::getFalse in replaceOverflowUses. (#241998)
We also support simplifying ops on vector values, so use
ConstantInt::getFalse instead of Builder.getFalse() which returns a
plain bool.
Fixes a crash in the added tests.
[SystemZ][z/OS] Mark scan-dep tests as unsupported/xfail (#238557)
Most of these are unsupported b/c z/OS doesn't have the __clangast
section just like in AIX. The others are like not handling multiple
threads.
[AMDGPU] Do not track TENSOR_SAVE/TENSOR_STOP with xcnt (#239519)
Follow-up to #236045.
The VGLOBAL tensor ops don't increment xcnt, but TENSOR_SAVE and
TENSOR_STOP take the generic FLAT path in `getEventsForImpl` and get
`VMEM_GROUP`. Counting them weakens the wait for older VMEM operations:
the address of an earlier global load can be overwritten after
`s_wait_xcnt 1` when `s_wait_xcnt 0` is needed. It also adds an
unnecessary `s_wait_xcnt 0` before a later `$exec` write.
Skip `VMEM_GROUP` for these two opcodes.
---------
Co-authored-by: Cursor <cursoragent at cursor.com>
Co-authored-by: Matt Arsenault <arsenm2 at gmail.com>
[llubi] Add support for vp.merge (#241727)
A vp.merge is unique from other VP intrinsics in that the lanes past EVL
(or the pivot as the langref calls it) aren't poison, they're taken from
the false branch.
It's defined in terms of `select %EVLMask, %true, %false`. I've factored
out the SelectInst logic so it can be shared. But it can be duplicated
if reviewers prefer.
Assisted-by: Opus 5.5
[OpenMP][OpenMPIRBuilder] Enable non-pointee storage present propagation in mappers (#241537)
Add a boolean to emitUserDefinedMapper to toggle on present propagation
for non-pointee storage members, effectively storage shared with/part of
the top-level parent. This will remain off for the main clang path for
the moment but is switched on for Flang/CIR. This is due to the fact
that Clang still predominantly uses OBJ_AND_PTR style maps, whereas the
MLIR path only uses it for declare target at the moment, which bypasses
the mapper route making it a non-issue for this change.
[Support] Resolve real path lazily for RealFile (#239020)
`RealFileSystem` resolves the real path of every file it opens, so
that `RealFile::getName()` can return it later. Not every caller asks
for the name: clang's dependency scanner opens a file by the path it
already has and only reads its contents.
On Windows, the real path comes from `GetFinalPathNameByHandleW`,
which queries the Mount Manager, and that query serializes. Parallel
compile processes wait in `mountmgr.sys`.
Resolve the path on the first `getName()` call, using
`getRealPathFromHandle` on the open file. Callers that ask for the
name get the same result as before. Callers that never ask no longer
pay for it.
When the OS cannot resolve the path from the open file, or the
file is already closed, fall back to the `real_path` of the original
path.
[3 lines not shown]
[CIR] Use target-specific maximum for _BitInt alignment (#241466)
CIR had been using a hard-coded 64-bit maximum alignment for _BitInt
types, which matches x86-64 targets but not AArch64. This change adds an
MLIR data layout entry to record the target's maximum _BitInt alignment
so that this value can be retrieved by post-codegen queries.
Assisted-by: Cursor / various models
Attributor: Don't seed functions without exact definitions in the light pass
attributor-light seeded abstract attributes for every function in the
SCC, including functions without an exact definition, e.g. linkonce_odr
C++ inline functions. Their attributes cannot be derived from the body
that may be replaced at link time, so these AAs only reached a
pessimistic state. FunctionAttrs skips such functions as well. NFC in
the output of the light pass for CTMark, kimwitu++ and several clang
sources.
CTMark instructions:u with -attributor-enable=light:
O3: -1.30% (tramp3d-v4 -10.43%)
ThinLTO: -0.83% (tramp3d-v4 -4.01%)
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
IR: Track analysis invalidation state by result list index
AnalysisManager::invalidate recorded whether each cached result was
invalidated in a 32 entry SmallDenseMap, and the Invalidator found
dependencies through the AnalysisResults map. Keep the states in a
vector parallel to the IR unit's result list instead, and find
dependencies by scanning that short list. With N cached analyses for
the IR unit, each lookup is O(N) and invalidation O(N^2) in the worst
case. N is bounded by the number of registered analyses rather than
the size of the IR: functions have about 11 cached results in O3 (at
most 22), and the average scan costs about as much as the hash probe
it replaces.
CTMark instructions:u, geomean: O3 -0.27%, ThinLTO -0.30%
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[cmake][docs] Rewrite cmake rst docs to md [2/2] (#234025)
Tracking issue:
[#201242](https://github.com/llvm/llvm-project/issues/201242)
See the [migration
guide](https://llvm.org/docs/SphinxQuickstartTemplate.html#markdown-migration-guidelines)
for more information.
this is the second part of migrating the cmake readme from rst to md
the content conversion is provided by this pr, following the rename in
the previous pr
Depends on #234023
the first commit is from the base pr (rename), the second commit
contains the content conversion
[Clang][OpenMP] Emit device kernels for target regions in lambdas without an enclosing function (#240840)
Fixes #136652
A `target` region in a lambda at namespace scope no longer crashes the
host after #226691, but with offloading the device still emitted no
kernel for it. The device finds target regions by scanning function
bodies, and a lambda in a global initializer, a default argument or a
default member initializer is reached from none of them. The host
registers the entry, the device image has nothing behind it.
The device scan now walks those initializers and names a region the way
the host does: after the enclosing non-closure function, or after the
call operator itself when there is none, through one helper shared by
both sides. Such closures also get a mangling number when offloading, as
under CUDA, so the two compilations agree on the name.
AI Assisted!
[CodeGen] Set the SignedClassRO bit in __objc_imageinfo (#238444)
Since #147899, clang emits the "Objective-C Enforce ClassRO Pointer
Signing" module flag. Its value is `SignedClassRO (1 << 4)` when clang
signs `class_ro_t` pointers, which it does by default on arm64e, and 0
otherwise. `GetObjCImageInfo` doesn't OR this key into the image info
flags so the bit never reaches `__objc_imageinfo`. For the same arm64e
Objective-C file, Xcode's clang writes flags 0x50 and upstream clang
0x40.
The Objective-C runtime reads a clear bit as "this image's class_ro_t
pointers are not signed". When an arm64e process loads such an image,
objc4 quietly stops authenticating `class_ro_t` pointers for the whole
process.
Here, we add the key to the set. `ptrauth-objc-imageinfo.ll` checks an
arm64e module with the flag set and one where clang emits the flag as 0
and the flags stay 0x40.
Assisted-by: Claude Code
[openmp][docs] Rewrite openmp rst docs to md [2/2] (#234020)
Tracking issue:
[#201242](https://github.com/llvm/llvm-project/issues/201242)
See the [migration
guide](https://llvm.org/docs/SphinxQuickstartTemplate.html#markdown-migration-guidelines)
for more information.
this is the second part of migrating the remaining openmp readme from
rst to md
the content conversion is provided by this pr, following the rename in
the previous pr
Depends on #234018
the first commit is from the base pr (rename), the second commit
contains the content conversion
[Clang][OpenMP] Fix crash on a tuple-like structured binding in a task (#241357)
Fixes #116258
A tuple-like structured binding (`std::pair`, `std::tuple`) referenced
in a `task` or named in `firstprivate` crashed clang right after the
"not yet supported" error. `isOpenMPCapturedDecl` maps struct and array
bindings to their `DecompositionDecl` but let tuple-like ones fall into
the data-member path, which dereferences a private copy that a binding's
DSA never has.
`isOpenMPCapturedDecl` now reports the holding variable for a privatized
tuple-like binding, so its uses still reach the capture checks instead
of a null private copy; unprivatized ones keep returning null. Outside
any construct, `getDSA` now classifies a tuple-like binding by the
storage of the variable it decomposes, so a namespace-scope one is
shared like that variable.
LLM tools were used for this contribution.
clang: Add ArgRange builtin attribute for constant argument ranges
Many target builtins take constant arguments that must be in a
specific range. These usually correspond directly to the Range
annotation on the IR intrinsic, which the verifier enforces. Today
this requires manual verification with a large builtin ID switch in
Sema, and missed cases will emit code that fails the IR verifier.
Add an ArgRange<Index, Lo, Hi> builtin attribute declaring that a
_Constant argument must be in the half-open range [Lo, Hi), the same
as the IR declaration.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[flang] Fuse chained character concatenations into one buffer
Lowering creates one binary hlfir.concat per // operator, so a // b // c
was evaluated into an intermediate buffer that was then copied into the
result buffer. Add a canonicalization that folds a single-use hlfir.concat
into its user when no operation in between may modify or release its
operands, and bufferize hlfir.concat with any number of operands. The
buffer is now sized with the hlfir.concat length operand, which can be
computed outside of elemental loops, instead of the sum of the operand
lengths computed in the loop body.
[flang] Address review comments on chained concatenation fusion
Let concatenation fusion cross operations that only allocate, like the
hlfir.declare of a character literal operand, so that chains ending with a
literal are fused into one buffer. Only operations that may write or free
memory, or whose effects are unknown, now prevent the fusion.
Remove CharacterExprHelper::createConcatenate, which no longer has users.
Add bufferization tests for concatenations whose operands all have a
compile-time length, and for character kind 4.
[ThinLTO] Run LowerTypeTests after indirect call promotion (#241582)
In ThinLTO backends, `LowerTypeTestsPass` ran before
`SampleProfileLoaderPass`
and `PGOIndirectCallPromotion`, renaming each CFI jump-table member
`foo` to
`foo.cfi` and leaving a `foo` declaration for the jump-table entry:
* `SampleProfileLoader` canonicalizes `foo.cfi` to `foo`, colliding with
the
`foo` declaration in `SymbolMap` and skipping sample annotation and ICP.
* Running ICP first lets it promote calls to `foo` under its original
name;
`LowerTypeTestsPass` then keeps direct calls to `foo.cfi` and redirects
the
promoted pointer comparison to `foo`.
Move `LowerTypeTestsPass` after ICP in
`buildModuleSimplificationPipeline`,
[4 lines not shown]
[ObjCARC] Treat objc_claimAutoreleasedReturnValue as RetainRV (#241436)
In spite of the names, claimRV really has much more in common with
retainRV than with unsafeClaimRV. Semantically claimRV is just retainRV
without the marker nop.
Currently GetFunctionClass doesn't handle claimRV at all, and it
defaults to CallOrUser. In well-behaved pass pipelines this omission
shouldn't be observable, but in the face of unusual pass ordering we
could have e.g. a situation where inlining happens after contraction,
and then the inliner gets confused and sends the claimRV down the
unsafeClaimRV +0 path, resulting in an over-release.
As a hardening against such situations, this patch classifies claimRV as
kind RetainRV. The additional changes in InlineFunction.cpp are just NFC
clarifications. Some of its mentions of "claimRV" are a bit too loose
when they actually mean unsafeClaimRV specifically.
Assisted-by: claude
rdar://191370661
[libc] Add CLOCK_TAI (#241692)
`CLOCK_TAI` is the kernel's clock for International Atomic Time, number
11. It was missing from the Linux time macros
AI disclosure: this patch was written with Claude Code. I reviewed the
change and built and ran the new test in a full build; it does not build
without the change
Assisted-by: Claude