<div dir="ltr">Thanks for explaining - that sounds broadly right. Could you include a minimal test case for this situation? You shouldn't need to involve LTO in the test case itself - two (say, C or C++) source files compiled to IR, llvm-link'd together & then the test case should probably be running llc on that IR file. You can see other test cases for debug info in the test/DebugInfo directory of LLVM's source.<br><br><div class="gmail_quote"><div dir="ltr">On Thu, May 3, 2018 at 8:55 AM Yunlian Jiang via Phabricator <<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">yunlian updated this revision to Diff 145027.<br>
yunlian added a comment.<br>
<br>
It looks like this error comes from the mixing of LTO, debug fission and -fdebug-info-for-profiling.<br>
<br>
In <br>
DwarfCompileUnit::constructAbstractSubprogramScopeDIE, we would not run<br>
getOrCreateSubprogramDIE if includeMinimalInlineScopes() returns True.<br>
<br>
In  DwarfUnit::applySubprogramAttributes, we would  run<br>
DwarfUnit::applySubprogramDefinitionAttributes if includeMinimalInlineScopes() returns False or -fdebug-info-for-profiling is set.<br>
<br>
In my case,  includeMinimalInlineScopes returns True and -fdebug-info-for-profiling is set. So it did not call getOrCreateSubprogramDIE<br>
but it calls DwarfUnit::applySubprogramDefinitionAttributes to trigger the assertion.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D46137" rel="noreferrer" target="_blank">https://reviews.llvm.org/D46137</a><br>
<br>
Files:<br>
  lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
<br>
<br>
Index: lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
===================================================================<br>
--- lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
+++ lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
@@ -1007,6 +1007,6 @@<br>
 }<br>
<br>
 bool DwarfCompileUnit::includeMinimalInlineScopes() const {<br>
-  return getCUNode()->getEmissionKind() == DICompileUnit::LineTablesOnly ||<br>
-         (DD->useSplitDwarf() && !Skeleton);<br>
+  return (getCUNode()->getEmissionKind() == DICompileUnit::LineTablesOnly ||<br>
+         (DD->useSplitDwarf() && !Skeleton)) && !getCUNode()->getDebugInfoForProfiling();<br>
 }<br>
<br>
<br>
</blockquote></div></div>