This is an archive of the discontinued LLVM Phabricator instance.

Fix an assertion of This DIE should've already been constructed when the " "definition DIE was created in " "getOrCreateSubprogramDIE
Needs ReviewPublic

Authored by yunlian on Apr 26 2018, 11:00 AM.

Details

Reviewers
dblaikie
Summary

This makes the assertion in PR37255 disappear.

Diff Detail

Repository
rL LLVM

Event Timeline

yunlian created this revision.Apr 26 2018, 11:00 AM

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.

yunlian updated this revision to Diff 145027.May 3 2018, 8:55 AM

It looks like this error comes from the mixing of LTO, debug fission and -fdebug-info-for-profiling.

In
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.

JDevlieghere added inline comments.May 3 2018, 12:56 PM
lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
1015

Can you please run clang-format over your change?