我想复制指令(例如加法二进制操作),并在LLVM IR中显示它们,但以下代码仅返回我构建的第1条指令(add1)。如何返回两者都构建说明?复制llvm指令
IRBuilder<> builder(op);
Value *lhs = op->getOperand(0);
Value *rhs = op->getOperand(1);
Value *add1 = builder.CreateAdd(lhs, rhs);
Value *add2 = builder.CreateAdd(lhs, rhs);
for (auto &U : op->uses()) {
User *user = U.getUser(); // A User is anything with operands.
user->setOperand(U.getOperandNo(), add1);
user->setOperand(U.getOperandNo(), add2);
}
非常感谢你,最好使用clone()来复制指令 –