LLVM How to replace a Instruction with a callInst that is calling a function in my program

17 Views Asked by At

So I am trying to create a CallInst* object, and I am replacing it with a Instruction I. But here, instead of "myFunc", I need to define my function but I couldn't figure out how from the llvm docs

Value* val[1];
val[0] = CI->getOperand(0);
CallInst* replace = CallInst::Create(myFunc, val, Twine("call"));        
ReplaceInstWithInst(I, replace);

My function is something like this:

void* myFunc(size_t x) {
    /* Do Stuff */
    return something;   
}

I am trying to achieve the following:

 %call = call noalias align 16 i8* @myFunc(i64 512) #2

How can I define my function as a Function* object to use it in CallInst::Create? And would I need to define my function in a different directory to achieve this?

0

There are 0 best solutions below