[PATCH] D87499: [DebugInfo] Flang should not emit DW_AT_main_subprogram for DWARF version lower than 4
Alok Kumar Sharma via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 11 02:28:24 PDT 2020
alok created this revision.
alok added reviewers: aprantl, jmorse, dblaikie, SouraVX, jini.susan.george.
alok added a project: debug-info.
Herald added subscribers: llvm-commits, ormris, hiraditya.
Herald added a reviewer: DavidTruby.
Herald added a reviewer: sscalpone.
Herald added a project: LLVM.
alok requested review of this revision.
Summary:
DWARF attribute DW_AT_main_subprogram should be emitted with DWARF version 4 or greater.
Testing:
- check-llvm
- check-debuginfo
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D87499
Files:
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/test/DebugInfo/X86/dwarfdump-main-subprogram.ll
Index: llvm/test/DebugInfo/X86/dwarfdump-main-subprogram.ll
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/X86/dwarfdump-main-subprogram.ll
@@ -0,0 +1,31 @@
+;; check emission of DW_AT_main_subprogram is done for DWARF version >= 4
+; RUN: %llc_dwarf -dwarf-version 2 -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s --check-prefix=DWARF23
+; RUN: %llc_dwarf -dwarf-version 3 -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s --check-prefix=DWARF23
+; RUN: %llc_dwarf -dwarf-version 4 -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s --check-prefix=DWARF45
+; RUN: %llc_dwarf -dwarf-version 5 -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s --check-prefix=DWARF45
+
+; DWARF23-NOT: DW_AT_main_subprogram
+; DWARF45: DW_AT_main_subprogram (true)
+
+; ModuleID = 'dwarfdump_main_subprogram.ll'
+source_filename = "dwarfdump_main_subprogram.ll"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @MAIN_() #0 !dbg !5 {
+L.entry:
+ ret void, !dbg !8
+}
+
+!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_Fortran90, file: !3, producer: " F90 Flang - 1.5 2017-05-01", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !4, globals: !4, imports: !4)
+!3 = !DIFile(filename: "dwarfdump_main_subprogram.f90", directory: "/home/alok/amdllvm/llvm-project")
+!4 = !{}
+!5 = distinct !DISubprogram(name: "main", scope: !2, file: !3, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagMainSubprogram, unit: !2)
+!6 = !DISubroutineType(cc: DW_CC_program, types: !7)
+!7 = !{null}
+!8 = !DILocation(line: 2, column: 1, scope: !5)
Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1334,7 +1334,7 @@
if (SP->isExplicit())
addFlag(SPDie, dwarf::DW_AT_explicit);
- if (SP->isMainSubprogram())
+ if ((DD->getDwarfVersion() >= 4) && SP->isMainSubprogram())
addFlag(SPDie, dwarf::DW_AT_main_subprogram);
if (SP->isPure())
addFlag(SPDie, dwarf::DW_AT_pure);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87499.291163.patch
Type: text/x-patch
Size: 2404 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200911/c264e662/attachment.bin>
More information about the llvm-commits
mailing list