[llvm] r192749 - Make sure we're not attempting to construct a subprogram DIE

David Blaikie dblaikie at gmail.com
Mon May 26 00:00:33 PDT 2014


Added test coverage for this issue in r209614.

On Thu, Oct 17, 2013 at 7:02 PM, Eric Christopher <echristo at gmail.com> wrote:
> For the record I've reverted this here in r192938 as it causes some
> problems with function definitions in multiple TUs/CUs being
> constructed twice. The resultant debug info isn't very good, but at
> least isn't crashing the compiler for now. I'll need to think about a
> solution for that.
>
> -eric
>
> On Tue, Oct 15, 2013 at 4:31 PM, Eric Christopher <echristo at gmail.com> wrote:
>> Author: echristo
>> Date: Tue Oct 15 18:31:38 2013
>> New Revision: 192749
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=192749&view=rev
>> Log:
>> Make sure we're not attempting to construct a subprogram DIE
>> twice and just look up the value. Fix the one case where
>> we were trying to create a subprogram DIE and we should already
>> have had one. Reflow formatting in collectDeadVariables while fixing.
>>
>> Modified:
>>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
>>
>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=192749&r1=192748&r2=192749&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Oct 15 18:31:38 2013
>> @@ -826,12 +826,8 @@ CompileUnit *DwarfDebug::constructCompil
>>  }
>>
>>  // Construct subprogram DIE.
>> -void DwarfDebug::constructSubprogramDIE(CompileUnit *TheCU,
>> -                                        const MDNode *N) {
>> -  CompileUnit *&CURef = SPMap[N];
>> -  if (CURef)
>> -    return;
>> -  CURef = TheCU;
>> +void DwarfDebug::constructSubprogramDIE(CompileUnit *TheCU, const MDNode *N) {
>> +  assert(!SPMap[N] && "Trying to create a subprogram DIE twice!");
>>
>>    DISubprogram SP(N);
>>    if (!SP.isDefinition())
>> @@ -840,6 +836,7 @@ void DwarfDebug::constructSubprogramDIE(
>>      return;
>>
>>    DIE *SubprogramDie = TheCU->getOrCreateSubprogramDIE(SP);
>> +  SPMap[N] = TheCU;
>>
>>    // Expose as a global name.
>>    TheCU->addGlobalName(SP.getName(), SubprogramDie);
>> @@ -974,28 +971,33 @@ void DwarfDebug::collectDeadVariables()
>>        DIArray Subprograms = TheCU.getSubprograms();
>>        for (unsigned i = 0, e = Subprograms.getNumElements(); i != e; ++i) {
>>          DISubprogram SP(Subprograms.getElement(i));
>> -        if (ProcessedSPNodes.count(SP) != 0) continue;
>> -        if (!SP.isSubprogram()) continue;
>> -        if (!SP.isDefinition()) continue;
>> +        if (ProcessedSPNodes.count(SP) != 0)
>> +          continue;
>> +        if (!SP.isSubprogram())
>> +          continue;
>> +        if (!SP.isDefinition())
>> +          continue;
>>          DIArray Variables = SP.getVariables();
>> -        if (Variables.getNumElements() == 0) continue;
>> +        if (Variables.getNumElements() == 0)
>> +          continue;
>>
>>          LexicalScope *Scope =
>> -          new LexicalScope(NULL, DIDescriptor(SP), NULL, false);
>> +            new LexicalScope(NULL, DIDescriptor(SP), NULL, false);
>>          DeadFnScopeMap[SP] = Scope;
>>
>>          // Construct subprogram DIE and add variables DIEs.
>>          CompileUnit *SPCU = CUMap.lookup(TheCU);
>>          assert(SPCU && "Unable to find Compile Unit!");
>> -        constructSubprogramDIE(SPCU, SP);
>> -        DIE *ScopeDIE = SPCU->getDIE(SP);
>> +        DIE *SPDIE = SPCU->getDIE(SP);
>> +        assert(SPDIE && "Subprogram wasn't created?");
>>          for (unsigned vi = 0, ve = Variables.getNumElements(); vi != ve; ++vi) {
>>            DIVariable DV(Variables.getElement(vi));
>> -          if (!DV.isVariable()) continue;
>> +          if (!DV.isVariable())
>> +            continue;
>>            DbgVariable NewVar(DV, NULL, this);
>>            if (DIE *VariableDIE =
>> -              SPCU->constructVariableDIE(&NewVar, Scope->isAbstractScope()))
>> -            ScopeDIE->addChild(VariableDIE);
>> +                  SPCU->constructVariableDIE(&NewVar, Scope->isAbstractScope()))
>> +            SPDIE->addChild(VariableDIE);
>>          }
>>        }
>>      }
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list