Stream: git-wasmtime

Topic: wasmtime / issue #1125 FunctionBuilder.cursor should not ...


view this post on Zulip Wasmtime GitHub notifications bot (May 21 2026 at 17:47):

cfallin closed issue #1125:

When FunctionBuilder.cursor() is called, it marks the current EBB as not pristine, even if it has no instructions. API users then have no way of distinguishing between an empty and non-empty block. This is compounded by API users not having any way to get the current block without using cursor.

The call chain for cursor looks like this: cursor -> ensure_inserted_ebb_block -> self.func_ctx.ebbs[ebb].pristine = false;

This is a particular concern for me while generating C case statements, my code looks like this:

    fn case(&mut self, switch: Switch, constexpr: u64, builder: &FunctionBuilder) {
        if builder.is_pristine() {
            let current = builder.cursor().current_ebb().unwrap();
            switch.set_entry(constexpr, current);
        } else {
            let new = builder.create_ebb();
            switch.set_entry(constexpr, new);
            self.switch_to_block(new, builder);
        };
    }

If I call case twice in a row, then I will make two different EBB blocks, even if the first was never filled.
As far as I can tell, there's nothing I can do from a user perspective to avoid this.
(this is why I was generating empty EBBs in https://github.com/CraneStation/cranelift/issues/1059)

view this post on Zulip Wasmtime GitHub notifications bot (May 21 2026 at 17:47):

cfallin commented on issue #1125:

We're doing old-issue triage. It looks like we now have block status tracked in cranelift-frontend and we set status to partial (not empty) only when instructions have been added. So I'll go ahead and close this issue. Thanks!


Last updated: Jun 01 2026 at 09:49 UTC