getting address of parameter or return memory cell on stack in bitcode

Hello LLVM Developers,

I am curious if it is possible to get the actual address in memory of where the parameter or return memory location is on to the stack prior to the call or return being made in the LLVM IR. If these things are possible how is it done in a safe manner?

Thanks,

Carter.

Hi Carter,

I am curious if it is possible to get the actual address in memory of where the parameter or return memory location is on to the stack prior to the call or return being made in the LLVM IR.

I suspect the answer depends on what you're hoping to do with that information.

The "inalloca" attribute was added for a particular Windows use-case
(where the ABI demanded the caller modify that memory in arbitrary
ways before the call), and might be useful if you control the
front-end or at least can insert a conversion pass without breaking an
existing ABI you care about.

Alternatively, the information is available at certain stages in the
CodeGen. During call-lowering the offsets are assigned (as "some
target-specific stack offset + N"); the targets generally know what
that specific stack offset is and can go digging around if they want.

So what do you plan to do with this information if you can obtain it?

Cheers.

Tim.

Hello Tim,

Thanks for the reply. I am trying to write a compiler pass where I can assign a “type” to variables on the stack, heap and globals without modifying the form of the existing data. I assume the inalloca attribute works for return values as well?