2017-04-09 57 views

回答

1

假设你正在使用C++ API复制并粘贴到这一点,你只需要clone每条指令分别同时fixing references它们之间。类似以下内容:

llvm::ValueToValueMapTy vmap; 

for (auto *inst: instructions_to_clone) { 
    auto *new_inst = inst->clone(); 
    new_inst->insertBefore(insertion_pos); 
    vmap[inst] = new_inst; 
    llvm::RemapInstruction(new_inst, vmap, 
         RF_NoModuleLevelChanges | RF_IgnoreMissingLocals); 
}