[LLVMdev] How can i insert an add instruction in IR file llvm?

Mos Moh mos4abs at yahoo.com
Wed Mar 12 07:45:32 PDT 2014


i want to insert add instruction in IR llvm format, instruction like x = x + 1 , 
where x is global variable , 
i try to use: 
GlobalVariable* x = new GlobalVariable(mod,Type::getInt32Ty(Context),false,GlobalValue::CommonLinkage,0,"xCounter");
Value one =  ConstantInt::get(Type::getInt32Ty(Context),1);
newInst = BinaryOperator::Create(Instruction::Add, , one ,"counter", insertPos);
but an error occur, 
it is not accept type GlobalVariable, 
How can i define a global variable and set its value , and final i print its value on screen ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140312/43fd639f/attachment.html>


More information about the llvm-dev mailing list