[llvm] r276956 - [CodeView] Don't crash on functions without subprograms

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 28 08:36:43 PDT 2016


The actual effect of this is that we don't emit any symbol info for
functions that lack a subprogram, right? If so, yeah, sounds good, let's
merge to 3.9.

On Wed, Jul 27, 2016 at 10:14 PM, David Majnemer <david.majnemer at gmail.com>
wrote:

> I think this should get merged into 3.9, it is apparently blocking the
> rust folks from using it.
> Thoughts?
>
> On Thu, Jul 28, 2016 at 1:03 AM, David Majnemer via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> Author: majnemer
>> Date: Thu Jul 28 00:03:22 2016
>> New Revision: 276956
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=276956&view=rev
>> Log:
>> [CodeView] Don't crash on functions without subprograms
>>
>> A function may have instructions annotated with debug info without
>> having a subprogram.
>>
>> This fixes PR28747.
>>
>> Added:
>>     llvm/trunk/test/DebugInfo/COFF/pr28747.ll
>> Modified:
>>     llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
>>     llvm/trunk/test/DebugInfo/COFF/inlining-same-name.ll
>>
>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=276956&r1=276955&r2=276956&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Thu Jul 28
>> 00:03:22 2016
>> @@ -217,10 +217,7 @@ TypeIndex CodeViewDebug::getScopeIndex(c
>>  }
>>
>>  TypeIndex CodeViewDebug::getFuncIdForSubprogram(const DISubprogram *SP) {
>> -  // It's possible to ask for the FuncId of a function which doesn't
>> have a
>> -  // subprogram: inlining a function with debug info into a function
>> with none.
>> -  if (!SP)
>> -    return TypeIndex::None();
>> +  assert(SP);
>>
>>    // Check if we've already translated this subprogram.
>>    auto I = TypeIndices.find({SP, nullptr});
>> @@ -624,11 +621,12 @@ void CodeViewDebug::emitDebugInfoForFunc
>>
>>    std::string FuncName;
>>    auto *SP = GV->getSubprogram();
>> +  assert(SP);
>>    setCurrentSubprogram(SP);
>>
>>    // If we have a display name, build the fully qualified name by
>> walking the
>>    // chain of scopes.
>> -  if (SP != nullptr && !SP->getDisplayName().empty())
>> +  if (!SP->getDisplayName().empty())
>>      FuncName =
>>          getFullyQualifiedName(SP->getScope().resolve(),
>> SP->getDisplayName());
>>
>> @@ -867,7 +865,7 @@ void CodeViewDebug::collectVariableInfo(
>>  void CodeViewDebug::beginFunction(const MachineFunction *MF) {
>>    assert(!CurFn && "Can't process two functions at once!");
>>
>> -  if (!Asm || !MMI->hasDebugInfo())
>> +  if (!Asm || !MMI->hasDebugInfo() ||
>> !MF->getFunction()->getSubprogram())
>>      return;
>>
>>    DebugHandlerBase::beginFunction(MF);
>> @@ -1942,7 +1940,8 @@ void CodeViewDebug::beginInstruction(con
>>    DebugHandlerBase::beginInstruction(MI);
>>
>>    // Ignore DBG_VALUE locations and function prologue.
>> -  if (!Asm || MI->isDebugValue() ||
>> MI->getFlag(MachineInstr::FrameSetup))
>> +  if (!Asm || !CurFn || MI->isDebugValue() ||
>> +      MI->getFlag(MachineInstr::FrameSetup))
>>      return;
>>    DebugLoc DL = MI->getDebugLoc();
>>    if (DL == PrevInstLoc || !DL)
>>
>> Modified: llvm/trunk/test/DebugInfo/COFF/inlining-same-name.ll
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/inlining-same-name.ll?rev=276956&r1=276955&r2=276956&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/test/DebugInfo/COFF/inlining-same-name.ll (original)
>> +++ llvm/trunk/test/DebugInfo/COFF/inlining-same-name.ll Thu Jul 28
>> 00:03:22 2016
>> @@ -33,7 +33,7 @@
>>  target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
>>  target triple = "x86_64-pc-windows-msvc"
>>
>> -define void @main(i32* %i.i) {
>> +define void @main(i32* %i.i) !dbg !16 {
>>    store volatile i32 3, i32* %i.i, !dbg !6
>>    store volatile i32 3, i32* %i.i, !dbg !19
>>    ret void
>>
>> Added: llvm/trunk/test/DebugInfo/COFF/pr28747.ll
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/pr28747.ll?rev=276956&view=auto
>>
>> ==============================================================================
>> --- llvm/trunk/test/DebugInfo/COFF/pr28747.ll (added)
>> +++ llvm/trunk/test/DebugInfo/COFF/pr28747.ll Thu Jul 28 00:03:22 2016
>> @@ -0,0 +1,44 @@
>> +; RUN: llc < %s | FileCheck %s
>> +
>> +; CHECK:             .section .debug$S,"dr"{{$}}
>> +; CHECK-NEXT:        .p2align 2
>> +; CHECK-NEXT:        .long 4
>> +; CHECK-NEXT:        .cv_filechecksums
>> +; CHECK-NEXT:        .cv_stringtable
>> +
>> +target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
>> +target triple = "i686-pc-windows-msvc18.0.0"
>> +
>> +define void @baz() {
>> +entry:
>> +  %x.i.i = alloca i32, align 4
>> +  call void @llvm.dbg.declare(metadata i32* %x.i.i, metadata !6,
>> metadata !12), !dbg !13
>> +  store i32 5, i32* %x.i.i, align 4, !dbg !13
>> +  ret void
>> +}
>> +
>> +; Function Attrs: nounwind readnone
>> +declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
>> +
>> +attributes #0 = { nounwind readnone }
>> +
>> +!llvm.dbg.cu = !{!0}
>> +!llvm.module.flags = !{!3, !4}
>> +!llvm.ident = !{!5}
>> +
>> +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer:
>> "clang version 4.0.0 (trunk 276756) (llvm/trunk 276952)", isOptimized:
>> false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
>> +!1 = !DIFile(filename: "-", directory: "/")
>> +!2 = !{}
>> +!3 = !{i32 2, !"CodeView", i32 1}
>> +!4 = !{i32 2, !"Debug Info Version", i32 3}
>> +!5 = !{!"clang version 4.0.0 (trunk 276756) (llvm/trunk 276952)"}
>> +!6 = !DILocalVariable(name: "x", scope: !7, file: !8, line: 1, type: !11)
>> +!7 = distinct !DISubprogram(name: "foo", scope: !8, file: !8, line: 1,
>> type: !9, isLocal: true, isDefinition: true, scopeLine: 1, isOptimized:
>> false, unit: !0, variables: !2)
>> +!8 = !DIFile(filename: "<stdin>", directory: "/")
>> +!9 = !DISubroutineType(types: !10)
>> +!10 = !{null}
>> +!11 = !DIBasicType(name: "int", size: 32, align: 32, encoding:
>> DW_ATE_signed)
>> +!12 = !DIExpression()
>> +!13 = !DILocation(line: 1, column: 56, scope: !7, inlinedAt: !14)
>> +!14 = distinct !DILocation(line: 2, column: 52, scope: !15)
>> +!15 = distinct !DISubprogram(name: "bar", scope: !8, file: !8, line: 2,
>> type: !9, isLocal: true, isDefinition: true, scopeLine: 2, isOptimized:
>> false, unit: !0, variables: !2)
>>
>>
>> _______________________________________________
>> 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/20160728/79aa66e2/attachment.html>


More information about the llvm-commits mailing list