[llvm] r204790 - Fix PR19239 - Add support for generating debug info for functions without lexical scopes and/or debug info at all

Timur Iskhodzhanov timurrrr at google.com
Fri Apr 4 06:20:42 PDT 2014


Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/DwarfDebug.cpp (revision 205623)
+++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp (working copy)
@@ -1361,6 +1361,8 @@
         Flags |= DWARF2_FLAG_IS_STMT;

       if (!DL.isUnknown()) {
+        // At this point we seem to know the line/column info, right?
+        assert(!LScopes.empty());
         const MDNode *Scope =
DL.getScope(Asm->MF->getFunction()->getContext());
         recordSourceLine(DL.getLine(), DL.getCol(), Scope, Flags);
       } else
//////////////////////
Failing Tests (4):
    LLVM :: DebugInfo/X86/DW_AT_specification.ll
    LLVM :: DebugInfo/X86/dbg-value-terminator.ll
    LLVM :: DebugInfo/X86/elf-names.ll
    LLVM :: DebugInfo/X86/pr12831.ll

2014-04-01 21:03 GMT+04:00 Eric Christopher <echristo at gmail.com>:
> On Tue, Apr 1, 2014 at 10:02 AM, Eric Christopher <echristo at gmail.com> wrote:
>> On Tue, Apr 1, 2014 at 3:07 AM, Timur Iskhodzhanov <timurrrr at google.com> wrote:
>>> 2014-04-01 4:12 GMT+04:00 Eric Christopher <echristo at gmail.com>:
>>>>> -  // Grab the lexical scopes for the function, if we don't have any of those
>>>>> -  // then we're not going to be able to do anything.
>>>>> -  LScopes.initialize(*MF);
>>>>> -  if (LScopes.empty())
>>>>> -    return;
>>>>> -
>>>>>    const Function *GV = MF->getFunction();
>>>>>    assert(FnDebugInfo.count(GV) == false);
>>>>>    VisitedFunctions.push_back(GV);
>>>>> @@ -311,13 +308,12 @@ void WinCodeViewLineTables::endFunction(
>>>>>    if (!Asm || !CurFn)  // We haven't created any debug info for this function.
>>>>>      return;
>>>>>
>>>>> -  if (CurFn->Instrs.empty())
>>>>> -    llvm_unreachable("Can this ever happen?");
>>>>> -
>>>>> -  // Define end label for subprogram.
>>>>> -  MCSymbol *FunctionEndSym = Asm->OutStreamer.getContext().CreateTempSymbol();
>>>>> -  Asm->OutStreamer.EmitLabel(FunctionEndSym);
>>>>> -  CurFn->End = FunctionEndSym;
>>>>> +  if (!CurFn->Instrs.empty()) {
>>>>> +    // Define end label for subprogram.
>>>>> +    MCSymbol *FunctionEndSym = Asm->OutStreamer.getContext().CreateTempSymbol();
>>>>> +    Asm->OutStreamer.EmitLabel(FunctionEndSym);
>>>>> +    CurFn->End = FunctionEndSym;
>>>>> +  }
>>>>>    CurFn = 0;
>>>>>  }
>>>>
>>>> This part doesn't really make sense. You're saying that without any
>>>> scope we can still generate a line table entry for this?
>>>
>>> Yes - I think we can get some minimal required information even if
>>> there's no lexical scope.
>>>
>>>> What's the information contained within and how did it get line information on there?
>>>> I might be missing something though.
>>>
>>> The MI's seem to have DebugLoc available, the IR instructions seem to
>>> have some minimal debug metadata too.
>>
>> Then there should be a lexical scope, can you show where it's not?
>>
>
> In other words, if there's debug information in the IR, but no lexical
> scopes then that's a bug in the lexical scope code :)
>
> -eric
>
>> -eric
>>
>>>
>>>> I'm not sure what kind of code this is supposed to be catching (and I looked at the testcases :)
>>>
>>> One of the other problems is that we discuss this on a number of
>>> commits and some stuff and comments already got fixed, improved, etc.
>>>
>>> Please see the attached patch that contains all the changes I did and
>>> tests for them.



More information about the llvm-commits mailing list