[llvm] r215407 - Add a couple of convenience accessors to DebugLocEntry::Value to further

Adrian Prantl aprantl at apple.com
Mon Aug 11 16:23:00 PDT 2014


Author: adrian
Date: Mon Aug 11 18:22:59 2014
New Revision: 215407

URL: http://llvm.org/viewvc/llvm-project?rev=215407&view=rev
Log:
Add a couple of convenience accessors to DebugLocEntry::Value to further
simplify common usage patterns.

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DebugLocEntry.h
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DebugLocEntry.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DebugLocEntry.h?rev=215407&r1=215406&r2=215407&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DebugLocEntry.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DebugLocEntry.h Mon Aug 11 18:22:59 2014
@@ -67,7 +67,9 @@ public:
     const ConstantFP *getConstantFP() const { return Constant.CFP; }
     const ConstantInt *getConstantInt() const { return Constant.CIP; }
     MachineLocation getLoc() const { return Loc; }
-    const MDNode *getVariable() const { return Variable; }
+    const MDNode *getVariableNode() const { return Variable; }
+    DIVariable getVariable() const { return DIVariable(Variable); }
+    bool isVariablePiece() const { return getVariable().isVariablePiece(); }
     friend bool operator==(const Value &, const Value &);
     friend bool operator<(const Value &, const Value &);
   };
@@ -121,7 +123,7 @@ public:
     Values.append(Vals.begin(), Vals.end());
     sortUniqueValues();
     assert(std::all_of(Values.begin(), Values.end(), [](DebugLocEntry::Value V){
-          return DIVariable(V.Variable).isVariablePiece();
+          return V.isVariablePiece();
         }) && "value must be a piece");
   }
 
@@ -158,9 +160,7 @@ inline bool operator==(const DebugLocEnt
 /// Compare two pieces based on their offset.
 inline bool operator<(const DebugLocEntry::Value &A,
                       const DebugLocEntry::Value &B) {
-  DIVariable Var(A.getVariable());
-  DIVariable OtherVar(B.getVariable());
-  return Var.getPieceOffset() < OtherVar.getPieceOffset();
+  return A.getVariable().getPieceOffset() < B.getVariable().getPieceOffset();
 }
 
 }

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=215407&r1=215406&r2=215407&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Aug 11 18:22:59 2014
@@ -1251,9 +1251,9 @@ DwarfDebug::buildLocationList(SmallVecto
     // If this piece overlaps with any open ranges, truncate them.
     DIVariable DIVar = Begin->getDebugVariable();
     auto Last = std::remove_if(OpenRanges.begin(), OpenRanges.end(),
-                  [&](DebugLocEntry::Value R) {
-                    return piecesOverlap(DIVar, DIVariable(R.getVariable()));
-                  });
+                               [&](DebugLocEntry::Value R) {
+                                 return piecesOverlap(DIVar, R.getVariable());
+                               });
     OpenRanges.erase(Last, OpenRanges.end());
 
     const MCSymbol *StartLabel = getLabelBeforeInsn(Begin);
@@ -2067,14 +2067,14 @@ void DwarfDebug::emitLocPieces(ByteStrea
                                const DITypeIdentifierMap &Map,
                                ArrayRef<DebugLocEntry::Value> Values) {
   assert(std::all_of(Values.begin(), Values.end(), [](DebugLocEntry::Value P) {
-        return DIVariable(P.getVariable()).isVariablePiece();
+        return P.isVariablePiece();
       }) && "all values are expected to be pieces");
   assert(std::is_sorted(Values.begin(), Values.end()) &&
          "pieces are expected to be sorted");
 
   unsigned Offset = 0;
   for (auto Piece : Values) {
-    DIVariable Var(Piece.getVariable());
+    DIVariable Var = Piece.getVariable();
     unsigned PieceOffset = Var.getPieceOffset();
     unsigned PieceSize = Var.getPieceSize();
     assert(Offset <= PieceOffset && "overlapping or duplicate pieces");
@@ -2110,8 +2110,7 @@ void DwarfDebug::emitLocPieces(ByteStrea
 void DwarfDebug::emitDebugLocEntry(ByteStreamer &Streamer,
                                    const DebugLocEntry &Entry) {
   const DebugLocEntry::Value Value = Entry.getValues()[0];
-  DIVariable DV(Value.getVariable());
-  if (DV.isVariablePiece())
+  if (Value.isVariablePiece())
     // Emit all pieces that belong to the same variable and range.
     return emitLocPieces(Streamer, TypeIdentifierMap, Entry.getValues());
 
@@ -2121,7 +2120,7 @@ void DwarfDebug::emitDebugLocEntry(ByteS
 
 void DwarfDebug::emitDebugLocValue(ByteStreamer &Streamer,
                                    const DebugLocEntry::Value &Value) {
-  DIVariable DV(Value.getVariable());
+  DIVariable DV = Value.getVariable();
   // Regular entry.
   if (Value.isInt()) {
     DIBasicType BTy(resolve(DV.getType()));





More information about the llvm-commits mailing list