Skip to content

[FIX][Relax] Preserve closure-referenced private functions - #20738

Open
Yuhx141 wants to merge 2 commits into
apache:mainfrom
Yuhx141:yuhx/fix-relax-closure-references-20261015
Open

Yuhx141 wants to merge 2 commits into
apache:mainfrom
Yuhx141:yuhx/fix-relax-closure-references-20261015

Conversation

@Yuhx141

@Yuhx141 Yuhx141 commented Oct 15, 2026

Copy link
Copy Markdown

Private functions passed to make_closure still need their original definitions and call signatures. These passes previously updated direct calls only and could remove or replace a function while leaving its closure reference behind.

  • retain value-referenced functions in InlinePrivateFunctions;
  • retain their tuple parameter signatures in ExpandTupleArguments;
  • retain their original parameters and GlobalVar identity in RemoveUnusedParameters.

The three passes share a small internal reference collector. Functions used only by direct calls remain eligible for the existing optimizations.

Closes #20593
Closes #20653
Closes #20654

Tests:

  • All three added closure regressions fail on unmodified main.
  • pytest tests/python/relax/test_transform_inline_private_functions.py tests/python/relax/test_transform_expand_tuple_args.py tests/python/relax/test_transform_remove_unused_parameters.py -q: 12 passed, including the existing direct-call and recursion controls.
  • Release/LLVM build completed for the three modified C++ passes.
  • Pre-commit passed on all seven PR files.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant