[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
Tue Feb 14 09:34:05 PST 2017


dblaikie added inline comments.


================
Comment at: lib/CodeGen/LexicalScopes.cpp:82
+      // Ignore locations linked from a NoDebug compile unit.
+      auto *SP = dyn_cast<DISubprogram>(MIDL->getScope());
+      if (SP && SP->getUnit()->getEmissionKind() == DICompileUnit::NoDebug) {
----------------
This probably won't catch all cases - if the location was in a subscope within the function (eg: try adding a {} to the function which should add an extra scope). Walking the scope chain until a DISubprogram is probably needed here - I forget if we have a nice wrapped up utility for that. Don't see one at a glance.

It should be an invariant/guaranteed that a DISubprogram is reached (& is the end of the scope chain), so something like:

oh, wait, no, here it is: http://llvm.org/docs/doxygen/html/classllvm_1_1DILocalScope.html#a747dd1690fc477a8d9638fa37a30ced8

so, I think, maybe:

  if (cast<DILocalScope>(MIDL->getScope())->getSubprogram()->getUnit()->getEmissionKind() == DICompileUnit::NoDebug) {
    ...


================
Comment at: test/DebugInfo/Generic/debug_and_nodebug_CUs.ll:4
+
+; RUN: llc %s -o - | FileCheck %s
+; CHECK-DAG: # debug.c:
----------------
Include the steps for reproducing this test case (basically the RUN lines, and the original C source/steps for producing the IR, from the first version of the test) - helps to visualize/document/reproduce the situation.


https://reviews.llvm.org/D29765





More information about the llvm-commits mailing list