[PATCH] D81631: Fix undefined behavior in Dwarf.

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 8 12:12:17 PDT 2020


dblaikie added a comment.

Ah, I see - only reproduced in an optimized build. Sorry for the delays/noise.

I'd perhaps feel /marginally/ better about fixing this issue this way:

  diff --git llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  index 296c380ae55..8be0c19bbc4 100644
  --- llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  +++ llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  @@ -333,13 +333,13 @@ DIE *DwarfCompileUnit::getOrCreateCommonBlock(
   void DwarfCompileUnit::addRange(RangeSpan Range) {
     DD->insertSectionLabel(Range.Begin);
   
  -  bool SameAsPrevCU = this == DD->getPrevCU();
  +  const DwarfCompileUnit *PrevCU = 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() || !SameAsPrevCU ||
  +  if (CURanges.empty() || this != PrevCU ||
         (&CURanges.back().End->getSection() !=
          &Range.End->getSection())) {
       CURanges.push_back(Range);

At least I /think/ that should work & probably better reflect when this value should be used.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81631/new/

https://reviews.llvm.org/D81631





More information about the llvm-commits mailing list