Ahmad Nouralizadeh via llvm-dev
2018-Aug-07 02:16 UTC
[llvm-dev] Create an Add Instruction in LLVM IR
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>
mayuyu.io via llvm-dev
2018-Aug-07 03:05 UTC
[llvm-dev] Create an Add Instruction in LLVM IR
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
Ahmad Nouralizadeh via llvm-dev
2018-Aug-07 12:35 UTC
[llvm-dev] Create an Add Instruction in LLVM IR
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>