[llvm] r289697 - DebugInfo: Improve type safety and simplify some subprogram finalization code

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 15 15:48:04 PST 2016


r289892

On Thu, Dec 15, 2016 at 12:25 PM Adrian Prantl <aprantl at apple.com> wrote:

>
> > On Dec 14, 2016, at 11:38 AM, David Blaikie via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
> >
> > Author: dblaikie
> > Date: Wed Dec 14 13:38:39 2016
> > New Revision: 289697
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=289697&view=rev
> > Log:
> > DebugInfo: Improve type safety and simplify some subprogram finalization
> code
> >
> > This probably ended up this way aften the subprogram<>function link
> > inversion and debug info metadata schema changes.
> >
> > Modified:
> >    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
> >    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
> >
> > Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=289697&r1=289696&r2=289697&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
> > +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Dec 14 13:38:39
> 2016
> > @@ -364,13 +364,13 @@ void DwarfDebug::constructAbstractSubpro
> >   assert(Scope->isAbstractScope());
> >   assert(!Scope->getInlinedAt());
> >
> > -  const MDNode *SP = Scope->getScopeNode();
> > +  auto *SP = cast<DISubprogram>(Scope->getScopeNode());
> >
> >   ProcessedSPNodes.insert(SP);
> >
> >   // Find the subprogram's DwarfCompileUnit in the SPMap in case the
> subprogram
> >   // was inlined from another compile unit.
> > -  auto &CU = *CUMap.lookup(cast<DISubprogram>(SP)->getUnit());
> > +  auto &CU = *CUMap.lookup(SP->getUnit());
> >   forBothCUs(CU, [&](DwarfCompileUnit &CU) {
> >     CU.constructAbstractSubprogramScopeDIE(Scope);
> >   });
> > @@ -535,13 +535,11 @@ void DwarfDebug::finishVariableDefinitio
> > }
> >
> > void DwarfDebug::finishSubprogramDefinitions() {
> > -  for (auto &F : MMI->getModule()->functions())
> > -    if (auto *SP = F.getSubprogram())
> > -      if (ProcessedSPNodes.count(SP) &&
> > -          SP->getUnit()->getEmissionKind() != DICompileUnit::NoDebug)
> > -        forBothCUs(*CUMap.lookup(SP->getUnit()), [&](DwarfCompileUnit
> &CU) {
> > -          CU.finishSubprogramDefinition(SP);
> > -        });
> > +  for (const DISubprogram *SP : ProcessedSPNodes)
>
> I was just tracking down a failing buildbot and then realized that it is
> probably this commit that makes the output nondeterministic. You are
> iterating over a SmallPtrSet<const MDNode *, 16> here. I think this only
> triggers when the set is non-small, but this should be fixed nonetheless.
>
> -- adrian
>
> > +    if (SP->getUnit()->getEmissionKind() != DICompileUnit::NoDebug)
> > +      forBothCUs(*CUMap.lookup(SP->getUnit()), [&](DwarfCompileUnit
> &CU) {
> > +        CU.finishSubprogramDefinition(SP);
> > +      });
> > }
> >
> > void DwarfDebug::finalizeModuleInfo() {
> >
> > Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=289697&r1=289696&r2=289697&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
> > +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Wed Dec 14 13:38:39
> 2016
> > @@ -216,7 +216,7 @@ class DwarfDebug : public DebugHandlerBa
> >
> >   /// This is a collection of subprogram MDNodes that are processed to
> >   /// create DIEs.
> > -  SmallPtrSet<const MDNode *, 16> ProcessedSPNodes;
> > +  SmallPtrSet<const DISubprogram *, 16> ProcessedSPNodes;
> >
> >   /// If nonnull, stores the current machine function we're processing.
> >   const MachineFunction *CurFn;
> > @@ -553,7 +553,7 @@ public:
> >
> >   // FIXME: Sink these functions down into DwarfFile/Dwarf*Unit.
> >
> > -  SmallPtrSet<const MDNode *, 16> &getProcessedSPNodes() {
> > +  SmallPtrSet<const DISubprogram *, 16> &getProcessedSPNodes() {
> >     return ProcessedSPNodes;
> >   }
> > };
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161215/d66ac916/attachment.html>


More information about the llvm-commits mailing list