Remove DwarfDebug::PrevSection, PrevCU is sufficient for handling address range holes.
authorDavid Blaikie <dblaikie@gmail.com>
Tue, 9 Sep 2014 22:56:36 +0000 (22:56 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Tue, 9 Sep 2014 22:56:36 +0000 (22:56 +0000)
PrevSection/PrevCU are used to detect holes in the address range of a CU
to ensure the DW_AT_ranges does not include those holes. When we see a
function with no debug info, though it may be in the same range as the
prior and subsequent functions, there should be a gap in the CU's
ranges. By setting PrevCU to null in that case, the range would not be
extended to cover the gap.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217466 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/DwarfDebug.cpp
lib/CodeGen/AsmPrinter/DwarfDebug.h
lib/CodeGen/AsmPrinter/DwarfUnit.cpp

index 2f0e8181ed5f65bc9c9376240abbdb504f4a4ebd..663ebef250bfab5a7269d070f80b5991e4894f05 100644 (file)
@@ -1667,7 +1667,6 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
     // If we don't have a lexical scope for this function then there will
     // be a hole in the range information. Keep note of this by setting the
     // previously used section to nullptr.
     // If we don't have a lexical scope for this function then there will
     // be a hole in the range information. Keep note of this by setting the
     // previously used section to nullptr.
-    PrevSection = nullptr;
     PrevCU = nullptr;
     CurFn = nullptr;
     return;
     PrevCU = nullptr;
     CurFn = nullptr;
     return;
@@ -1710,7 +1709,6 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
   // Add the range of this function to the list of ranges for the CU.
   RangeSpan Span(FunctionBeginSym, FunctionEndSym);
   TheCU.addRange(std::move(Span));
   // Add the range of this function to the list of ranges for the CU.
   RangeSpan Span(FunctionBeginSym, FunctionEndSym);
   TheCU.addRange(std::move(Span));
-  PrevSection = Asm->getCurrentSection();
   PrevCU = &TheCU;
 
   // Clear debug info
   PrevCU = &TheCU;
 
   // Clear debug info
index 5c33d34559bde79ad4af881d7bbd46be24ceaff7..67615dc9fe0b24df97b34a297b9ce032a6df5a7f 100644 (file)
@@ -243,10 +243,6 @@ class DwarfDebug : public AsmPrinterHandler {
   // If nonnull, stores the current machine instruction we're processing.
   const MachineInstr *CurMI;
 
   // If nonnull, stores the current machine instruction we're processing.
   const MachineInstr *CurMI;
 
-  // If nonnull, stores the section that the previous function was allocated to
-  // emitting.
-  const MCSection *PrevSection;
-
   // If nonnull, stores the CU in which the previous subprogram was contained.
   const DwarfCompileUnit *PrevCU;
 
   // If nonnull, stores the CU in which the previous subprogram was contained.
   const DwarfCompileUnit *PrevCU;
 
@@ -631,9 +627,6 @@ public:
   /// Returns the section symbol for the .debug_loc section.
   MCSymbol *getDebugLocSym() const { return DwarfDebugLocSectionSym; }
 
   /// Returns the section symbol for the .debug_loc section.
   MCSymbol *getDebugLocSym() const { return DwarfDebugLocSectionSym; }
 
-  /// Returns the previous section that was emitted into.
-  const MCSection *getPrevSection() const { return PrevSection; }
-
   /// Returns the previous CU that was being updated
   const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
 
   /// Returns the previous CU that was being updated
   const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
 
index c995e8bd244174106ff5d65cb63be1f6fd7cf0c8..3797831506f2d2ec3f62195c8e61807a4c0dfbfb 100644 (file)
@@ -2044,16 +2044,13 @@ void DwarfUnit::addRange(RangeSpan Range) {
     // 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.
     // 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.size() == 0 ||
-        this != DD->getPrevCU() ||
-        Asm->getCurrentSection() != DD->getPrevSection()) {
+    if (CURanges.empty() || this != DD->getPrevCU() ||
+        (&CURanges.back().getEnd()->getSection() !=
+         &Range.getEnd()->getSection())) {
       CURanges.push_back(Range);
       return;
     }
 
       CURanges.push_back(Range);
       return;
     }
 
-    assert(&(CURanges.back().getEnd()->getSection()) ==
-               &(Range.getEnd()->getSection()) &&
-           "We can only append to a range in the same section!");
     CURanges.back().setEnd(Range.getEnd());
   }
 }
     CURanges.back().setEnd(Range.getEnd());
   }
 }