[llvm] r368891 - [DebugInfo] Consider debug label scope has an extra lexical block file

Taewook Oh via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 14 10:58:45 PDT 2019


Author: twoh
Date: Wed Aug 14 10:58:45 2019
New Revision: 368891

URL: http://llvm.org/viewvc/llvm-project?rev=368891&view=rev
Log:
[DebugInfo] Consider debug label scope has an extra lexical block file

Summary: There are places where a case that debug label scope has an extra lexical block file is not considered properly. The modified test won't pass without this patch.

Reviewers: aprantl, HsiangKai

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D66187

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/trunk/test/DebugInfo/Generic/debug-label.ll

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=368891&r1=368890&r2=368891&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Aug 14 10:58:45 2019
@@ -910,7 +910,8 @@ static bool emitDebugLabelComment(const
   OS << "DEBUG_LABEL: ";
 
   const DILabel *V = MI->getDebugLabel();
-  if (auto *SP = dyn_cast<DISubprogram>(V->getScope())) {
+  if (auto *SP = dyn_cast<DISubprogram>(
+          V->getScope()->getNonLexicalBlockFileScope())) {
     StringRef Name = SP->getName();
     if (!Name.empty())
       OS << Name << ":";

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=368891&r1=368890&r2=368891&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Aug 14 10:58:45 2019
@@ -1603,11 +1603,14 @@ void DwarfDebug::collectEntityInfo(Dwarf
 
     LexicalScope *Scope = nullptr;
     const DILabel *Label = cast<DILabel>(IL.first);
+    // The scope could have an extra lexical block file.
+    const DILocalScope *LocalScope =
+        Label->getScope()->getNonLexicalBlockFileScope();
     // Get inlined DILocation if it is inlined label.
     if (const DILocation *IA = IL.second)
-      Scope = LScopes.findInlinedScope(Label->getScope(), IA);
+      Scope = LScopes.findInlinedScope(LocalScope, IA);
     else
-      Scope = LScopes.findLexicalScope(Label->getScope());
+      Scope = LScopes.findLexicalScope(LocalScope);
     // If label scope is not found then skip this label.
     if (!Scope)
       continue;

Modified: llvm/trunk/test/DebugInfo/Generic/debug-label.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/debug-label.ll?rev=368891&r1=368890&r2=368891&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/Generic/debug-label.ll (original)
+++ llvm/trunk/test/DebugInfo/Generic/debug-label.ll Wed Aug 14 10:58:45 2019
@@ -70,6 +70,7 @@ declare void @llvm.dbg.label(metadata)
 !9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
 !10 = !DILabel(scope: !6, name: "top", file: !1, line: 4)
 !11 = !DILocation(line: 4, column: 1, scope: !6)
-!12 = !DILabel(scope: !6, name: "done", file: !1, line: 7)
+!12 = !DILabel(scope: !15, name: "done", file: !1, line: 7)
 !13 = !DILocation(line: 7, column: 1, scope: !6)
 !14 = !DILocation(line: 8, column: 3, scope: !6)
+!15 = !DILexicalBlockFile(discriminator: 2, file: !1, scope: !6)




More information about the llvm-commits mailing list