[LLVMdev] Removing dead code

Fernando Magno Quintao Pereira fernando at CS.UCLA.EDU
Thu Jun 29 21:44:36 PDT 2006


Dear guys,

    I am working in a register allocator for LLVM, and I realized that,
after I perform register allocation, there is many move instructions that
are dead code, and can safely be removed. It is easy for the RA algorithm
to remove these instructions. It seems to me that the only instructions
with dead definitions that I should not remove are the calls. Is it true?
I would like to know if a code like this below is safe, that is, besides
call instructions, is there other instructions that must stay in the code
even if their definitions are dead?

MachineInstr * mi = iter;
opCode = // get the opcode of mi
if(!mi.isCall(opCode)) {
    mbb.remove(iter);
}

Thank you,

Fernando



More information about the llvm-dev mailing list