Skip to content

Cranelift: emit_stackmaps should avoid walking the IR if the function doesn't use r32 or r64 #1883

@fitzgen

Description

@fitzgen

Enabling stack maps and GC safepoints adds another pass over the IR (emit_stackmaps) regardless whether the function in question actually uses reference types at all. One could imagine (especially with wasm-bindgen's "switch reference types into table indices at the boundaries" approach, that seems likely to be copied by C/C++) that many functions in a module don't use reference types. For these functions, that extra pass over the IR is a waste of time.

We could have a flag on functions that gets set if it uses reference types in any way (and then never gets unset when a particular reference type-using instruction is removed, so we don't have to precisely count them) and in emit_stackmaps, only walk the IR if the flag is set (and probably debug_assert! that it doesn't have any uses of reference types if the flag is not set).

This came up in #1832 (comment) for Wasmtime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    craneliftIssues related to the Cranelift code generator

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions