Search code examples
rustcompiler-constructioncranelift

How to get the address of a global in Cranelift?


How do I get the address of a global that I've declared with Module::declare_data?

I know that I can create a reference of sorts using Module::declare_data_in_func, but the only methods that I can see for using this in InstBuilder, InstBuilder::global_value and similar, appear to load it by value.

Am I simply misinterpreting the return value of InstBuilder::global_value, or is there something else I've missed?


Solution

  • I completely misinterpreted the documentation.

    Despite its name, InstBuilder::global_value gives the address of a global value.