[asm] Allow RawOp to reserve registers from regalloc#1156
Closed
Hardcode84 wants to merge 4 commits intoiree-org:mainfrom
Closed
[asm] Allow RawOp to reserve registers from regalloc#1156Hardcode84 wants to merge 4 commits intoiree-org:mainfrom
Hardcode84 wants to merge 4 commits intoiree-org:mainfrom
Conversation
d01c315 to
7a488d2
Compare
RawOp embeds physical register names as opaque text, invisible to SSA-based liveness. When PrecoloredSRegOps are DCE'd (they have [Pure] and no SSA users), the allocator loses track of those registers and may assign them to loop iter_args, corrupting SRDs at runtime. Instead of parsing raw assembly text with regex in the allocator, add sreg_reads/vreg_reads/areg_reads optional DenseI64ArrayAttr attributes to RawOp so creation sites can declare which physical registers they read. The linear-scan pass now reserves registers from these attributes directly. Made-with: Cursor Signed-off-by: Ivan Butygin <ivan.butygin@gmail.com>
- Rename sreg_reads/vreg_reads/areg_reads to sreg_uses/vreg_uses/areg_uses
for generality (covers both reads and writes of physical registers).
- Replace two OpBuilders with a single one taking ArrayRef<int64_t> with
default = {} for all three register sets, eliminating DenseI64ArrayAttr
boilerplate and sregAttr lambdas at call sites.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Ivan Butygin <ivan.butygin@gmail.com>
- Dialect roundtrip test: verifies sreg_uses, vreg_uses, areg_uses parse and print correctly, including combinations and omission. - Regalloc test: verifies the linear-scan allocator reserves SGPRs declared in sreg_uses, forcing virtual registers to skip those positions. Includes baseline (no annotation) for comparison. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Ivan Butygin <ivan.butygin@gmail.com>
Remove the TODO and wire up vreg_uses/areg_uses reservation alongside the existing sreg_uses handling. All three register-use attributes now reserve their respective physical registers in the allocator. Add vreg_uses regalloc test cases alongside existing sreg_uses ones. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Ivan Butygin <ivan.butygin@gmail.com>
7a488d2 to
266d44c
Compare
Contributor
Author
|
Superseded by #1188 |
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.
RawOp embeds physical register names as opaque assembly text, invisible to SSA-based liveness. When PrecoloredSRegOps are DCE'd (they have
[Pure]and no SSA users), the allocator loses track of those registers and may assign them to loop iter_args, corrupting SRDs at runtime.This PR adds optional
sreg_uses/vreg_uses/areg_usesattributes towaveasm.rawso creation sites can declare which physical registers they reference. The linear-scan pass reserves registers from these attributes.Changes
sreg_uses/vreg_uses/areg_usesasOptionalAttr<DenseI64ArrayAttr>to RawOp with a convenienceArrayRef<int64_t>builder (empty = omitted).reservedSGPRs/reservedVGPRs/reservedAGPRssets before allocation.emitSRDPrologueandemitSRDBaseAdjustmentwhere physical register dependencies exist. Deliberately omit annotations on GFX950 preload-path RawOps where reservation would conflict with S_LOAD_DWORDX2 allocation (documented with comments).s_and_b32SRD word-1 fixup inhandleMakeBufferRsrc.handleFatRawBufferCast.