[Comgr][hotswap] Add the per-kernel raise context - #3720
Open
ftynse wants to merge 19 commits into
Open
Conversation
tgymnich
reviewed
Aug 3, 2026
tgymnich
reviewed
Aug 3, 2026
ftynse
force-pushed
the
users/ftynse/hotswap-m0-07-layouts
branch
from
August 5, 2026 11:38
6816886 to
6ce2386
Compare
ftynse
force-pushed
the
users/ftynse/hotswap-m0-08-raise-context
branch
from
August 5, 2026 11:38
a785ba6 to
0fa8ddd
Compare
ftynse
force-pushed
the
users/ftynse/hotswap-m0-07-layouts
branch
from
August 5, 2026 11:50
6ce2386 to
c42e041
Compare
ftynse
force-pushed
the
users/ftynse/hotswap-m0-08-raise-context
branch
from
August 5, 2026 11:50
0fa8ddd to
3217ab9
Compare
ftynse
force-pushed
the
users/ftynse/hotswap-m0-07-layouts
branch
from
August 5, 2026 11:59
c42e041 to
b21056a
Compare
ftynse
force-pushed
the
users/ftynse/hotswap-m0-08-raise-context
branch
from
August 5, 2026 11:59
3217ab9 to
676c32c
Compare
ftynse
force-pushed
the
users/ftynse/hotswap-m0-07-layouts
branch
from
August 7, 2026 10:48
b21056a to
90971ab
Compare
ftynse
force-pushed
the
users/ftynse/hotswap-m0-08-raise-context
branch
from
August 7, 2026 10:48
676c32c to
a993586
Compare
ftynse
force-pushed
the
users/ftynse/hotswap-m0-07-layouts
branch
2 times, most recently
from
August 7, 2026 12:25
c8352b4 to
c6116b3
Compare
ftynse
force-pushed
the
users/ftynse/hotswap-m0-08-raise-context
branch
from
August 7, 2026 12:57
a993586 to
fbe45f3
Compare
martin-luecke
force-pushed
the
users/ftynse/hotswap-m0-07-layouts
branch
4 times, most recently
from
August 11, 2026 12:38
2e60b1a to
4c78c4f
Compare
martin-luecke
force-pushed
the
users/ftynse/hotswap-m0-08-raise-context
branch
from
August 11, 2026 13:53
fbe45f3 to
1bd626d
Compare
martin-luecke
force-pushed
the
users/ftynse/hotswap-m0-07-layouts
branch
from
August 11, 2026 18:08
4c78c4f to
6497687
Compare
martin-luecke
force-pushed
the
users/ftynse/hotswap-m0-08-raise-context
branch
from
August 11, 2026 18:09
037b1a8 to
fa275f9
Compare
Base automatically changed from
users/ftynse/hotswap-m0-07-layouts
to
amd-staging
August 11, 2026 23:22
martin-luecke
force-pushed
the
users/ftynse/hotswap-m0-08-raise-context
branch
from
August 12, 2026 06:34
fa275f9 to
fde1246
Compare
martin-luecke
changed the base branch from
amd-staging
to
users/ftynse/hotswap-m0-05-dylib-amdgpu-utils
August 12, 2026 06:34
martin-luecke
force-pushed
the
users/ftynse/hotswap-m0-08-raise-context
branch
from
August 12, 2026 09:12
fde1246 to
bda8042
Compare
martin-luecke
changed the base branch from
users/ftynse/hotswap-m0-05-dylib-amdgpu-utils
to
users/mluecke/hotswap-reject-dylib-linkage
August 12, 2026 09:14
martin-luecke
force-pushed
the
users/ftynse/hotswap-m0-08-raise-context
branch
from
August 13, 2026 12:25
d789b8b to
5e116f5
Compare
An error occurred while trying to automatically change base from
users/mluecke/hotswap-reject-dylib-linkage
to
amd-staging
August 13, 2026 12:55
martin-luecke
changed the base branch from
users/mluecke/hotswap-reject-dylib-linkage
to
amd-staging
August 13, 2026 13:52
martin-luecke
force-pushed
the
users/ftynse/hotswap-m0-08-raise-context
branch
2 times, most recently
from
August 13, 2026 14:12
3cbaedf to
a081014
Compare
martin-luecke
enabled auto-merge (squash)
August 13, 2026 14:41
Teach llvm_add_library to preserve both the monolithic LLVM and component-library interfaces when LLVM is configured to link the dylib. A final consumer target property can select the component interface without changing the producer-wide default. Use this interface for COMGR_STATIC_LLVM and capture COMGR's effective LLVM and Clang linkage before repeated package discovery. This lets the shared COMGR library embed its complete LLVM, Clang, and LLD closure while normal consumers continue using the configured dylibs. This addresses #2927.
RaiseContext is the mutable state threaded through every instruction handler: the IRBuilder and module, the register file, the wave projection, the MC state, the decoded block-to-BasicBlock map, and the operand resolver that turns a decoded operand into an SSA value or a register write. It ties together the register file, projection, and layouts from the preceding patches into the single object the handlers operate on. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Use optional and unsigned types for register indices, consistently name the MC state, and append SmallVector ranges directly. This removes sentinel values and redundant casts without changing behavior.
The IRBuilder provides the LLVMContext and canonical scalar types, while the per-kernel function identifies its module. Drop the duplicated fields and derive these values at their use sites.
Use an i32 input so the half-write test exercises wave-mask decoding instead of the per-lane i1 shortcut.
Treat XNACK mask operands as unsupported instead of silently mapping them to zero, and make unknown register classification propagate a structured refusal. Null-register writes remain explicit discard operations. Size VGPR bank adjustments from the decoded instruction and descriptor rather than a fixed operand limit. Assert decoded operand-shape invariants and cover the new refusal and discard paths directly.
Make RaiseContext update its EXEC cache, SGPR shadows and provenance, and M0 constant state as part of each handler-visible register write. Entry initialization can continue using direct AllocaRegFile stores without installing mutable callbacks. This removes the register-file callback hooks and covers the coupled state changes through the normal RaiseContext write path.
Obtain the source and target ISA from the wave projection, require the descriptor-derived user-SGPR layout by reference, and drop the unused kernel and lane-cache block fields. Use the provenance map itself to identify precomputed block state, and leave the handler result type for the handler-dispatch patch that first consumes it.
Reject unsupported architectural registers while parsing both source and destination operands, and invalidate every SGPR shadow touched by an EXEC-width write. Trust the AMDGPU operand tables to identify instructions affected by VGPR-MSB state instead of duplicating their classification.
The AMDGPU operand-role table is authoritative for whether an instruction uses S_SET_VGPR_MSB state. Treat malformed table entries as compiler invariants and remove the unused recoverable-error path.
AMDGPU subregister indices include composite ranges and cannot be counted as consecutive dword lanes. Query the active hardware-mode operand register class instead, and refuse decoded registers that the class does not accept. Add focused coverage for an eight-dword scalar destination, mismatched register classes, and both null-register sink halves.
Preserve kernarg offsets across unrelated loads and keep source-wave shadow validity unchanged for inactive waves. Make RaiseContext own its per-SGPR shadow storage and report AMDGPU encoding formats through structured failures. Add focused coverage for each behavior.
Project VCC, EXEC, and zero-predicate reads to the current source wave when the target mask is wider. Keep SGPR shadow pair width in the alloca-backed state so a high-half write invalidates stale pair masks after a block boundary. Add focused coverage for distinct widened mask halves and cross-block pair invalidation.
martin-luecke
changed the base branch from
amd-staging
to
users/mluecke/comgr-static-closure-2927
August 14, 2026 10:25
auto-merge was automatically disabled
August 14, 2026 10:25
Invalid email address
martin-luecke
force-pushed
the
users/ftynse/hotswap-m0-08-raise-context
branch
from
August 14, 2026 10:25
a081014 to
c178c32
Compare
martin-luecke
force-pushed
the
users/mluecke/comgr-static-closure-2927
branch
from
August 14, 2026 12:02
22249e4 to
2499e97
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add the per-kernel
RaiseContextused by upcoming instruction handlers for operand resolution, register access, wave projection, and kernel layout state.Register writes now keep EXEC caching, SGPR tracking, pointer provenance, and M0 tracking consistent. The change also handles the high and low halves of VCC and FLAT_SCR correctly and reports unsupported register operands.
Focused tests cover register mapping and state updates.
This PR is stacked on #3869. The following handler PR in this stack adds the production callers.