[PATCH] D29765: Handle link of NoDebug CU with a CU that has debug emission enabled

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 16 11:31:45 PST 2017


dblaikie added a comment.

I was hoping to simplify this a bit by having DwarfDebug (well, DebugHandlerBase) filter and never try to build a LexicalScopes for a non-debug-having function (so it wouldn't need the filter at the start of LexicalScopes::initialize), except LiveDebugValues also creates LexicalScopes and doesn't have any existing filtering/probably shouldn't have any.

So I'm back around to basically this change, with a couple of questions.



================
Comment at: lib/CodeGen/LexicalScopes.cpp:87-94
+      // unit, but we could have instructions within a function body
+      // inlined from elsewhere in LTO mode).
+      auto *SP = dyn_cast<DISubprogram>(MIDL->getScope());
+      if (SP && SP->getUnit()->getEmissionKind() == DICompileUnit::NoDebug) {
+        PrevMI = &MInsn;
+        continue;
+      }
----------------
Which test case/behavior does this address that the change in getOrCreateLexicalScope wasn't able to handle?


================
Comment at: lib/CodeGen/LexicalScopes.cpp:182-184
+  assert(
+      I->second.getScopeNode()->getSubprogram()->getUnit()->getEmissionKind() !=
+      DICompileUnit::NoDebug);
----------------
What about asserting in LexicalScope's ctor? 

This was what I tried & seemed to provide the checking desired?

diff --git include/llvm/CodeGen/LexicalScopes.h include/llvm/CodeGen/LexicalScopes.h
index 7d7e48af2a0..b6d524fce44 100644
--- include/llvm/CodeGen/LexicalScopes.h
+++ include/llvm/CodeGen/LexicalScopes.h
@@ -49,7 +49,11 @@ public:
                bool A)
       : Parent(P), Desc(D), InlinedAtLocation(I), AbstractScope(A),
         LastInsn(nullptr), FirstInsn(nullptr), DFSIn(0), DFSOut(0) {
-    assert((!D || D->isResolved()) && "Expected resolved node");
+    assert(D);
+    assert(D->getSubprogram()->getUnit()->getEmissionKind() !=
+               DICompileUnit::NoDebug &&
+           "Don't build lexical scopes for non-debug locations");
+    assert(D->isResolved() && "Expected resolved node");
     assert((!I || I->isResolved()) && "Expected resolved node");
     if (Parent)
       Parent->addChild(this);


https://reviews.llvm.org/D29765





More information about the llvm-commits mailing list