]> granicus.if.org Git - llvm/commitdiff
[DebugInfo] Consider debug label scope has an extra lexical block file
authorTaewook Oh <twoh@fb.com>
Wed, 14 Aug 2019 17:58:45 +0000 (17:58 +0000)
committerTaewook Oh <twoh@fb.com>
Wed, 14 Aug 2019 17:58:45 +0000 (17:58 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368891 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
test/DebugInfo/Generic/debug-label.ll

index 61cb46cb4bb6a345311ac5192163d5b6c5805bf9..0319f256c6ef47abacc023be2a9152cc6686a0d9 100644 (file)
@@ -910,7 +910,8 @@ static bool emitDebugLabelComment(const MachineInstr *MI, AsmPrinter &AP) {
   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 << ":";
index bfde1cf626c234a7c6e4f0405cf9f042f68147c5..d828c9097e943eb7b477b6fc666be06293261de6 100644 (file)
@@ -1603,11 +1603,14 @@ void DwarfDebug::collectEntityInfo(DwarfCompileUnit &TheCU,
 
     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;
index 57a0e952dea5e50db880d4c676d3c6e69e97ea1e..9139c98028dbde9d83194367a44d191dad4be773 100644 (file)
@@ -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)