Skip to content

[Relax] Exclude R.null_value()-bound vars from KillAfterLastUse - #20267

Open
cchung100m wants to merge 2 commits into
apache:mainfrom
cchung100m:issue-20200
Open

[Relax] Exclude R.null_value()-bound vars from KillAfterLastUse#20267
cchung100m wants to merge 2 commits into
apache:mainfrom
cchung100m:issue-20200

Conversation

@cchung100m

Copy link
Copy Markdown
Contributor

Hi Committers,

This PR addresses issue #20200. Any suggestions would be appreciated if you are available.

Root Cause

KillAfterLastUse decides whether a variable is a legal R.vm.kill_object target via stored_in_vm_register, which only excludes constants and FuncType/ShapeType/PrimType vars. A variable bound to R.null_value() has type AnyType - not in that exclusion list - so the pass wrongly treats it as killable. But both CodeGenVM and CodeGenVMTIR special-case null_value to bypass real VM register/anylist-slot allocation entirely. In CodeGenVMTIR, this mismatch hits an ICHECK requiring the kill target to resolve to an anylist_getitem() call, causing a hard crash (CodeGenVM's bytecode backend happens to swallow it silently via a sentinel "void register," which is why only exec_mode="compiled" crashes).

Solution

Track variables bound to relax.null_value in CollectLastUsage (mirroring the existing constant_tensors_ pattern) and add them to the stored_in_vm_register exclusion, so the pass never emits a kill for them - closing the gap at its sources rather than patching either codegen.

@cchung100m
cchung100m marked this pull request as ready for review September 4, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant