Fix debug info builds with inlining on

This is likely an LLVM bug: The code in InlineFunctions.cpp
only updates the source location metadata for the instructions
in the inlined callee when the call site has a source location
set. When the caller has no location metadata, the scope for
the inlined instructions thus still points to the DISubprogram
for the original callee. This then leads to an assertion during
codegen.

GitHub: Fixes #998.
This commit is contained in:
David Nadlinger 2015-07-12 22:30:41 +02:00
parent 4571411b66
commit 4e2bc18957
2 changed files with 12 additions and 2 deletions

View file

@ -833,7 +833,13 @@ void ldc::DIBuilder::EmitBlockEnd()
void ldc::DIBuilder::EmitStopPoint(Loc& loc)
{
if (!global.params.symdebug || !loc.linnum)
if (!global.params.symdebug)
return;
// If we already have a location set and the current loc is invalid
// (line 0), then we can just ignore it (see GitHub issue #998 for why we
// cannot do this in all cases).
if (!loc.linnum && !IR->ir->getCurrentDebugLocation().isUnknown())
return;
Logger::println("D to dwarf stoppoint at line %u, column %u", loc.linnum, loc.charnum);