LLVM红外插入
我试图通过代码将一条非常简单的指令插入到我的基本块中LLVM红外插入,llvm,Llvm,我试图通过代码将一条非常简单的指令插入到我的基本块中 Value *ten=ConstantInt::get(Type::getInt32Ty(con),10,true); Instruction *newinst=new AllocaInst(Type::getInt32Ty(con),ten,"jst"); b->getInstList().push_back(newinst); Instruction *add=BinaryOperator::Create(Instruction :
Value *ten=ConstantInt::get(Type::getInt32Ty(con),10,true);
Instruction *newinst=new AllocaInst(Type::getInt32Ty(con),ten,"jst");
b->getInstList().push_back(newinst);
Instruction *add=BinaryOperator::Create(Instruction :: Add,ten,ten,"twenty");
b->getInstList().push_back(add);
当我在一个非常小的文件上运行堆栈转储时,它将提供堆栈转储:
While deleting: i32 %
Def销毁后仍在使用:%twenth=添加i32 10,10
我对LLVM比较陌生,所以如果这段代码没有意义,我会接受任何建议。LLVM指令构造函数和
Create
工厂接受在后面插入的指令,或者在后面插入的基本块
。不要使用getInstList
执行此操作
对于AllocaInst
:
AllocaInst (Type *Ty, Value *ArraySize=nullptr,
const Twine &Name="", Instruction *InsertBefore=nullptr)
AllocaInst (Type *Ty, Value *ArraySize,
const Twine &Name, BasicBlock *InsertAtEnd)
如果我想要一个10的数组,参数“const Twine&Name”的值是多少integers@techcomp:任何东西,都只是为了调试。您只需传入一个空字符串