I want to insert an add instruction in LLVM IR format, something like x = x + 1, where x is global variable. I have tried this:
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 occurs, it does not accept type GlobalVariable.
How can I define a global variable and set its value?