Skip to content

Store function signatures instead of FuncOp handles in functionMap (§2)#214

Merged
ASDAlexander77 merged 1 commit into
mainfrom
refactor/functionmap-deopify
Jul 12, 2026
Merged

Store function signatures instead of FuncOp handles in functionMap (§2)#214
ASDAlexander77 merged 1 commit into
mainfrom
refactor/functionmap-deopify

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Summary

Implements §2 from docs/MLIRGen-refactoring-review.md for NamespaceInfo::functionMap.

The map cached raw mlir_ts::FuncOp handles. Since #213 routed the discovery pass into a throwaway module, any handle registered during discovery is guaranteed to dangle once that module is erased — consumers survived only because they read the (MLIRContext-owned, always-safe) function type early. Now:

  • functionMap stores a FunctionEntry { symbol name (std::string — a StringRef would dangle with the op's attribute storage), mlir_ts::FunctionType }, which is everything any consumer actually used.
  • The one site that needs a live op — the generic-instantiation short-circuit in mlirGenFunctionLikeDeclaration — resolves it through theModule.lookupSymbol<mlir_ts::FuncOp> with a short-name → full-name fallback, so it returns an op from the current module rather than a possibly-stale cached handle.

Test plan

The full suite earned its keep here: the first full run caught a real regression — my initial short-circuit rewrite resolved by short name only, returning null where the original returned the cached (full-symbol) op, failing funcs-nesting-capture and any-generic-equals in both compile and JIT modes. The fallback fixed it.

  • Final run: 683/683 ctest tests passed (152 s, -j8) — full AOT + JIT + unittests
  • The four previously failed tests pass individually as well

🤖 Generated with Claude Code

…eview doc 2)

NamespaceInfo::functionMap cached raw mlir_ts::FuncOp handles; since
the discovery pass emits into a throwaway module (#213), any handle
registered during discovery is guaranteed to dangle once the module is
erased - consumers survived only because they read the (context-owned)
type early. The map now stores FunctionEntry { symbol name, function
type }, which is all any consumer used; the one site that needs a live
op (generic-instantiation short-circuit) resolves it through
theModule.lookupSymbol with a short/full-name fallback.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ASDAlexander77 ASDAlexander77 merged commit 3dea895 into main Jul 12, 2026
2 checks passed
@ASDAlexander77 ASDAlexander77 deleted the refactor/functionmap-deopify branch July 12, 2026 18:42
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