[llvm] r342943 - [DebugInfo] Do not generate address info for removed debug labels.

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 25 09:00:57 PDT 2018


I'm getting a crash with this test file on macOS:
Stack dump:
0.    Program arguments: /Users/spatel/myllvm/release/bin/llc -filetype=obj
-split-dwarf-file debug.dwo -o -
/Users/spatel/myllvm/llvm/test/DebugInfo/Generic/debug-label-unreached.ll
0  llc                      0x00000001088e8268
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  llc                      0x00000001088e7205
llvm::sys::RunSignalHandlers() + 85
2  llc                      0x00000001088e8872 SignalHandler(int) + 258
3  libsystem_platform.dylib 0x00007fff7be8df5a _sigtramp + 26
4  libsystem_platform.dylib 0x00007ffee8e24840 _sigtramp + 1828284672
5  llc                      0x0000000107de1abf
llvm::DwarfDebug::finalizeModuleInfo() + 479
6  llc                      0x0000000107de1ed4
llvm::DwarfDebug::endModule() + 68
7  llc                      0x0000000107db7a06
llvm::AsmPrinter::doFinalization(llvm::Module&) + 1910
8  llc                      0x00000001082ac146
llvm::FPPassManager::doFinalization(llvm::Module&) + 70
9  llc                      0x00000001082ac603
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 1155
10 llc                      0x0000000106ddf2c6 compileModule(char**,
llvm::LLVMContext&) + 9654
11 llc                      0x0000000106ddca9c main + 1436
12 libdyld.dylib            0x00007fff7bb7f015 start + 1
-: The file was not recognized as a valid object file


On Tue, Sep 25, 2018 at 12:11 AM Hsiangkai Wang via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: hsiangkai
> Date: Mon Sep 24 23:09:50 2018
> New Revision: 342943
>
> URL: http://llvm.org/viewvc/llvm-project?rev=342943&view=rev
> Log:
> [DebugInfo] Do not generate address info for removed debug labels.
>
> In some senario, LLVM will remove llvm.dbg.labels in IR. For example,
> when the labels are in unreachable blocks, these labels will not
> be generated in LLVM IR. In the case, these debug labels will have
> address zero as their address. It is not legal address for debugger to
> set breakpoints or query sources. So, the patch inhibits the address info
> (DW_AT_low_pc) of removed labels.
>
> Differential Revision: https://reviews.llvm.org/D51908
>
> Added:
>     llvm/trunk/test/DebugInfo/Generic/debug-label-unreached.ll
> Modified:
>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=342943&r1=342942&r2=342943&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Mon Sep 24
> 23:09:50 2018
> @@ -865,10 +865,9 @@ void DwarfCompileUnit::finishEntityDefin
>        llvm_unreachable("DbgEntity must be DbgVariable or DbgLabel.");
>    }
>
> -  if (Label) {
> -    const MCSymbol *Sym = Label->getSymbol();
> -    addLabelAddress(*Die, dwarf::DW_AT_low_pc, Sym);
> -  }
> +  if (Label)
> +    if (const auto *Sym = Label->getSymbol())
> +      addLabelAddress(*Die, dwarf::DW_AT_low_pc, Sym);
>  }
>
>  DbgEntity *DwarfCompileUnit::getExistingAbstractEntity(const DINode
> *Node) {
>
> Added: llvm/trunk/test/DebugInfo/Generic/debug-label-unreached.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/debug-label-unreached.ll?rev=342943&view=auto
>
> ==============================================================================
> --- llvm/trunk/test/DebugInfo/Generic/debug-label-unreached.ll (added)
> +++ llvm/trunk/test/DebugInfo/Generic/debug-label-unreached.ll Mon Sep 24
> 23:09:50 2018
> @@ -0,0 +1,39 @@
> +; Test unreachable llvm.dbg.label
> +;
> +; RUN: llc -filetype=obj -split-dwarf-file debug.dwo -o - %s |
> llvm-dwarfdump -v - | FileCheck %s
> +;
> +; CHECK: .debug_info.dwo contents:
> +; CHECK: DW_TAG_label
> +; CHECK-NEXT: DW_AT_name {{.*}}"done"
> +; CHECK-NOT: {{DW_TAG|NULL}}
> +; CHECK: DW_AT_low_pc
> +; CHECK: DW_TAG_label
> +; CHECK-NEXT: DW_AT_name {{.*}}"removed"
> +; CHECK-NOT: DW_AT_low_pc
> +source_filename = "debug-label-unreached.c"
> +
> +define dso_local i32 @foo(i32 %a, i32 %b) !dbg !8 {
> +entry:
> +  %sum = add nsw i32 %a, %b, !dbg !12
> +  call void @llvm.dbg.label(metadata !11), !dbg !12
> +  ret i32 %sum, !dbg !13
> +}
> +
> +declare void @llvm.dbg.label(metadata)
> +
> +!llvm.dbg.cu = !{!0}
> +!llvm.module.flags = !{!4}
> +
> +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1,
> isOptimized: true, emissionKind: FullDebug, enums: !2)
> +!1 = !DIFile(filename: "debug-label-unreached.c", directory: "./")
> +!2 = !{}
> +!4 = !{i32 2, !"Debug Info Version", i32 3}
> +!5 = !DISubroutineType(types: !6)
> +!6 = !{!7}
> +!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
> +!8 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 8,
> type: !5, isLocal: false, isDefinition: true, scopeLine: 9, flags:
> DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !9)
> +!9 = !{!10, !11}
> +!10 = !DILabel(scope: !8, name: "removed", file: !1, line: 11)
> +!11 = !DILabel(scope: !8, name: "done", file: !1, line: 13)
> +!12 = !DILocation(line: 13, column: 1, scope: !8)
> +!13 = !DILocation(line: 14, column: 5, scope: !8)
>
>
> _______________________________________________
> 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/20180925/e60ce5fd/attachment.html>


More information about the llvm-commits mailing list