From f98df953fb9dc50411d9c6582a7f4e830c13845b Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Fri, 17 Apr 2015 16:33:37 +0000 Subject: [PATCH] AsmPrinter: Stop storing MDLocalVariable in DebugLocEntry Stop storing the `MDLocalVariable` in the `DebugLocEntry::Value`s. We generate the list of `DebugLocEntry`s separately for each variable/inlined-at pair, so the variable never actually changes here. This is effectively NFC (aside from saving some memory and CPU time). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235202 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DebugLocEntry.h | 40 ++++++++++---------------- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 10 +++---- 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/DebugLocEntry.h b/lib/CodeGen/AsmPrinter/DebugLocEntry.h index 8dc003f1820..184fb295784 100644 --- a/lib/CodeGen/AsmPrinter/DebugLocEntry.h +++ b/lib/CodeGen/AsmPrinter/DebugLocEntry.h @@ -28,27 +28,23 @@ class DebugLocEntry { public: /// \brief A single location or constant. struct Value { - Value(const MDNode *Var, const MDNode *Expr, int64_t i) - : Variable(Var), Expression(Expr), EntryKind(E_Integer) { + Value(const MDNode *Expr, int64_t i) + : Expression(Expr), EntryKind(E_Integer) { Constant.Int = i; } - Value(const MDNode *Var, const MDNode *Expr, const ConstantFP *CFP) - : Variable(Var), Expression(Expr), EntryKind(E_ConstantFP) { + Value(const MDNode *Expr, const ConstantFP *CFP) + : Expression(Expr), EntryKind(E_ConstantFP) { Constant.CFP = CFP; } - Value(const MDNode *Var, const MDNode *Expr, const ConstantInt *CIP) - : Variable(Var), Expression(Expr), EntryKind(E_ConstantInt) { + Value(const MDNode *Expr, const ConstantInt *CIP) + : Expression(Expr), EntryKind(E_ConstantInt) { Constant.CIP = CIP; } - Value(const MDNode *Var, const MDNode *Expr, MachineLocation Loc) - : Variable(Var), Expression(Expr), EntryKind(E_Location), Loc(Loc) { - assert(isa(Var)); + Value(const MDNode *Expr, MachineLocation Loc) + : Expression(Expr), EntryKind(E_Location), Loc(Loc) { assert(cast(Expr)->isValid()); } - /// The variable to which this location entry corresponds. - const MDNode *Variable; - /// Any complex address location expression for this Value. const MDNode *Expression; @@ -74,7 +70,6 @@ public: const ConstantFP *getConstantFP() const { return Constant.CFP; } const ConstantInt *getConstantInt() const { return Constant.CIP; } MachineLocation getLoc() const { return Loc; } - DIVariable getVariable() const { return cast(Variable); } bool isBitPiece() const { return getExpression()->isBitPiece(); } DIExpression getExpression() const { return cast_or_null(Expression); @@ -103,11 +98,9 @@ public: bool MergeValues(const DebugLocEntry &Next) { if (Begin == Next.Begin) { DIExpression Expr = cast_or_null(Values[0].Expression); - DIVariable Var = cast_or_null(Values[0].Variable); DIExpression NextExpr = cast_or_null(Next.Values[0].Expression); - DIVariable NextVar = cast_or_null(Next.Values[0].Variable); - if (Var == NextVar && Expr->isBitPiece() && NextExpr->isBitPiece()) { + if (Expr->isBitPiece() && NextExpr->isBitPiece()) { addValues(Next.Values); End = Next.End; return true; @@ -144,12 +137,12 @@ public: // Remove any duplicate entries by dropping all but the first. void sortUniqueValues() { std::sort(Values.begin(), Values.end()); - Values.erase(std::unique(Values.begin(), Values.end(), - [](const Value &A, const Value &B) { - return A.getVariable() == B.getVariable() && - A.getExpression() == B.getExpression(); - }), - Values.end()); + Values.erase( + std::unique( + Values.begin(), Values.end(), [](const Value &A, const Value &B) { + return A.getExpression() == B.getExpression(); + }), + Values.end()); } /// \brief Lower this entry into a DWARF expression. @@ -170,9 +163,6 @@ inline bool operator==(const DebugLocEntry::Value &A, if (A.Expression != B.Expression) return false; - if (A.Variable != B.Variable) - return false; - switch (A.EntryKind) { case DebugLocEntry::Value::E_Location: return A.Loc == B.Loc; diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 853f6264e93..7c13f1384aa 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -734,7 +734,6 @@ void DwarfDebug::collectVariableInfoFromMMITable( // Get .debug_loc entry for the instruction range starting at MI. static DebugLocEntry::Value getDebugLocValue(const MachineInstr *MI) { const MDNode *Expr = MI->getDebugExpression(); - const MDNode *Var = MI->getDebugVariable(); assert(MI->getNumOperands() == 4); if (MI->getOperand(0).isReg()) { @@ -745,14 +744,14 @@ static DebugLocEntry::Value getDebugLocValue(const MachineInstr *MI) { MLoc.set(MI->getOperand(0).getReg()); else MLoc.set(MI->getOperand(0).getReg(), MI->getOperand(1).getImm()); - return DebugLocEntry::Value(Var, Expr, MLoc); + return DebugLocEntry::Value(Expr, MLoc); } if (MI->getOperand(0).isImm()) - return DebugLocEntry::Value(Var, Expr, MI->getOperand(0).getImm()); + return DebugLocEntry::Value(Expr, MI->getOperand(0).getImm()); if (MI->getOperand(0).isFPImm()) - return DebugLocEntry::Value(Var, Expr, MI->getOperand(0).getFPImm()); + return DebugLocEntry::Value(Expr, MI->getOperand(0).getFPImm()); if (MI->getOperand(0).isCImm()) - return DebugLocEntry::Value(Var, Expr, MI->getOperand(0).getCImm()); + return DebugLocEntry::Value(Expr, MI->getOperand(0).getCImm()); llvm_unreachable("Unexpected 4-operand DBG_VALUE instruction!"); } @@ -865,7 +864,6 @@ DwarfDebug::buildLocationList(SmallVectorImpl &DebugLoc, DEBUG({ dbgs() << CurEntry->getValues().size() << " Values:\n"; for (auto Value : CurEntry->getValues()) { - Value.getVariable()->dump(); Value.getExpression()->dump(); } dbgs() << "-----\n";