diff options
Diffstat (limited to 'lib/CodeGen/DeadMachineInstructionElim.cpp')
| -rw-r--r-- | lib/CodeGen/DeadMachineInstructionElim.cpp | 26 | 
1 files changed, 11 insertions, 15 deletions
| diff --git a/lib/CodeGen/DeadMachineInstructionElim.cpp b/lib/CodeGen/DeadMachineInstructionElim.cpp index 2b144d89e651..c17a35d1c734 100644 --- a/lib/CodeGen/DeadMachineInstructionElim.cpp +++ b/lib/CodeGen/DeadMachineInstructionElim.cpp @@ -19,7 +19,8 @@  #include "llvm/Support/Debug.h"  #include "llvm/Support/raw_ostream.h"  #include "llvm/Target/TargetInstrInfo.h" -#include "llvm/Target/TargetMachine.h" +#include "llvm/Target/TargetSubtargetInfo.h" +  using namespace llvm;  #define DEBUG_TYPE "codegen-dce" @@ -58,6 +59,10 @@ bool DeadMachineInstructionElim::isDead(const MachineInstr *MI) const {    if (MI->isInlineAsm())      return false; +  // Don't delete frame allocation labels. +  if (MI->getOpcode() == TargetOpcode::FRAME_ALLOC) +    return false; +    // Don't delete instructions with side effects.    bool SawStore = false;    if (!MI->isSafeToMove(TII, nullptr, SawStore) && !MI->isPHI()) @@ -90,8 +95,8 @@ bool DeadMachineInstructionElim::runOnMachineFunction(MachineFunction &MF) {    bool AnyChanges = false;    MRI = &MF.getRegInfo(); -  TRI = MF.getTarget().getRegisterInfo(); -  TII = MF.getTarget().getInstrInfo(); +  TRI = MF.getSubtarget().getRegisterInfo(); +  TII = MF.getSubtarget().getInstrInfo();    // Loop over all instructions in all blocks, from bottom to top, so that it's    // more likely that chains of dependent but ultimately dead instructions will @@ -122,19 +127,10 @@ bool DeadMachineInstructionElim::runOnMachineFunction(MachineFunction &MF) {        if (isDead(MI)) {          DEBUG(dbgs() << "DeadMachineInstructionElim: DELETING: " << *MI);          // It is possible that some DBG_VALUE instructions refer to this -        // instruction.  Examine each def operand for such references; -        // if found, mark the DBG_VALUE as undef (but don't delete it). -        for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { -          const MachineOperand &MO = MI->getOperand(i); -          if (!MO.isReg() || !MO.isDef()) -            continue; -          unsigned Reg = MO.getReg(); -          if (!TargetRegisterInfo::isVirtualRegister(Reg)) -            continue; -          MRI->markUsesInDebugValueAsUndef(Reg); -        } +        // instruction.  They get marked as undef and will be deleted +        // in the live debug variable analysis. +        MI->eraseFromParentAndMarkDBGValuesForRemoval();          AnyChanges = true; -        MI->eraseFromParent();          ++NumDeletes;          MIE = MBB->rend();          // MII is now pointing to the next instruction to process, | 
