Skip to content

Remove the global_value CLIF instruction #10339

Open
@fitzgen

Description

@fitzgen

This would force us to translate all unnecessary uses of ir::Global into regular CLIF instructions.

Note: We have to keep cranelift_codegen::ir::Globals around for special things like the stack limit check, which are not (and can't ever really be) represented in regular CLIF instructions, since they happen inside of function prologues or what not.

However, we end up using ir::Globals in lots of other places where we could just use regular CLIF instructions instead. For example, we use them to represent Wasm globals in our Wasm to CLIF translation layer. This is annoying because now we have to fit Wasm globals into different kinds of ir::Globals, and it would just be easier to emit the CLIF instructions to get/set the Wasm global directly. These unnecessary ir::Global uses just introduce extra abstraction layers that don't buy us anything, add instructions that require legalization processing in the mid-end, make it harder to follow code through the compiler pipeline because there are extra and unnecessary rewrites, etc...

I propose that we remove the global_value CLIF instruction (the instruction that turns an ir::Global into an ir::Value). Every use of global_value could instead just be the constant or (chained) load that it would otherwise be legalized into, and emitting that already-legalized code will be easier to follow and also mildly more efficient since it doesn't need that legalization anymore. It also means we can remove the associated legalization code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions