[Relax] Exclude R.null_value()-bound vars from KillAfterLastUse - #20267
Open
cchung100m wants to merge 2 commits into
Open
[Relax] Exclude R.null_value()-bound vars from KillAfterLastUse#20267cchung100m wants to merge 2 commits into
cchung100m wants to merge 2 commits into
Conversation
cchung100m
force-pushed
the
issue-20200
branch
from
September 4, 2026 16:14
f1df508 to
35c35be
Compare
cchung100m
marked this pull request as ready for review
September 4, 2026 16:33
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.
Hi Committers,
This PR addresses issue #20200. Any suggestions would be appreciated if you are available.
Root Cause
KillAfterLastUsedecides whether a variable is a legalR.vm.kill_objecttarget viastored_in_vm_register, which only excludes constants and FuncType/ShapeType/PrimType vars. A variable bound toR.null_value()has typeAnyType- not in that exclusion list - so the pass wrongly treats it as killable. But bothCodeGenVMandCodeGenVMTIRspecial-casenull_valueto bypass real VM register/anylist-slot allocation entirely. InCodeGenVMTIR, this mismatch hits anICHECKrequiring the kill target to resolve to ananylist_getitem()call, causing a hard crash (CodeGenVM's bytecode backend happens to swallow it silently via a sentinel "void register," which is why onlyexec_mode="compiled"crashes).Solution
Track variables bound to
relax.null_valueinCollectLastUsage(mirroring the existing constant_tensors_ pattern) and add them to thestored_in_vm_registerexclusion, so the pass never emits a kill for them - closing the gap at its sources rather than patching either codegen.