2017-04-09 102 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); 
}