Skip to content

add static_assert to clang HALO functions to prevent silent HALO failure - #270

Merged
tzcnt merged 2 commits into
mainfrom
fork_clang_halo
Jul 14, 2026
Merged

tzcnt merged 2 commits into
mainfrom
fork_clang_halo

Conversation

@tzcnt

@tzcnt tzcnt commented Jul 14, 2026 •

Copy link
Copy Markdown
Owner

Motivating example, which previously would compile, but HALO doesn't work - a task wrapper is generated internally which causes an allocation. This is most relevant in the "join streams" usage of mux, where an awaitable is being re-forked into the same slot repeatedly.

co_await mux.fork_clang<0>(q.pull()); // secretly allocates a wrapper task

Now there is a static_assert that detects when the wrapper would be created internally, and directs you to use the newly added tmc::as_task wrapper function at the call site instead. Since this wrapper is created externally, it can be HALO'd.

co_await q.pull(); // 0 allocations
mux.fork<0>(q.pull()); // 1 allocation
co_await mux.fork_clang<0>(q.pull()); // 1 allocation, user wanted HALO - no longer compiles
co_await mux.fork_clang<0>(tmc::as_task(q.pull())); // 0 allocations

Note that this static_assert only fires then the awaitable mode is actually WRAPPER. In other cases, no wrapper is needed for allocation-free operation.

@tzcnt
tzcnt merged commit 72f4eb3 into main Jul 14, 2026
56 checks passed
@tzcnt
tzcnt deleted the fork_clang_halo branch July 14, 2026 01:03
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