Skip to content

[REFACTOR][EXTRA] Add TVM_FFI_S_VISIT_RETURN_NONE for visit hook tails - #753

Merged
tqchen merged 1 commit into
apache:mainfrom
tqchen:visit-return-none
Sep 6, 2026
Merged

[REFACTOR][EXTRA] Add TVM_FFI_S_VISIT_RETURN_NONE for visit hook tails#753
tqchen merged 1 commit into
apache:mainfrom
tqchen:visit-return-none

Conversation

@tqchen

@tqchen tqchen commented Sep 6, 2026

Copy link
Copy Markdown
Member

A visit hook ends by returning "no interrupt", which every hook currently spells
out by hand:

return ExpectedUnsafe::MoveToTVMFFIAny(Expected<Optional<VisitInterrupt>>(std::nullopt));

That puts the Expected storage representation into every hook body, including
downstream ones outside this repository, where it would keep compiling if the
representation ever changed.

TVM_FFI_S_VISIT_MAYBE_EARLY_RETURN already owns the other half of this ABI
boundary; the tail was the only part still written by hand. This adds the
terminal counterpart, going through the same MaybeReturnHelper proxy so it
works from a raw TVMFFIAny hook and a typed helper alike, adopts it in the
container hooks, and documents the canonical hook shape once beside the macro
pair.

A visit hook ends by returning "no interrupt", which every hook spells out
by hand as MoveToTVMFFIAny(Expected<Optional<VisitInterrupt>>(std::nullopt)).
That puts the Expected storage representation in every hook body, including
downstream ones outside this repository.

Add the terminal counterpart to TVM_FFI_S_VISIT_MAYBE_EARLY_RETURN, going
through the same MaybeReturnHelper proxy so it works from a raw TVMFFIAny hook
and a typed helper alike. Adopt it in the container hooks, and document both
visit macros with the canonical hook shape, matching how
TVM_FFI_S_MUTATE_ASSIGN_OR_RETURN is already documented.
@tqchen
tqchen merged commit 1279f63 into apache:main Sep 6, 2026
9 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