Skip to content

Access to global variable metadata? #1646

@SteveBoxite

Description

@SteveBoxite

Hello, I am writing an extension for Cranelift, for which at one point I need to determine the size of static global data.

When compiling an example codebase, with the following buffer declaration and --emit=llvm-ir enabled, I get the expected IR output:

static BUFFER: [i32; 5] = [1, 2, 3, 4, 0];
gv0 = symbol userextname0 ; DefId(0:4 ~ extension_test_example[f5b4]::BUFFER)

I discovered that the above comment is generated in the codegen_fn_body function, but failed to further narrow it down. Is it possible to determine the exact spot where DefId is converted into a GlobalValueData object?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions