[llvm] r217468 - Sink PrevCU updating into DwarfUnit::addRange to ensure consistency

David Blaikie dblaikie at gmail.com
Tue Sep 9 16:13:02 PDT 2014


Author: dblaikie
Date: Tue Sep  9 18:13:01 2014
New Revision: 217468

URL: http://llvm.org/viewvc/llvm-project?rev=217468&view=rev
Log:
Sink PrevCU updating into DwarfUnit::addRange to ensure consistency

So that the two operations in DwarfDebug couldn't get separated (because
I accidentally separated them in some work in progress), put them
together. While we're here, move DwarfUnit::addRange to
DwarfCompileUnit, since it's not relevant to type units.

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

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=217468&r1=217467&r2=217468&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Sep  9 18:13:01 2014
@@ -1709,7 +1709,6 @@ void DwarfDebug::endFunction(const Machi
   // Add the range of this function to the list of ranges for the CU.
   RangeSpan Span(FunctionBeginSym, FunctionEndSym);
   TheCU.addRange(std::move(Span));
-  PrevCU = &TheCU;
 
   // Clear debug info
   // Ownership of DbgVariables is a bit subtle - ScopeVariables owns all the

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=217468&r1=217467&r2=217468&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Tue Sep  9 18:13:01 2014
@@ -629,6 +629,7 @@ public:
 
   /// Returns the previous CU that was being updated
   const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
+  void setPrevCU(const DwarfCompileUnit *PrevCU) { this->PrevCU = PrevCU; }
 
   /// Returns the entries for the .debug_loc section.
   const SmallVectorImpl<DebugLocList> &

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=217468&r1=217467&r2=217468&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Tue Sep  9 18:13:01 2014
@@ -2037,14 +2037,16 @@ void DwarfUnit::emitHeader(const MCSymbo
   Asm->EmitInt8(Asm->getDataLayout().getPointerSize());
 }
 
-void DwarfUnit::addRange(RangeSpan Range) {
+void DwarfCompileUnit::addRange(RangeSpan Range) {
   // Only add a range for this unit if we're emitting full debug.
   if (getCUNode().getEmissionKind() == DIBuilder::FullDebug) {
+    bool SameAsPrevCU = this == DD->getPrevCU();
+    DD->setPrevCU(this);
     // If we have no current ranges just add the range and return, otherwise,
     // check the current section and CU against the previous section and CU we
     // emitted into and the subprogram was contained within. If these are the
     // same then extend our current range, otherwise add this as a new range.
-    if (CURanges.empty() || this != DD->getPrevCU() ||
+    if (CURanges.empty() || !SameAsPrevCU ||
         (&CURanges.back().getEnd()->getSection() !=
          &Range.getEnd()->getSection())) {
       CURanges.push_back(Range);

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h?rev=217468&r1=217467&r2=217468&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h Tue Sep  9 18:13:01 2014
@@ -216,9 +216,6 @@ public:
   /// hasContent - Return true if this compile unit has something to write out.
   bool hasContent() const { return !UnitDie.getChildren().empty(); }
 
-  /// addRange - Add an address range to the list of ranges for this unit.
-  void addRange(RangeSpan Range);
-
   /// getRanges - Get the list of ranges for this unit.
   const SmallVectorImpl<RangeSpan> &getRanges() const { return CURanges; }
   SmallVectorImpl<RangeSpan> &getRanges() { return CURanges; }
@@ -555,6 +552,9 @@ public:
   DwarfCompileUnit &getCU() override { return *this; }
 
   unsigned getOrCreateSourceID(StringRef FileName, StringRef DirName) override;
+
+  /// addRange - Add an address range to the list of ranges for this unit.
+  void addRange(RangeSpan Range);
 };
 
 class DwarfTypeUnit : public DwarfUnit {





More information about the llvm-commits mailing list