1; RUN: split-file %s %t 2; RUN: llc < %t/1.ll -mtriple=x86_64 | FileCheck %s --check-prefix=DEBUG_FRAME 3; RUN: llc < %t/1.ll -mtriple=x86_64 -force-dwarf-frame-section | FileCheck %s --check-prefix=DEBUG_FRAME 4; RUN: llc < %t/2.ll -mtriple=x86_64 | FileCheck %s --check-prefix=EH_FRAME 5; RUN: llc < %t/2.ll -mtriple=x86_64 -force-dwarf-frame-section | FileCheck %s --check-prefix=BOTH 6; RUN: llc < %t/3.ll -mtriple=x86_64 | FileCheck %s --check-prefix=EH_FRAME 7; RUN: llc < %t/3.ll -mtriple=x86_64 -force-dwarf-frame-section | FileCheck %s --check-prefix=BOTH 8 9; EH_FRAME-NOT: .cfi_sections 10; DEBUG_FRAME: .cfi_sections .debug_frame{{$}} 11; BOTH: .cfi_sections .eh_frame, .debug_frame{{$}} 12 13;--- 1.ll 14;; No function has uwtable/personality or throws && f needs debug info -> emit .debug_frame 15 16define void @f() nounwind !dbg !6 { 17entry: 18 ret void 19} 20 21define void @g() nounwind { 22entry: 23 ret void 24} 25 26!llvm.dbg.cu = !{!0} 27!llvm.module.flags = !{!3, !4, !5} 28 29!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) 30!1 = !DIFile(filename: "a.c", directory: "/tmp") 31!2 = !{} 32!3 = !{i32 7, !"Dwarf Version", i32 5} 33!4 = !{i32 2, !"Debug Info Version", i32 3} 34!5 = !{i32 1, !"wchar_size", i32 4} 35!6 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !7, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) 36!7 = !DISubroutineType(types: !8) 37!8 = !{null} 38!9 = !DILocation(line: 1, column: 15, scope: !6) 39 40;--- 2.ll 41;; g has uwtable and thus needs .eh_frame 42 43define void @f() nounwind !dbg !6 { 44entry: 45 ret void 46} 47 48define void @g() nounwind uwtable !dbg !10 { 49entry: 50 ret void 51} 52 53!llvm.dbg.cu = !{!0} 54!llvm.module.flags = !{!3, !4, !5} 55 56!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) 57!1 = !DIFile(filename: "a.c", directory: "/tmp") 58!2 = !{} 59!3 = !{i32 7, !"Dwarf Version", i32 5} 60!4 = !{i32 2, !"Debug Info Version", i32 3} 61!5 = !{i32 1, !"wchar_size", i32 4} 62!6 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !7, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) 63!7 = !DISubroutineType(types: !8) 64!8 = !{null} 65!9 = !DILocation(line: 1, column: 15, scope: !6) 66!10 = distinct !DISubprogram(name: "g", scope: !1, file: !1, line: 2, type: !7, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) 67!11 = !DILocation(line: 2, column: 15, scope: !10) 68 69;--- 3.ll 70;; g has no nounwind, so it is treated as throwable. Emit .eh_frame. 71 72define void @f() nounwind !dbg !6 { 73entry: 74 ret void 75} 76 77define void @g() !dbg !10 { 78entry: 79 ret void 80} 81 82!llvm.dbg.cu = !{!0} 83!llvm.module.flags = !{!3, !4, !5} 84 85!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) 86!1 = !DIFile(filename: "a.c", directory: "/tmp") 87!2 = !{} 88!3 = !{i32 7, !"Dwarf Version", i32 5} 89!4 = !{i32 2, !"Debug Info Version", i32 3} 90!5 = !{i32 1, !"wchar_size", i32 4} 91!6 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !7, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) 92!7 = !DISubroutineType(types: !8) 93!8 = !{null} 94!9 = !DILocation(line: 1, column: 15, scope: !6) 95!10 = distinct !DISubprogram(name: "g", scope: !1, file: !1, line: 2, type: !7, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) 96!11 = !DILocation(line: 2, column: 15, scope: !10) 97