This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Removed assert on missing CountVarDIE
ClosedPublic

Authored by sdesmalen on Feb 16 2018, 7:42 AM.

Details

Summary

The assert for a DISubrange's CountVarDIE to be available fails
when the dbg.value() has been optimized away for any reason.
Having the assert for that is a little heavy, so instead removing
it now in favor of not generating the 'count' expression.

Addresses http://llvm.org/PR36263 .

Diff Detail

Event Timeline

sdesmalen created this revision.Feb 16 2018, 7:42 AM
sdesmalen edited the summary of this revision. (Show Details)Feb 16 2018, 7:53 AM
aprantl added inline comments.Feb 16 2018, 8:39 AM
lib/CodeGen/AsmPrinter/DwarfUnit.cpp
1391

Why not:

if (auto *CV = SR->getCount().dyn_cast<DIVariable*>()) {
  if (DIE *CountVarDIE = getDIE(CV))
    addDIEEntry(DW_Subrange, dwarf::DW_AT_count, *CountVarDIE);
  else
     // should this. case be handled?
} else if (Count != -1)
  addUInt(DW_Subrange, dwarf::DW_AT_count, None, Count);
sdesmalen updated this revision to Diff 134645.Feb 16 2018, 9:24 AM
sdesmalen marked an inline comment as done.

Can you add a testcase by, e.g, manually removing the dbg.value for the count from an existing testcase?

lib/CodeGen/AsmPrinter/DwarfUnit.cpp
1392

That else statement was more meant as a question for you :-)

sdesmalen updated this revision to Diff 134704.Feb 16 2018, 1:08 PM
  • Renamed test/DebugInfo/Generic/disubrange.ll -> test/DebugInfo/Generic/disubrange_vla.ll
  • Added test/DebugInfo/Generic/disubrange_vla_no_dbgvalue.ll
lib/CodeGen/AsmPrinter/DwarfUnit.cpp
1392

Ahh, I wasn't sure :-) So if there is not enough information about the 'count' at the point of arriving here, there isn't much else you can do than not generating the information. Of course it is best to make sure this doesn't happen without a good reason (hence https://reviews.llvm.org/D43386).

I expect this code to undergo some more changes in the near future because it doesn't work properly with inlining (http://llvm.org/PR36323) and so needs more effort to better retrieve the DIEs for inlined count expressions and to generate correct DWARF for the inlined variable-length types. I started looking into that, but haven't had the time to come up with a patch yet.

aprantl accepted this revision.Feb 16 2018, 1:30 PM
This revision is now accepted and ready to land.Feb 16 2018, 1:30 PM
This revision was automatically updated to reflect the committed changes.

Yes, that seems like the same issue, thanks for pointing out!