[llvm-dev] Create an Add Instruction in LLVM IR

Ahmad Nouralizadeh via llvm-dev llvm-dev at lists.llvm.org
Mon Aug 6 19:16:29 PDT 2018


I want to create an add instruction that takes two constant operands at the
LLVM IR level. I use the IRBuilder class, but nothing happens. Here is part
of the runOnFunction() method of my function pass:
...
LLVMContext &Context = F.getContext();
IRBuilder<> builder(&Instruction);
Value *Lef = ConstantInt::get(Type::getInt32Ty(Context), 4);
Value *Rig = ConstantInt::get(Type::getInt32Ty(Context), 5);
Value *Result = builder.CreateAdd(Lef, Rig);
...
It seems that the problem is with the ConstantInt::get() function. Any idea?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180807/3565bd7b/attachment.html>


More information about the llvm-dev mailing list