This makes the assertion in PR37255 disappear.
Hi there :)
Just a note: There's no need to file a bug if you're already working on the
fix anyway. It's probably easier/quicker to provide all the context in the
patch/review rather than referring to a bug anyway.
This change will need a test case - and the test case might help explain
why/whether or not this is necessary/what's happening here & whether this
is the right approach to address it.
It looks like this error comes from the mixing of LTO, debug fission and -fdebug-info-for-profiling.
DwarfCompileUnit::constructAbstractSubprogramScopeDIE, we would not run
getOrCreateSubprogramDIE if includeMinimalInlineScopes() returns True.
In DwarfUnit::applySubprogramAttributes, we would run
DwarfUnit::applySubprogramDefinitionAttributes if includeMinimalInlineScopes() returns False or -fdebug-info-for-profiling is set.
In my case, includeMinimalInlineScopes returns True and -fdebug-info-for-profiling is set. So it did not call getOrCreateSubprogramDIE
but it calls DwarfUnit::applySubprogramDefinitionAttributes to trigger the assertion.
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.