[AMDGPU][Scheduler] Fix non-monotonic SlotIndex after schedule revert (#192039)
modifyRegionSchedule restores the original instruction order by splicing
MIs before RegionEnd. When an MI is already at the expected position
(MII == RegionEnd) its SlotIndex was left unchanged, even though earlier
splices may have shifted neighboring indices. This could leave a stale,
lower-numbered slot on a non-moved MI, breaking SlotIndex monotonicity
and corrupting LiveIntervals.
The corruption surfaced as a "register isn't live" assertion in
GCNDownwardRPTracker when PreRARematStage's finalizeGCNSchedStage
globally reverted regions that were already locally reverted by
checkScheduling.
Fix by calling LIS->handleMove for non-moved MIs whose SlotIndex has
become non-monotonic (PrevIdx >= MI_Idx). Additionally, track whether
checkScheduling already reverted a region and skip the redundant global
revert in finalizeGCNSchedStage.
Assisted-by: Claude Opus
Reapply "[cmake] Add support for statically linking libxml2" (#192088)
This applies a fix for windows not discovering libxml
This reverts commit 2a9c32496b5e8e63844597f638bdf67e4732fd35.
[MLIR][Vector] Fix WarpOpScfForOp and WarpOpScfIfOp leaving invalid ops after region moves (#188951)
WarpOpScfForOp::matchAndRewrite called mergeBlocks() to move forOp's
body block into the inner WarpOp. mergeBlocks() erases the source block,
leaving forOp with an empty body region (0 blocks). Since scf.for
requires exactly 1 body block, IR verification fails with "region with 1
blocks" after the pattern succeeds. Additionally, when forOp had no init
args, the pattern was missing the scf.yield terminator in the new ForOp.
WarpOpScfIfOp::matchAndRewrite had the same issue: takeBody() emptied
the ifOp's then/else regions, leaving scf.if with 0 blocks.
Fix:
- Restore the conditional scf.yield creation (only when newForOp has
results).
- After merging/taking the regions, replace the remaining op's results
with ub.poison and erase the now-invalid op from the new WarpOp's body.
Assisted-by: Claude Code
Fix a failure present with MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS=ON.
[mlir][OpenMP] Fix teams reduction assert with sibling distributes (#191475)
Avoid double-mapping teams reduction block arguments when multiple
sibling `omp.distribute` ops appear under the same `omp.teams`.
Replace `teamsReductionContainedInDistribute` with
`getDistributeCapturingTeamsReduction`, which returns the unique
`omp::DistributeOp` containing all non-debug uses of the teams reduction
block arguments, or null if no such distribute exists. In that case,
reduction setup falls back to the teams op.
This ensures only the owning distribute handles reduction setup and
prevents `moduleTranslation.mapValue()` from being called multiple times
for the same block arguments.
Fixes https://github.com/llvm/llvm-project/issues/191470
Assisted with Copilot and GPT-5.4
[CIR][OpenMP] Add OpenMP-to-LLVM type conversion for CIR-to-LLVM lowering (#190063)
Register OpenMP conversion legality and patterns in the CIR-to-LLVM pass
so that OpenMP operations (e.g. omp.map.info, omp.target) have their CIR
types converted to LLVM types during lowering. Without this,
the conversion leaves behind unrealized_conversion_cast ops that cause
translation to LLVM IR to fail.
Also registers omp::PointerLikeType on cir::PointerType so that CIR
pointers are accepted as operands in OpenMP map operations.
Assised-by: Cursor / Claude Opus 4.6
[CIR] Handle full expression cleanups in conditional branches (#191479)
This adds CIR support for handling full expression cleanups in
conditional branches. Because CIR uses structured control flow, it was
necessary to handle these cleanups differently than is done in classic
codegen. CIR speculatively creates a cleanup scope when an
ExprWithCleanups contains a conditional operator and maintains a
dedicated stack of these deferred cleanups, which is added to the
cleanup scope at the end of the full expression with an active flag used
to control whether the cleanup should be executed based on any branches
that may have been taken during the conditional expression evaluation.
This is similar to the mechanism used for lifetime extended cleanups,
but the timing of when the cleanups are moved to the main EH stack is
different, so we need to maintain two different pending cleanup stacks.
We are able to use the same PendingCleanupEntry class for both.
Assisted-by: Cursor / claude-4.6-opus-high
[CIR] Handle irregular partial init destroy (#192158)
This implements CIR handling for the case where an array of a destructed
type is being initialized using an initializer list and therefore the
address of the last successfully constructed element must be loaded from
a temporary variable before the partial array destroy loop can begin.
In classic codegen this shares its implementation with the general array
ctor/dtor handling, but in CIR we have dedicated operations to abstract
array ctors/dtors, so the implementation of the irregular partial
destruction happens in a different place in codegen.
Assisted-by: Cursor / claude-4.6-opus-high
[SimplifyCFG] Reuse function comdat for switch lookup table (#190995)
Fixes #190994.
As the switch table is extracted from the function, the table should be
removed when the function is removed, and therefore inherits the comdat
of the function.
[ValueTracking][KnownFPClass] Cover known no-infinity cases for powi (#191736)
Teach `computeKnownFPClass` to infer non-infinity cass for `powi`.
Rules out `inf` for `powi(x, exp)` when:
- `x ?= inf` && `exp > 0`
- `x ?= +/-0` && `exp < 0`
- `x ?= finite` && `|exp| > 1`
- `x ?= subnormal` && `exp ?= -1` (special asym case after |exp| > 1)
where `?=` is maybe equal.
It's a bit conservative, and we could refine it further, but I'd take an
iterative improvement.
[OpenACC] Fix invalid routine case where 'bind' didn't exist (#192270)
For some reason I'd failed to check the result of `find_if` and just
assumed that the `bind` clause must exist! Looking through my other
tests, I've validated every other combination other than this one for
some reason.
Fixes: #192245
[Clang] Fix handling of overloads differing only by constraints and ref-qualifiers (#192018)
We should only error about inconsistent qualifiers if the functions are
actually overloads.
Fixes #120812
[llvm-jitlink] Hold Session::ObjLayer by unique_ptr. (#192253)
This will simplify the Session construction process when we remove
jitlink::JITLinkMemoryManager ownership from ExecutorProcessControl in
an upcoming patch.
(Reason: ObjectLinkingLayer's constructor will require a
JITLinkMemoryManager, which we'll want to cerate after the
ExecutionSession has been initialized. Creating a JITLinkMemoryManager
is generally a fallible operation, so we want to be able to bail on
construction of the ObjectLinkingLayer entirely if we can't create a
memory manager for it).
[lldb][Docs] Fix presentation of some default values (#192239)
There were two bugs with the display of default values:
1. If a default value contains a backtick, that would render
incorrectly. For example
[`disassembly-format`](https://lldb.llvm.org/use/settings.html#disassembly-format).
Fixed by doing the wrapping when we generate the Markdown instead of
when parsing the directive. MyST will already parse the content of the
directive as Markdown. We can escape backticks inside the string by
changing the fence. Markdown can take any number of backticks at the
start as long as they match the amount at the end
([spec](https://spec.commonmark.org/0.31.2/#code-spans)).
2. When the docs were built on Windows, UTF-8 was not correctly picked
up, because the default encoding isn't utf8 there.
[`separator`](https://lldb.llvm.org/use/settings.html#separator) was one
example (renders correctly on the Website but not on my machine).
[Clang] Diagnose `co_await` expressions in default arguments of nested functions (#191817)
co_await/co_yield expressions are not allowed in default arguments. We
were checking they do not appear outside of function contexts, which
include default arguments of the corresponding function, but it missed
default arguments of functions declared in the body of another
functions.
Because parsing default argument isn't done in a dedicated scope, we do
additional checks in `ActOnParamDefaultArgument`. Because the checks is
done in two places, we cannot introduce a more precise diagnostic.
It might be worth considering a parse scope for default arguments in the
future.
Fixes #98923
[LifetimeSafety] Propagate origins through explicit cast expressions (#192180)
Before this PR, `FactsGenerator` handled cast nodes with
`VisitImplicitCastExpr` (`CastKind` switch case) and
`VisitCXXFunctionalCastExpr` (handle`gsl::Pointer` types). Other
explicit casts (`CStyleCastExpr`, `CXXStaticCastExpr`, ...) had no
handler, so origin was silently dropped. This is the root cause of
#190912: the dangle in `a = StringView(s);` is missed even though the
equivalent `StringView tmp(s); a = tmp;` is reported.
The policy for "does this cast propagate origin?" is a function of
`CastKind`, independent of whether the cast is implicit or explicit.
This PR replaces `VisitImplicitCastExpr` with a generic `VisitCastExpr`.
`VisitCXXFunctionalCastExpr` is retained only to preserve the
`handleTestPoint` logic, then delegates to `VisitCastExpr`.
This mirrors `clang/lib/AST/ExprConstant.cpp`, where each evaluator
implements only `VisitCastExpr` and switches on `CastKind`; the few
ExprClass-specific overrides (e.g., `VisitCXXDynamicCastExpr`) exist
[4 lines not shown]