[llvm-dev] Create an Add Instruction in LLVM IR
Ahmad Nouralizadeh via llvm-dev
llvm-dev at lists.llvm.org
Tue Aug 7 05:35:19 PDT 2018
Thanks! It worked!
On Tue, Aug 7, 2018 at 7:35 AM, mayuyu.io <admin at mayuyu.io> wrote:
> By default IRBuilder uses ConstantFolder to fold your constant add
> instruction. In order to disable this, use IRBuilder<NoFolder>
>
> Zhang
>
> > 在 2018年8月7日,10:16,Ahmad Nouralizadeh via llvm-dev <
> llvm-dev at lists.llvm.org> 写道:
> >
> > 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?
> > _______________________________________________
> > LLVM Developers mailing list
> > llvm-dev at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180807/a93c13bb/attachment.html>
More information about the llvm-dev
mailing list