[llvm-dev] How to get return address at llvm ir level?
Zhang via llvm-dev
llvm-dev at lists.llvm.org
Tue Sep 4 19:38:07 PDT 2018
Judging from the documentation, I'd say yes.
You can use intrinsics by importing them first using Intrinsics::getType and Intrinsics::lookupLLVMIntrinsicsByName I think. Then just call them like any other function. You might need to take special care with inline attributes and whatnot though
Zhang
------------------ Original ------------------
From: "PenYiWang via llvm-dev"<llvm-dev at lists.llvm.org>;
Date: Wed, Sep 5, 2018 10:16 AM
To: "llvm-dev"<llvm-dev at lists.llvm.org>;
Subject: [llvm-dev] How to get return address at llvm ir level?
Hi
I want to write a FunctionPass to insert some code before return.
Funcion:
..
..
..
mov eax,[esp]
cmp eax,0x12345678
je 0x12345678
ret
(maybe stack will not balance)
I wonder that can I get the return address at llvm ir level?
I use IRBuilder to CreateICmpEQ and CreateCondBr.
but I don't how to get the value of return addrss.
I have found there is a Intrinsic::returnaddress.
Is Intrinsic::returnaddress can help me?
I don't konw how to use Intrinsic::returnaddress because few files use this intrinsic.
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180905/aa71006f/attachment.html>
More information about the llvm-dev
mailing list