[LLVMdev] Instantiating the new Instructions from CallInst Class

Ferad Zyulkyarov feradz at gmail.com
Wed Apr 18 01:45:40 PDT 2007


prior to call a function it should be declared in your

> After several analysis phases, I want to instantiate several
> instructions in the basic block.
> Instructions that I try to instantiate are like below;
> call void (int)* %waitABC(int 10)
> %tmp = call int (int, int*)* %doABC(int %i, int* %total)
> I think I should use 'CallInst' class in 'Instructions.h' file.
> How I could make those instructions from 'CallInst' class?

To be able to call a function let's say "waitABC" that you have
defined in somewhere else you have to declare it in your module. To
declare a Function you have to create a Function object with empty
basic block  (see

The code should be something like this:

Function *f = new Function(TheTypeOfYourFunction,
GlobalValue::ExternalLinkage, "FunctionName",
CallInst callInst = new CallInst(f, args, "valueName",

Ferad Zyulkyarov
Barcelona Supercomputing Center

More information about the llvm-dev mailing list