[llvm-bugs] [Bug 52363] New: case where llc crashes when DWARF are generated

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Oct 30 07:57:18 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=52363

            Bug ID: 52363
           Summary: case where llc crashes when DWARF are generated
           Product: new-bugs
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: b2.temp at gmx.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

the test case is reduced from the source language side to produce this ll file:

di_bug.ll:
---
; ModuleID = 'di_bug'
source_filename = "di_bug"

; Function Attrs: noinline
define i32 @main() #0 !dbg !7 {
entry:
  call void @di_bug.takeFun(void (i32)* @di_bug.main.27.__tmp0), !dbg !13
  ret i32 0, !dbg !14
}

; Function Attrs: noinline
define void @di_bug.takeFun(void (i32)* %0) #0 !dbg !15 {
entry:
  %1 = alloca void (i32)*, align 8
  store void (i32)* %0, void (i32)** %1, align 8
  call void @llvm.dbg.declare(metadata void (i32)** %1, metadata !20, metadata
!DIExpression()), !dbg !21
  ret void, !dbg !22
}

; Function Attrs: nounwind readnone speculatable willreturn
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1

; Function Attrs: noinline
define void @di_bug.main.27.__tmp0(i32 %0) #0 !dbg !24 {
entry:
  %1 = alloca i32, align 4
  store i32 %0, i32* %1, align 4
  call void @llvm.dbg.declare(metadata i32* %1, metadata !26, metadata
!DIExpression()), !dbg !27
  ret void, !dbg !28
}

attributes #0 = { noinline }
attributes #1 = { nounwind readnone speculatable willreturn }

!llvm.module.flags = !{!0, !1}
!llvm.dbg.cu = !{!2}

!0 = !{i32 2, !"Dwarf Version", i32 2}
!1 = !{i32 2, !"Debug Info Version", i32 3}
!2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "0.0.0",
isOptimized: false, runtimeVersion: 0, splitDebugFilename: "temp.txt",
emissionKind: FullDebug, enums: !4, splitDebugInlining: false)
!3 = !DIFile(filename: "di_bug.sx", directory: "/home/xxxx/Desktop/temp")
!4 = !{!5}
!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E", scope: !6, file:
!3, baseType: !10, size: 32, elements: !11)
!6 = distinct !DILexicalBlock(scope: !7, file: !3, line: 11, column: 5)
!7 = distinct !DISubprogram(name: "main", linkageName: "main", scope: !3, file:
!3, line: 8, type: !8, scopeLine: 8, flags: DIFlagPrototyped, spFlags:
DISPFlagLocalToUnit | DISPFlagDefinition, unit: !2, retainedNodes: !9)
!8 = !DISubroutineType(types: !9)
!9 = !{}
!10 = !DIBasicType(name: "u32", size: 32, encoding: DW_ATE_unsigned)
!11 = !{!12}
!12 = !DIEnumerator(name: "e", value: 0)
!13 = !DILocation(line: 11, column: 12, scope: !6)
!14 = !DILocation(line: 12, column: 5, scope: !6)
!15 = distinct !DISubprogram(name: "di_bug.takeFun", linkageName:
"di_bug.takeFun", scope: !3, file: !3, line: 19, type: !16, scopeLine: 19,
flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition,
unit: !2, retainedNodes: !9)
!16 = !DISubroutineType(types: !17)
!17 = !{!18}
!18 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "static function (E e)*",
baseType: !19, size: 64, align: 8, dwarfAddressSpace: 0)
!19 = !DIBasicType(tag: DW_TAG_unspecified_type, name: "static function (E e)")
!20 = !DILocalVariable(name: "afun", arg: 1, scope: !15, file: !3, line: 19,
type: !18)
!21 = !DILocation(line: 19, column: 18, scope: !15)
!22 = !DILocation(line: 21, column: 1, scope: !23)
!23 = distinct !DILexicalBlock(scope: !15, file: !3, line: 21, column: 1)
!24 = distinct !DISubprogram(name: "di_bug.main.27.__tmp0", linkageName:
"di_bug.main.27.__tmp0", scope: !3, file: !3, line: 11, type: !25, scopeLine:
11, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition,
unit: !2, retainedNodes: !9)
!25 = !DISubroutineType(types: !4)
!26 = !DILocalVariable(name: "e", arg: 1, scope: !24, file: !3, line: 11, type:
!5)
!27 = !DILocation(line: 11, column: 24, scope: !24)
!28 = !DILocation(line: 11, column: 34, scope: !29)
!29 = distinct !DILexicalBlock(scope: !24, file: !3, line: 11, column: 34)
---

If i feed LLC with that IR then it crashes

```bash
$ llc di_bug.ll
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace.
Stack dump:
0.      Program arguments: /usr/bin/llc --filetype=obj --relocation-model=pic
--mtriple=x86_64 -O0 
 #0 0x00007f848223527a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/lib64/libLLVM-11.so+0xa8b27a)
 #1 0x00007f84822334e4 llvm::sys::RunSignalHandlers()
(/lib64/libLLVM-11.so+0xa894e4)
 #2 0x00007f8482233676 (/lib64/libLLVM-11.so+0xa89676)
 #3 0x00007f8481434a70 __restore_rt (/lib64/libc.so.6+0x3da70)
 #4 0x00007f84829a7f40 llvm::DIE::getUnitDie() const
(/lib64/libLLVM-11.so+0x11fdf40)
 #5 0x00007f84829a7f99 llvm::DIE::getUnit() const
(/lib64/libLLVM-11.so+0x11fdf99)
 #6 0x00007f84829e10f7 llvm::DwarfUnit::getOrCreateTypeDIE(llvm::MDNode const*)
(/lib64/libLLVM-11.so+0x12370f7)
 #7 0x00007f84829d4588 llvm::DwarfDebug::beginModule()
(/lib64/libLLVM-11.so+0x122a588)
 #8 0x00007f848299311b llvm::AsmPrinter::doInitialization(llvm::Module&)
(/lib64/libLLVM-11.so+0x11e911b)
 #9 0x00007f848233f1de llvm::FPPassManager::doInitialization(llvm::Module&)
(/lib64/libLLVM-11.so+0xb951de)
#10 0x00007f848234a38e llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/lib64/libLLVM-11.so+0xba038e)
#11 0x000055e11873e73a (/usr/bin/llc+0x1373a)
#12 0x000055e118737436 main (/usr/bin/llc+0xc436)
#13 0x00007f848141f1e2 __libc_start_main (/lib64/libc.so.6+0x281e2)
#14 0x000055e11873754e _start (/usr/bin/llc+0xc54e)
```

I'd expect a warning saying at least that the meta data for debug info are not
valid and hence debug info wont be generated,

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211030/eb2c43a3/attachment-0001.html>


More information about the llvm-bugs mailing list