diff options
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp | 44 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/LiveDebugValues.cpp | 58 | 
2 files changed, 20 insertions, 82 deletions
| diff --git a/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp b/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp index 5601678734a..c006f3cc2ef 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp @@ -352,43 +352,17 @@ void llvm::calculateDbgEntityHistory(const MachineFunction *MF,        }      } -    // Make sure locations for all variables are valid only until the end of -    // the basic block (unless it's the last basic block, in which case let -    // their liveness run off to the end of the function). +    // Make sure locations for register-described variables are valid only +    // until the end of the basic block (unless it's the last basic block, in +    // which case let their liveness run off to the end of the function).      if (!MBB.empty() && &MBB != &MF->back()) { -      // Iterate over all variables that have open debug values. -      SmallSet<unsigned, 8> RegsToClobber; -      for (auto &Pair : LiveEntries) { -        // Iterate over history entries for all open fragments. -        SmallVector<EntryIndex, 8> IdxesToRemove; -        for (EntryIndex Idx : Pair.second) { -          DbgValueHistoryMap::Entry &Ent = DbgValues.getEntry(Pair.first, Idx); -          assert(Ent.isDbgValue() && !Ent.isClosed()); -          const MachineInstr *DbgValue = Ent.getInstr(); - -          // If this is a register or indirect DBG_VALUE, apply some futher -          // tests to see if we should clobber it. Perform the clobbering -          // later though, to keep LiveEntries iteration stable. -          if (DbgValue->getOperand(0).isReg()) { -            unsigned RegNo = DbgValue->getOperand(0).getReg(); -            if (TRI->isVirtualRegister(RegNo) || ChangingRegs.test(RegNo)) -              RegsToClobber.insert(RegNo); -          } else { -            // This is a constant, terminate it at end of the block. Store -            // eliminated EntryIdx and delete later, for iteration stability. -            EntryIndex ClobIdx = DbgValues.startClobber(Pair.first, MBB.back()); -            DbgValues.getEntry(Pair.first, Idx).endEntry(ClobIdx); -            IdxesToRemove.push_back(Idx); -          } -        } - -        for (EntryIndex Idx : IdxesToRemove) -          Pair.second.erase(Idx); +      for (auto I = RegVars.begin(), E = RegVars.end(); I != E;) { +        auto CurElem = I++; // CurElem can be erased below. +        if (TRI->isVirtualRegister(CurElem->first) || +            ChangingRegs.test(CurElem->first)) +          clobberRegisterUses(RegVars, CurElem, DbgValues, LiveEntries, +                              MBB.back());        } - -      // Implement clobbering of registers at the end of BB. -      for (unsigned Reg : RegsToClobber) -        clobberRegisterUses(RegVars, Reg, DbgValues, LiveEntries, MBB.back());      }    }  } diff --git a/llvm/lib/CodeGen/LiveDebugValues.cpp b/llvm/lib/CodeGen/LiveDebugValues.cpp index e36694d2c5b..449f10c7ef7 100644 --- a/llvm/lib/CodeGen/LiveDebugValues.cpp +++ b/llvm/lib/CodeGen/LiveDebugValues.cpp @@ -143,8 +143,7 @@ private:      enum VarLocKind {        InvalidKind = 0,        RegisterKind, -      SpillLocKind, -      ImmediateKind +      SpillLocKind      } Kind = InvalidKind;      /// The value location. Stored separately to avoid repeatedly @@ -153,9 +152,6 @@ private:        uint64_t RegNo;        SpillLoc SpillLocation;        uint64_t Hash; -      int64_t Immediate; -      const ConstantFP *FPImm; -      const ConstantInt *CImm;      } Loc;      VarLoc(const MachineInstr &MI, LexicalScopes &LS) @@ -168,15 +164,6 @@ private:        if (int RegNo = isDbgValueDescribedByReg(MI)) {          Kind = RegisterKind;          Loc.RegNo = RegNo; -      } else if (MI.getOperand(0).isImm()) { -        Kind = ImmediateKind; -        Loc.Immediate = MI.getOperand(0).getImm(); -      } else if (MI.getOperand(0).isFPImm()) { -        Kind = ImmediateKind; -        Loc.FPImm = MI.getOperand(0).getFPImm(); -      } else if (MI.getOperand(0).isCImm()) { -        Kind = ImmediateKind; -        Loc.CImm = MI.getOperand(0).getCImm();        }      } @@ -191,9 +178,6 @@ private:        Loc.SpillLocation = {SpillBase, SpillOffset};      } -    // Is the Loc field a constant or constant object? -    bool isConstant() const { return Kind == ImmediateKind; } -      /// If this variable is described by a register, return it,      /// otherwise return 0.      unsigned isDescribedByReg() const { @@ -211,8 +195,7 @@ private:  #endif      bool operator==(const VarLoc &Other) const { -      return Kind == Other.Kind && Var == Other.Var && -             Loc.Hash == Other.Loc.Hash; +      return Var == Other.Var && Loc.Hash == Other.Loc.Hash;      }      /// This operator guarantees that VarLocs are sorted by Variable first. @@ -425,23 +408,11 @@ void LiveDebugValues::transferDebugValue(const MachineInstr &MI,    OpenRanges.erase(V);    // Add the VarLoc to OpenRanges from this DBG_VALUE. -  unsigned ID; -  if (isDbgValueDescribedByReg(MI) || MI.getOperand(0).isImm() || -      MI.getOperand(0).isFPImm() || MI.getOperand(0).isCImm()) { -    // Use normal VarLoc constructor for registers and immediates. +  // TODO: Currently handles DBG_VALUE which has only reg as location. +  if (isDbgValueDescribedByReg(MI)) {      VarLoc VL(MI, LS); -    ID = VarLocIDs.insert(VL); -    OpenRanges.insert(ID, VL.Var); -  } else if (MI.hasOneMemOperand()) { -    // It's a stack spill -- fetch spill base and offset. -    VarLoc::SpillLoc SpillLocation = extractSpillBaseRegAndOffset(MI); -    VarLoc VL(MI, SpillLocation.SpillBase, SpillLocation.SpillOffset, LS); -    ID = VarLocIDs.insert(VL); +    unsigned ID = VarLocIDs.insert(VL);      OpenRanges.insert(ID, VL.Var); -  } else { -    // This must be an undefined location. We should leave OpenRanges closed. -    assert(MI.getOperand(0).isReg() && MI.getOperand(0).getReg() == 0 && -           "Unexpected non-undef DBG_VALUE encountered");    }  } @@ -835,19 +806,12 @@ bool LiveDebugValues::join(      // a new DBG_VALUE. process() will end this range however appropriate.      const VarLoc &DiffIt = VarLocIDs[ID];      const MachineInstr *DMI = &DiffIt.MI; -    MachineInstr *MI = nullptr; -    if (DiffIt.isConstant()) { -      MachineOperand MO(DMI->getOperand(0)); -      MI = BuildMI(MBB, MBB.instr_begin(), DMI->getDebugLoc(), DMI->getDesc(), -                   false, MO, DMI->getDebugVariable(), -                   DMI->getDebugExpression()); -    } else { -      MI = BuildMI(MBB, MBB.instr_begin(), DMI->getDebugLoc(), DMI->getDesc(), -                   DMI->isIndirectDebugValue(), DMI->getOperand(0).getReg(), -                   DMI->getDebugVariable(), DMI->getDebugExpression()); -      if (DMI->isIndirectDebugValue()) -        MI->getOperand(1).setImm(DMI->getOperand(1).getImm()); -    } +    MachineInstr *MI = +        BuildMI(MBB, MBB.instr_begin(), DMI->getDebugLoc(), DMI->getDesc(), +                DMI->isIndirectDebugValue(), DMI->getOperand(0).getReg(), +                DMI->getDebugVariable(), DMI->getDebugExpression()); +    if (DMI->isIndirectDebugValue()) +      MI->getOperand(1).setImm(DMI->getOperand(1).getImm());      LLVM_DEBUG(dbgs() << "Inserted: "; MI->dump(););      ILS.set(ID);      ++NumInserted; | 

