Address of an instruction (or a label?)

Hello, Nicolas.

Is there a way in llvm to get the address of a generated instruction? Or
somehow to fix the location of a label in the llvm code (something that
may look like a basic block perhaps) and get after the compilation the
address of this label?

Maybe it's worth to use llvm.dbg.stoppoint?

I agree. Instead of using line numbers, with llvm.dbg.stoppoint, you could use the byte code index. Or alternatively, you could use the column number field instead (not currently managed by MachineModuleInfo.) In the backend, you can generate a machine instruction to byte code mapping table from queries to MachineModuleInfo.

Cheers,

-- Jim

Hi Anton,

Anton Korobeynikov wrote:

Maybe it's worth to use llvm.dbg.stoppoint?

Do you have an example on how to use this intrinsic with the JIT? How can I get at compile
time the address of the stoppoint?

Thx,
Nicolas

After chatting with Anton, we realized that this was actually not a solution because
it is not implemented in the JIT.

Let me turn the question with a different angle : is there a way in llvm to force the emission of
basic blocks labels, even ones that are useless, eg:

        load 1
        load 2 add
        branch label "foo"
foo: load 4

And there is no other jump to the "foo" label. Actually in llvm the label is just removed and the basic block
does not get a native address after compilation.

Cheers,
Nicolas

Nicolas Geoffray wrote: