Get the address of basic block (mapping to llvm ir)


I want to get the address of basic block in llvm ir ,

so I use and BlockAddress,

and then use GlobalVariable 's setInitializer to pass it to my own program.

but I found that BlockAddress sometime would be wrong.

Because code gen (llvm backend) is free to insert instructions in to bb,

like “mov rax” or “add rsp”.

and even change the order of basic block .

like this:

[llvm-dev] Is BlockAddress always correct ?

Then, I study some discussion in llvm-dev

[llvm-dev] Figuring out return address of a call

[llvm-dev] Stackmap question

I also study the shadow stack paper in SP’19, but it is purely in llvm backend , right ?

After survey, I found that BlockAddress and patchpoint/stack map both can’t exactly get the address of basic block , especially the basic block is before a call instruction.

Have you solved this problem?
Or get the address of basic block in other way ?

Thank you ~