mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-07 03:16:05 +03:00
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:
parent
4571411b66
commit
4e2bc18957
2 changed files with 12 additions and 2 deletions
|
@ -833,7 +833,13 @@ void ldc::DIBuilder::EmitBlockEnd()
|
||||||
|
|
||||||
void ldc::DIBuilder::EmitStopPoint(Loc& loc)
|
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;
|
return;
|
||||||
|
|
||||||
Logger::println("D to dwarf stoppoint at line %u, column %u", loc.linnum, loc.charnum);
|
Logger::println("D to dwarf stoppoint at line %u, column %u", loc.linnum, loc.charnum);
|
||||||
|
|
|
@ -204,7 +204,11 @@ static llvm::Function* build_module_function(const std::string &name, const std:
|
||||||
IRBuilder<> builder(bb);
|
IRBuilder<> builder(bb);
|
||||||
|
|
||||||
// debug info
|
// debug info
|
||||||
gIR->DBuilder.EmitModuleCTor(fn, name.c_str());
|
llvm::DISubprogram dis = gIR->DBuilder.EmitModuleCTor(fn, name.c_str());
|
||||||
|
if (global.params.symdebug) {
|
||||||
|
// Need _some_ debug info to avoid inliner bug, see GitHub issue #998.
|
||||||
|
builder.SetCurrentDebugLocation(llvm::DebugLoc::get(0, 0, dis));
|
||||||
|
}
|
||||||
|
|
||||||
// Call ctor's
|
// Call ctor's
|
||||||
typedef std::list<FuncDeclaration*>::const_iterator FuncIterator;
|
typedef std::list<FuncDeclaration*>::const_iterator FuncIterator;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue