[libc++] Properly pass the LNT submission token to the submit workflow (#233010)
Reusable worklows don't automatically get their environment secrets
passed, they need to declare them and their callers to pass them
explicitly.
[SLP] Handle REVEC when costing expanded compress mask
With REVEC the scalars are vectors. The masked-load-compress shuffle that is
emitted uses the compress mask expanded to the elements of those vectors
(transformScalarShuffleIndiciesToVector), but the cost was computed with the
unexpanded per-vector mask, so a shuffle such as <24 x i8> -> <16 x i8> was
costed as a <2 x i8> shuffle. This made the compress sequence looked cheaper
than it is.
Assisted-By: Claude Sonnet 5.5
[mlir] Check greedy rewrite fingerprints and changed flag (#232576)
Under EXPENSIVE_CHECKS, compare operation fingerprints before and after
greedy rewriting. If the IR changes but the driver reports no change,
emit a fatal error.
Assisted-by: gpt 6.1 sol
[InstCombine] Canonicalize atomicrmw sub of a constant to add
Rewrite `atomicrmw sub ptr, C` as `atomicrmw add ptr, -C`. This
matches the canonical form InstCombine already uses for plain `sub`.
In wrapping arithmetic $old - C = old + (-C)$, so both the stored
value and the returned old value stay the same, including when C is
`INT_MIN`. Ordering, syncscope and metadata are kept.
```llvm
; before
%old = atomicrmw sub ptr %p, i32 1 syncscope("agent") monotonic
; after
%old = atomicrmw add ptr %p, i32 -1 syncscope("agent") monotonic
```
This benefits AMDGPU, for example: https://godbolt.org/z/39xsYro3o
[CIR] Skip record rebuilds for unchanging types in CXXABI lowering (#232880)
CIRABITypeConverter only rewrites data-member and method types, but it
did not override typeMayChange, so every named record converted to a
renamed copy and every op touching one was illegal, forcing the generic
pattern to rebuild them all. Override it to report only those two types
as possibly changing, letting records that reach neither convert to
themselves and stay legal.
Small gains across the more expensive selfhosting TUs (no CIR output
changes):
- Registry 36.7->35.8,
- ASTImporterTest 64.4->63.7,
- SLPVectorizer 93.6->91.9,
- OpenMPDecomp 39.5->38.1,
- SemaExpr 59.3->57.5.
[flang][OpenMP] Don't drop NOTHING with clauses in METADIRECTIVE
A METADIRECTIVE replacement of NOTHING was treated as having no
directive, even when it had clauses. A selected `nothing apply(...)` was
therefore lowered as a no-op, silently dropping the loop transformation.
Keep NOTHING as a replacement when it has clauses, and report it as not
yet implemented in lowering.
Assisted-by: GitHub Copilot (Claude Opus 5.5)
[TableGen] Mark Macro Fusion Features as Inline Ignore (#232889)
Tuning features are conventionally inline ignore -- you tune the whole
function according to the caller rather than merging caller/callee
tuning features.
Macro Fusion features are a kind of tuning feature, and until now were
marked InlineDefault - with this change they should be ignored and
therefore not prevent inlining.
Assisted-by: AI (for Tests)
[InstCombine] Add tests for atomicrmw sub of a constant. NFC
atomicrmw sub C can be canonicalized to atomicrmw add -C because both
produce the same stored and returned values under wrapping arithmetic.
Cover syncscope, INT_MIN, and negative cases.
[LoongArch] Extract FP vector element 0 as a subregister
Element 0 of an LSX/LASX floating-point vector is the aliased FPR, so
extractelement with index 0 needs no [x]vreplvei/xvpickve.
[flang] Set the target in bbc's semantics context
bbc created a target machine but never passed its triple and features to
the semantics context. Without a target triple, semantics treats device
and implementation context selectors as possibly matching, so it
checked METADIRECTIVE replacements that can never be selected for the
target. For example, bbc reported a COLLAPSE error for the SIMD
replacement of when(device={arch(nvptx64)}: simd collapse(2)) on
x86-64, while flang accepts it.
Set the semantics target triple and features from the target machine, as
the flang driver does.
Assisted-by: GitHub Copilot (Claude Opus 5.5)
[Option] Make Passes, Scalar, Instrumentation, and CGData options per-context (#232599)
Follow-up to #232365: drop `perContext = false` from PassesOptions,
ScalarOptions, InstrumentationOptions, and CGDataOptions.
* IR passes read their LLVMContext's options in run(). Legacy passes
that chose analyses from an option now always require them
(ConstantHoisting, StructurizeCFG, GVN).
* Pass parameters that an option overrides are combined in run(), so
-print-pipeline-passes no longer folds such options (e.g.
-bonus-inst-threshold) into the printed parameters.
* PipelineTuningOptions carries the library options to PassBuilder,
which falls back to the TargetMachine's. opt, clang, flang, and Polly
pass their module's.
* The CodeGenData singleton is configured by its first caller's context.
lld and llvm-cgdata pass an empty context, which reads the global
values their -mllvm sets.
LLM-aided
[flang][OpenMP] Match variant selectors in the source construct context
The construct context for METADIRECTIVE and DECLARE VARIANT came from
enclosing MLIR operations. It recognized only a few operations, followed
operation nesting instead of source nesting, kept constructs outside an
enclosing TARGET, and used the body context for clause expressions and
loop bounds.
Build the context from the evaluation's source ancestors and from frames
for construct regions entered during lowering:
- A selected METADIRECTIVE replacement stands in for its source construct.
- TARGET discards the outer context.
- Constructs without a selector property still add a nesting level.
- Clause expressions see only enclosing constructs.
- Loop bounds see the leaves that precede the first loop-associated leaf.
- Specification expressions see no construct.
Add llvm::omp::getConstructTraits, which returns the construct traits a
directive adds in source order, with an invalid placeholder for a
[14 lines not shown]
[CIR][Docs][www] Generate and publish the CIR dialect reference docs (#232912)
Wire up a consolidated CIR dialect reference page: the existing
-gen-dialect-doc output (operations, types, attributes, enums) plus a
passes section generated from Passes.td (-gen-pass-doc), merged ahead of
the other sections with an explicit index of the page sections.
The landing page grows a "CIR Dialect Reference" section right after
"Using ClangIR", showing an index into the reference page.
Also fix the doc tablegen include roots: the `MLIR_*_INCLUDE_DIR`
variables are still empty when Clang configures (MLIR configures later),
so derive the same roots from LLVM dirs instead; without this the
tablegen cannot find `mlir/*.td`.
[BoundsSafety] Don't orphan a shared counted_by node when one declarator nests it
A late-parsed counted_by-family attribute in declaration-specifier position is
shared by every declarator in the declaration, so they share one incomplete
CountAttributedType. When one declarator nests the node, as `*b` does in
`IP __counted_by(n) a, *b;`, it is rejected and the node is marked rejected.
The completion pass then skipped the node for every declarator, so `a` kept a
CountAttributedType without a count and crashed on use in
FieldDecl::findCountedByField.
Make the rejection apply to the declarator only. The parser checks and clears
the mark after each declarator, and doesn't pair a rejected declarator's field
with the attribute. The completion pass skips an attribute with no fields left,
still without parsing its argument.
Assisted-by: Opus 5.5
[BoundsSafety][test] Add late-parsed counted_by type-attribute coverage
New tests exercising the late-parse fill-in mechanism:
- Sema/attr-counted-by-weird-type-positions{,-late-parsed}.c: counted_by
in assorted type positions, nested pointers, and rejection cases.
- Sema/attr-bounds-safety-function-ptr-param.c: attributes on
function-pointer-typed members.
- Modules/ and PCH/ bounds-safety-attributed-type-late-parsed: the
resolved type round-trips through serialization.
- Sema/attr-counted-by-late-parsed-regressions.c: guards against the
double-free on a nested-record decl-spec attribute and the null-count
escape on a free-function parameter.
[BoundsSafety] Create incomplete counted_by types and wire up the refill
Activate late parsing for the counted_by family (counted_by / sized_by and
their _or_null variants) in type-attribute position, under
-fexperimental-late-parse-attributes, on top of the type-attribute handling,
the validation helper and the refill machinery added in the previous commits.
When such an attribute is seen during type construction and its argument
can't be resolved yet, build the CountAttributedType immediately with
getIncompleteCountAttributedType and record it against the enclosing record;
its count expression is filled in at the closing brace via the refill logic.
Because enclosing types refer to the node by pointer, completing it in place
leaves the type chain untouched.