Share construct contexts for variant reachability
Use AppendDirectiveContextTraits when building reachable directive paths
so semantic checks and lowering apply the same construct-context rules.
This excludes informational directives such as ASSUME while retaining
executable loop transformations and the source order of combined constructs.
Make AppendConstructTraitsForDirective private again and add semantic
tests for TILE, UNROLL, ASSUME, and TEAMS DISTRIBUTE PARALLEL DO. These
complement the existing lowering tests. The ASSUME case detects the old
collector counting an extra position and skipping a required diagnostic.
[RISC-V] Update streamer ArchString in emitTargetFeaturePush()
Previously, RISCVAsmPrinter::emitTargetFeaturePush() only emitted `.option push`
and `.option arch` without updating the streamer's active ArchString. When
emitting an ELF object file directly (`-filetype=obj`),
RISCVTargetELFStreamer::emitDirectiveOptionArch() is a no-op while
emitTargetFeaturePop() resets ArchString back to the pushed ArchString, so
module-level inline assembly and functions with custom `target-features` failed
to emit updated `$x<arch>` mapping symbols.
Call RTS.setArchString() with the parsed ISA string in emitTargetFeaturePush()
so `-filetype=obj` records the active `$x<arch>` mapping symbol alongside
`.option arch`.
This commit was created with the help of AI tools
[LTO] Preserve module inline asm target properties for .lto_discard and symvers
Previously, LTO::addRegularLTO() and IRLinker::run() called
prependModuleInlineAsm() and appendModuleInlineAsm() with a plain string when
synthesizing `.lto_discard` and imported `.symver` directives, creating a new
GlobalAsmFragment with empty TargetCPU and TargetFeatures instead of preserving
the existing module inline asm's properties. Copy the front fragment's Props so
these synthesized directives are merged into the module's inline asm with the
same target features.
This commit was created with the help of AI tools
[AMDGPU] Constant folding for wave-reduce intrinsics (#212755)
Relates to: https://github.com/llvm/llvm-project/pull/193142
A missed optimization opportunity.
While most constants to `add`, `sub` and `xor` wave reductions
cannot be folded, some identity constants(0, 1) can do with
some special handling.
[orc-rt] Add ConnectionSpec, a connection-string parser (#225304)
Parses the string a process is given to describe the connection it
should establish with its peer:
<transport>[:<action>]=<descriptor>
Checking is punctuation only: the transport and action are opaque tokens
and the descriptor's syntax belongs to the transport, so a spec parses
without knowing which transports this process was built with.
The grammar is LLVM's (#225075), so the same vocabulary reaches an
orc-rt executor and an LLVM controller. A registry mapping transports to
the connectors that implement them will be added in a follow-up commit.
Share construct contexts for variant reachability
Use AppendDirectiveContextTraits when building reachable directive paths
so semantic checks and lowering apply the same construct-context rules.
This excludes informational directives such as ASSUME while retaining
executable loop transformations and the source order of combined constructs.
Make AppendConstructTraitsForDirective private again and add semantic
tests for TILE, UNROLL, ASSUME, and TEAMS DISTRIBUTE PARALLEL DO. These
complement the existing lowering tests. The ASSUME case detects the old
collector counting an extra position and skipping a required diagnostic.
Preserve OpenMP variant ranking and reachability
Incorrect scores and premature candidate rejection can change lowering
selection or suppress required metadirective loop diagnostics.
Preserve full score values and context-dependent device weights, retain
paths distinguished by those weights, and let runtime conditions satisfy
match_any despite unknown static properties.
Count all enclosing leaves in reachable paths
Reachability must use the same construct positions and depth as lowering
when ranking metadirective replacements. Count source constructs without
selector traits, including leaves of combined directives, while keeping
NOTHING transparent.
Add regressions for actual and dynamically selected TASK regions and
DISTRIBUTE within TEAMS DISTRIBUTE PARALLEL DO.
Reject negative trait scores during metadirective recovery
Reachability analysis can rank candidates before CheckTraitScore diagnoses
invalid scores. A score of -1 wraps the initial unsigned score to zero,
causing selection to dereference a null best candidate.
Treat negative scores as absent during recovery while preserving the
existing diagnostic.
Preserve reachable metadirective variants across ranking and scopes
Incorrect candidate scores and stale scope boundaries can suppress required
loop diagnostics or let directives associate with loops outside their region.
Keep pending scopes consistent as directives are consumed, and preserve
candidate scores and highest-valued ordered matches when selecting and
merging reachable paths. Handle unknown properties without aborting ranking.
Fix extension matching and reachable path merging
Metadirective semantic checking relies on ranked selection to decide which
replacements need validation. With match_any and match_none, a selector can
remain applicable even when some construct traits are absent. The existing
matching and path-merging assumptions do not fully account for this, so
ranking can crash or discard a reachable replacement, allowing invalid loop
nests to pass unchecked.
Make applicability, scoring, and reachable-path merging agree on what these
matching extensions can observe. Preserve enough construct context to rank
partially matching selectors and distinguish paths whose nesting changes
the selected replacement. That context must also remain visible inside a
BLOCK associated with a selected directive, so nested metadirectives are
checked against the context in which they can execute.
Fix metadirective reachable path boundaries
Stop construct trait paths at the innermost target and retain the implicit
nothing fallback during unsupported-selector recovery.
Add coverage for actual and selected target boundaries and for nested
metadirectives reached through implicit fallback.
Respect target boundaries during OpenMP variant lowering
Stop collecting construct traits at the innermost TARGET so lowering
agrees with semantic analysis when selecting metadirective replacements
and DECLARE VARIANT callees.
Preserve metadirective selection semantics
Reachability checks can miss required loop diagnostics when selection
drops SIMD traits or treats NOTHING with APPLY as a no-op.
Preserve those distinctions in the shared selection plan so semantic
checks retain reachable transformations and lowering diagnoses
unsupported cases.
[flang][OpenMP] Track reachable metadirective replacement paths
The existing semantic checks can validate loop-associated directives in a
METADIRECTIVE against the following loop, but they do not model how the
METADIRECTIVE chooses among its replacements.
Today each WHEN is considered independently: if its selector can match, its
replacement is checked. Selection instead ranks all applicable candidates as
a set. An unguarded higher-ranked candidate makes lower-ranked candidates
unreachable, while a dynamically guarded candidate leaves them reachable
when its condition is false. Treating both cases alike can diagnose loop
requirements on a replacement that can never be selected.
The selected replacement can also affect later selection. Its directive
contributes to the construct context seen by a nested metadirective. The
checker currently retains only syntactic nesting, so nested construct
selectors cannot observe a directive selected by an enclosing
metadirective.
[44 lines not shown]
[SimpleLoopUnswitch] Allow trivial unswitch when exit LCSSA is a header PHI (#222962)
Trivial unswitch bails on a common loop shape: a loop-invariant branch
in the header that exits the loop returning a loop-carried value.
```
int acc = 0;
for (...) {
if (c)
return acc;
acc++;
}
```
After loop-rotate the `if` sits in the header, and the exit reads the
header PHI `%acc`. Trivial unswitch hoists the branch into the
preheader, so the exit value must be available there. It only accepts
loop-invariant values, and `%acc` is not one, so it gives up. But `%acc`
is safe here: the branch is invariant, so if the loop exits it exits on
[10 lines not shown]
[flang][cuda] Record implicit pinned attribution in module files
Under -gpu=mem:pinned an unattributed ALLOCATABLE is attributed as pinned by
the compiler, the same way -gpu=mem:managed attributes one as managed, but
only the latter recorded that it had done so. The module file therefore spelled
an implicitly applied PINNED the same as one the user wrote, and a reader
treated it as a user requirement: adding -gpu=mem:pinned to a module's build
rejected its OpenACC-only consumers over an attribute the user never wrote.
Record the attribution for pinned as well, so it is written as
PINNED(IMPLICIT) and consumers can tell the two apart.
[orc-rt] Fix unit test. (#225299)
Use !! to convert EPI to bool, and ExecutorProcessInfo::pageSize() to
get the page size (ExecutorProcessInfo::PageSize is private).
[libomp] OpenMP 6.0 Device-Scope Environment Variables (#197191)
The patch introduces `_ALL` `_DEV` `_DEV_<id>` env var suffixes to the
LLVM's OpenMP host runtime `libomp`. The eligible-list env var currently
supports `OMP_NUM_THREADS`.
Assisted by Claude Opus 4.7 / Claude 4.6 Sonnet