Skip to content

Fix LLVM builder leaks in T2C's cbeqz/cbnez/fuse12#723

Merged
jserv merged 1 commit intomasterfrom
fix-llvm-builder-leak
Mar 6, 2026
Merged

Fix LLVM builder leaks in T2C's cbeqz/cbnez/fuse12#723
jserv merged 1 commit intomasterfrom
fix-llvm-builder-leak

Conversation

@jserv
Copy link
Copy Markdown
Contributor

@jserv jserv commented Mar 6, 2026

The else branches in cbeqz, cbnez, and fuse12 handlers create LLVMBuilderRef objects that are used to emit RetVoid but never disposed, leaking heap-allocated LLVM objects per T2C compilation.

This adds LLVMDisposeBuilder() in each else branch, matching the pattern already used by the BRANCH_FUNC macro. Also add t2c_check_valid_blk() guard to cbeqz/cbnez branch conditions to prevent chaining to evicted or invalid blocks, aligning with BRANCH_FUNC and fuse12.

Close #722


Summary by cubic

Fixes LLVMBuilderRef leaks in T2C’s cbeqz/cbnez/fuse12 and adds a guard to avoid chaining to invalid blocks. This reduces per-compile heap growth and aligns behavior with BRANCH_FUNC.

  • Bug Fixes
    • Dispose LLVM builders after emitting RetVoid in else paths for cbeqz, cbnez, and fuse12 (LLVMDisposeBuilder).
    • Gate branch_taken/untaken in cbeqz/cbnez with t2c_check_valid_blk to prevent chaining to evicted/invalid blocks, matching BRANCH_FUNC.

Written for commit 7cd4602. Summary will update on new commits.

The else branches in cbeqz, cbnez, and fuse12 handlers create
LLVMBuilderRef objects that are used to emit RetVoid but never
disposed, leaking heap-allocated LLVM objects per T2C compilation.

This adds LLVMDisposeBuilder() in each else branch, matching the pattern
already used by the BRANCH_FUNC macro. Also add t2c_check_valid_blk()
guard to cbeqz/cbnez branch conditions to prevent chaining to evicted or
invalid blocks, aligning with BRANCH_FUNC and fuse12.

Close #722
@jserv jserv added this to the release-2026.2 milestone Mar 6, 2026
cubic-dev-ai[bot]

This comment was marked as resolved.

@jserv jserv merged commit 6074815 into master Mar 6, 2026
46 of 47 checks passed
@jserv jserv deleted the fix-llvm-builder-leak branch March 6, 2026 16:23
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.

T2C: LLVM builder leak in cbeqz/cbnez/fuse12 else branches

1 participant