[llvm-dev] Is BlockAddress always correct ? (original) (raw)

PenYiWang via llvm-dev llvm-dev at lists.llvm.org
Fri Feb 28 05:56:46 PST 2020


Hi

I use BlockAddress to get the address of BasicBlock ,

and I use GlobalVariable 's getInitializer()

to pass the address of BasicBlock to the global variable of my own program

and then I print it out.

But , I found that BlockAddress is not always correct.

For example, some function's rsp (stack pointer) or other register is maintained by caller,

so it would be like: https://i.imgur.com/Rwuy5ju.png 0x42c37a: e8 c1 7a 00 00 call 433e40 0x42c37f: 48 83 c4 20 add rsp,0x20 0x42c383: eb 00 jmp 42c385 <main+0x16b5>

What I want is the basic block which is "excatly" after the function call , 0x42c37f

I want BlockAddress give me 0x42c37f.

But actually, the output my program print out is 0x42c383.

I guess "add rsp,0x20" is seen as within the basic block of the function call.

Maybe reset the rsp (stack pointer) is part of the function call.

Can I say there is bug in BlockAddress ?

Or there is some bug in LLVM's backend?

How to solve this problem?

Force clang/llvm not to use caller-saved convention or something like that ?

Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200228/7bd0fe76/attachment.html>



More information about the llvm-dev mailing list