[llvm-dev] creating a callinst to an external function

marwayusuf@feng.bu.edu.eg via llvm-dev
Wed, 09 Sep 2015 13:30:39 -0000

Thanks a million for help. I got the general idea but I could not manage to
implement it.
I understood that I need to create IntToPtrInst that is supposed to convert an
integer (that represents the function address)  back to a function pointer at
the callee side. But I have some questions:
How I get this integer value at the first place?
I tried something like:
     Value *Arg1 = new IntToPtrInst(reinterpret_cast<uint64_t>(F),
F->getType());
It gave me this compilation error:
    error: no matching function for call to
‘llvm::IntToPtrInst::IntToPtrInst(uint64_t, llvm::PointerType*)’
and
     Value *Arg1 = new IntToPtrInst(F, F->getType());
It gave me this runtime error (during applying the pass):
     llvm::IntToPtrInst::IntToPtrInst(llvm::Value*, llvm::Type*, const
llvm::Twine&, llvm::Instruction*): Assertion `castIsValid(getOpcode(), S,
Ty) && "Illegal IntToPtr"' failed.


Regards,
Marwa Yusuf
Teaching Assistant - Computer Engineering Department
Faculty of Engineering - Benha University
E-JUST PhD Student
Computer Science & Engineering Dept.

________________________________________
From: Tim Northover <t.p.northover at gmail.com>
Sent: Wednesday, September 2, 2015 4:37 PM
To: marwayusuf at feng.bu.edu.eg
Cc: llvm-dev at lists.llvm.org
Subject: Re: [llvm-dev] creating a callinst to an external function