[cfe-dev] Parse a Value of Struct Type to extract the item type

Mustakimur Rahman Khandaker (Mustakim) via cfe-dev cfe-dev at lists.llvm.org
Fri Sep 28 10:20:19 PDT 2018


Hi

For this following code:
class Testpm {
public:
void m_func1() { cout << "m_func1\n"; }
int a;
};

void (Testpm::*pmfn)();
int orig61One_main()

{
Testpm ATestpm;

pmfn = &Testpm::m_func1;
}
the clang generates following LLVM IR for the 'pmfn = &Testpm::m_func1':

store { i64, i64 } { i64 ptrtoint (void (%class.Testpm*)* @_ZN6Testpm7m_func1Ev to i64), i64 0 }, { i64, i64 }* @pmfn, align 8
I want to add instruction after or before this to extract what have stored in 'pmfn' (the target address). What I have is the StoreInst and associated Value (source) and Address (destination). Can anyone suggest a way to solve this problem?
On Sep 25 2018, at 5:08 pm, Mustakimur Rahman Khandaker (Mustakim) <mustakcsecuet at gmail.com> wrote:
>
> Hello
> I am working on clang codegen module to parse some information in compile time. So, here is an example LLVM Value:
> { i64, i64 } { i64 ptrtoint (void (%class.Testpm*)* @_ZN6Testpm7m_func1Ev to i64), i64 0 }
> I want to parse this Value so that I can check the source type using in ptrtoint casting instruction (i.e. void (%class.Testpm*)*). I have tried following:
> if (isa<llvm::PtrToIntInst>(Val)) {
> llvm::IntToPtrInst *iptr = dyn_cast<llvm::PtrToIntInst>(Val);
> }
>
> but it is not working. Any idea?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180928/b6863834/attachment.html>


More information about the cfe-dev mailing list