Stream: git-cranelift

Topic: cranelift / Issue #1060 FunctionBuilder.cursor should not...


view this post on Zulip GitHub (Feb 28 2020 at 23:26):

alexcrichton transferred Issue #1060:

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)


Last updated: Oct 23 2024 at 20:03 UTC