[mlir] Add LabelLike trait for blocks entered without a CFG edge
Some ops mark a block that control enters through a jump the CFG does
not show yet. ClangIR's cir.label is the target of cir.goto, which may
leave a region and only becomes a branch once the CFG is flattened.
Such a block often has no predecessors, so eraseUnreachableBlocks
deletes it and the greedy driver skips its ops.
This adds OpTrait::LabelLike for an op that starts a non-entry block,
and findLabelEntry, which returns the op where control enters a block
through a label. That is either the label itself or an op whose regions
contain one, unless that op, or one between it and the label, is
isolated from above.
eraseUnreachableBlocks keeps these blocks, the blocks they reach and the
blocks whose values they use. Region DCE treats every remaining block as
live, and cf.br does not merge a labeled block into its predecessor.
GreedyRewriteConfig::enableRewritingAfterLabels, off by default, lets
[7 lines not shown]
[mlir][bufferization] Do not hoist copying allocations to out-params (#242630)
With `hoist-static-allocs` enabled, `-buffer-results-to-out-params`
replaces returned allocations with caller-provided output buffers and
erases their defining operations. Checking only `AllocationOpInterface`
also matches `memref.realloc` and `bufferization.clone`, whose results
preserve or reproduce existing data. Erasing these operations loses that
data and leaves the output buffer partially or entirely uninitialized.
Require `getHoistingKind() != HoistingKind::None` before replacing an
allocation. `memref.realloc` (`None` since #231608) and
`bufferization.clone` (`None` by default) are retained. For the static
results in #242611, the pass copies their contents into the output
parameters through the existing fallback path. `memref.alloc` remains
eligible for replacement.
The check remains interface-based, preserving support for custom
allocation operations introduced in #120288. Such operations remain
eligible when they report a non-None hoisting kind.
[12 lines not shown]
[lld/mac] Claim per-file work one item at a time (#242765)
This ports #240094 to lld/MachO.
Relocation processing in lld/MachO doesn't need an index, so this can
use parallelForFineGrained instead of parallelForSharded() in lld/ELF.
Linking Chromium Framework on an M4 Max (time trace scopes, median of
7):
Parse relocations: 115 ms -> 75 ms
Apply linker optimization hints: 36 ms -> 22 ms
Total link (hyperfine, median of 15): 3.911 s -> 3.859 s
No behavior change.
[mlir][docs] Add guidance on "non observable" side effect modeling (#242620)
Mention that a dialect defines which aspects of execution are observable
and which are
implementation details outside that semantic model. Also add a few
examples.
Discussion:
https://discourse.llvm.org/t/guidance-on-not-observable-side-effect-modeling/92790
Assisted-by: Codex
[VPlan] Build SCEV of VPDerivedIVRecipe like its expansion (NFC). (#242804)
Compute the SCEV of a VPDerivedIVRecipe as Start + zext-or-trunc(Index)
* Step, matching expandVPDerivedIV. Previously Start and Step were
truncated or sign-extended to the type of Index, so the SCEV had Index's
type rather than the recipe's, and VPScalarIVStepsRecipe truncated it
back. Remove that truncate.
All derived IVs queried today have an Index at least as wide as Start,
where both forms fold to the same SCEV.
[ConstantFolding] Use the pointer width for ptrtoint of inttoptr (#237878)
Previously, folding `ptrtoint (inttoptr C)` truncated C to the address
width and dropped the non-address bits; use the pointer width instead.
Fixes #235642.
Assisted-by: Claude Opus 5.5
Revert "[Hexagon] Test lowering of Clang HLX vector pair locals at -O0 (#242403) (#242803)
This reverts commit 351abdb04162065e75b007840aaf20ec7ac99a2b.
The tests fail in release builds because the values are unnamed.
[mlir][acc] Add the #acc.offload_packager offloading handler
Add an offloading handler attribute for gpu.module and gpu.binary that
is meant to embed the device images in the host object as LLVM offloading
binaries of kind OpenACC, for the offloading linker wrapper to link and
register with the OpenACC runtime.
Assisted-by: Claude Sonnet 5.5
[mlir][acc] Translate the acc.offload_entry attribute to an offloading entry
Add the acc.offload_entry unit attribute, which marks a global host symbol
(either a function or a global variable) that the offload runtime must be able
to associate with its device counterpart. The translation emits entries that
are registered with the OpenACC runtime libacctarget.
Assisted-by: Claude Sonnet 5.5
[mlir][acc] Translate #acc.offload_packager to LLVM IR
Add a translation library for the OpenACC dialect that implements the
offloading translation interface of #acc.offload_packager. Each object
of a gpu.binary is wrapped in an offloading binary of kind OpenACC,
carrying the target triple and architecture, and the images are placed
in the .llvm.offloading section of the host module for the offloading
linker wrapper to extract.
Assisted-by: Claude Sonnet 5.5
[CIR] Make cir-canonicalize a full canonicalizer
cir-canonicalize applied the CIR canonicalization patterns and folders
only to a hand-written list of operations. It now builds the pattern set
once in initialize() and runs the greedy driver over every operation, so
every pattern and folder applies everywhere. Only operations that
rewriting left dead are erased, such as the inputs of a folded
operation: CIR stays close to the source, so unused locals and ignored
expressions are kept as in classic codegen. Empty scopes and switches
were removed only because they were dead, so they get explicit
canonicalization patterns.
The pass uses the multi-op driver because the region driver always
erases blocks without a CFG predecessor, and a block that starts with
cir.label is reached only through cir.goto until the goto solver runs.
Region simplification stays off for the same reason. The new
test-convergence option fails the pass when the driver does not reach a
fixpoint, as in the upstream canonicalizer.
Assisted-by: Claude Code (claude-opus-5-5).
[mlir] Add a dead code elimination mode to the greedy rewriter
The greedy pattern rewrite driver always erases trivially dead
operations, so a client that wants canonicalization patterns and
folders without dead code elimination has no way to get it. Add
GreedyRewriteConfig::setDeadCodeElimination and the matching
dead-code-elimination option of the canonicalizer pass, with three
modes:
- all, the default, erases every trivially dead operation as before.
- newly-dead erases an operation only once the erasure or replacement
of another operation drops its last use, so the inputs that a fold
leaves unused go away while operations that were dead before
rewriting are kept.
- disabled erases an operation only by a pattern or by folding.
Region simplification is separate and still removes dead values unless
it is disabled too. The deadness cache skips invalidation while it is
empty, so a run that never queries it pays nothing for its tracking.
[2 lines not shown]