[PATCH] D60713: [IR] Add DISuprogram and DIE for func decl of an external

Djordje Todorovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 31 05:12:06 PDT 2019


djtodoro updated this revision to Diff 202417.
djtodoro added a comment.

-Remove the SP flag
-Attach a unique `sp` to a declaration for the purpose of call site dbg info


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60713/new/

https://reviews.llvm.org/D60713

Files:
  lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  lib/IR/Verifier.cpp
  test/Verifier/metadata-function-dbg.ll


Index: test/Verifier/metadata-function-dbg.ll
===================================================================
--- test/Verifier/metadata-function-dbg.ll
+++ test/Verifier/metadata-function-dbg.ll
@@ -1,8 +1,11 @@
 ; RUN: llvm-as %s -disable-output 2>&1 | FileCheck %s
 
-; CHECK:      function declaration may not have a !dbg attachment
+; CHECK:      function declaration may only have a unique !dbg attachment
 declare !dbg !4 void @f1()
 
+; CHECK-NOT:      function declaration may only have a unique !dbg attachment
+declare !dbg !6 void @f5()
+
 ; CHECK:      function must have a single !dbg attachment
 define void @f2() !dbg !4 !dbg !4 {
   unreachable
@@ -31,7 +34,9 @@
 !0 = !{i32 2, !"Debug Info Version", i32 3}
 
 !llvm.dbg.cu = !{!1}
-!1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2)
+!1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, retainedTypes: !5)
 !2 = !DIFile(filename: "t.c", directory: "/path/to/dir")
 !3 = !{}
 !4 = distinct !DISubprogram(name: "foo", scope: !1, file: !2, unit: !1)
+!5 = !{!6}
+!6 = !DISubprogram(name: "f5", scope: !1, file: !2, unit: !1, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
Index: lib/IR/Verifier.cpp
===================================================================
--- lib/IR/Verifier.cpp
+++ lib/IR/Verifier.cpp
@@ -2223,8 +2223,9 @@
            MDs.empty() ? nullptr : MDs.front().second);
   } else if (F.isDeclaration()) {
     for (const auto &I : MDs) {
-      AssertDI(I.first != LLVMContext::MD_dbg,
-               "function declaration may not have a !dbg attachment", &F);
+      AssertDI(I.first != LLVMContext::MD_dbg ||
+               !cast<DISubprogram>(I.second)->isDistinct(),
+               "function declaration may only have a unique !dbg attachment", &F);
       Assert(I.first != LLVMContext::MD_prof,
              "function declaration may not have a !prof attachment", &F);
 
Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -669,6 +669,11 @@
     NewCU.setSection(Asm->getObjFileLowering().getDwarfInfoSection());
   }
 
+  // Create DIEs for function declaraions used for dbg call sites.
+  for (auto Scope : DIUnit->getRetainedTypes())
+    if (auto *SP = dyn_cast_or_null<DISubprogram>(Scope))
+      NewCU.getOrCreateSubprogramDIE(SP);
+
   CUMap.insert({DIUnit, &NewCU});
   CUDieMap.insert({&NewCU.getUnitDie(), &NewCU});
   return NewCU;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60713.202417.patch
Type: text/x-patch
Size: 2521 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190531/1e668501/attachment.bin>


More information about the llvm-commits mailing list