Which version of LLVM are you building against? In current TOT, there is no CallInst::Create function with the signature you're calling it with. (You're missing the name argument.)
Where is "print" defined here? It looks like it's referencing
FunctionPass::print(), which explains your error message (non-static member
function without calling it).
Sorry ,I forgot to give the definition. I define the print in the doInitialization(Module &M); and it seems in the InstVisitor(), this can not be identified .
What I really want to do is to get every load/store instructions’s operand address in runtime and print it out when the program is running. I wrote a function to do the print work and make it into a dynamic library, so in the functionPass , I define the print functiono like this :
bool doInitialization(Module &M)
{
//Get the refference of the types
IntegerType* Int8Type = IntegerType::getInt8Ty(M.getContext());
IntegerType* Int32Type = IntegerType::getInt32Ty(M.getContext());
IntegerType* Int64Type = IntegerType::getInt64Ty(M.getContext());
PointerType* VoidPtrType = PointerType::getUnqual(Int8Type);
Type* VoidType = Type::getVoidTy(M.getContext());
//Get the function we needed in runtime
Function *print = cast(M.getOrInsertFunction(“my_print”,
VoidType,
Int32Type,
VoidPtrType
));
};
I thought if I define the function here ,then in the InstVisitor, I can use it directly,without define it in every specific InstVisitor function()(eg:visitStoreInst() visitLoadInst(),etc).But I was wrong.
I redefine the function in the visitStoreInst(), and it works.
Is there any easy way to use the function I wrote myself in the instVisitor?