Skip to content

[VM] Fix ref leak from incorrect MOVE bit on branch block args#23689

Merged
benvanik merged 1 commit intoiree-org:mainfrom
jtuyls:fix-vm-ref-move-liveness
Mar 9, 2026
Merged

[VM] Fix ref leak from incorrect MOVE bit on branch block args#23689
benvanik merged 1 commit intoiree-org:mainfrom
jtuyls:fix-vm-ref-move-liveness

Conversation

@jtuyls
Copy link
Copy Markdown
Contributor

@jtuyls jtuyls commented Mar 7, 2026

isLastRealValueUse checked uses in ALL other blocks when deciding MOVE vs retain for branch operands. Uses in predecessor/definition blocks (prior control-flow edges) incorrectly prevented MOVE, causing ref leaks: retain incremented the ref count but no discard existed on the taken path to release it.

Fix: only check uses in immediate successor blocks. Add a conservative guard for values that flow through a successor (liveIn && liveOut) to catch transitive escapes.

isLastRealValueUse checked uses in ALL other blocks when deciding
MOVE vs retain for branch operands. Uses in predecessor/definition
blocks (prior control-flow edges) incorrectly prevented MOVE, causing
ref leaks: retain incremented the ref count but no discard existed on
the taken path to release it.

Fix: only check uses in immediate successor blocks. Add a
conservative guard for values that flow through a successor
(liveIn && liveOut) to catch transitive escapes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Jorn <jorn.tuyls@gmail.com>
@jtuyls jtuyls requested a review from benvanik as a code owner March 7, 2026 16:06
@benvanik benvanik merged commit ed0d4f4 into iree-org:main Mar 9, 2026
55 of 57 checks passed
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.

2 participants