Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inlinedAt debug locations #13431

Merged
merged 1 commit into from
Oct 3, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
@@ -4414,6 +4414,7 @@ static Function *emit_function(jl_lambda_info_t *lam)
}
}
ctx.lineno = lno;
int toplineno = lno;

DIBuilder dbuilder(*m);
ctx.dbuilder = &dbuilder;
@@ -4994,31 +4995,32 @@ static Function *emit_function(jl_lambda_info_t *lam)
MDNode *funcscope = (MDNode*)dbuilder.createLexicalBlockFile(SP, topfile);
MDNode *scope;
if ((dfil == topfile || dfil == NULL) &&
lno >= ctx.lineno) // if we are in the top-level file
// and the current lineno is less than
// the last, must be same-file inline
// TODO: improve this heuristic...
lno >= toplineno)
{
// set location to the current top-level line
// for sequentially-defined code,
// set location to line in top file.
// TODO: improve handling of nested inlines
loc = DebugLoc::get(lno, 1, SP, NULL);
} else {
// otherwise, we are compiling code from another file,
// so create a location for the top-level line, and
// set the DebugLoc "inlinedAt" parameter.
// otherwise, we are compiling inlined code,
// so set the DebugLoc "inlinedAt" parameter
// to the current line, then use source loc.
#ifdef LLVM37
scope = (MDNode*)dbuilder.createLexicalBlockFile(SP,dfil);
MDNode *inlineLocMd = DebugLoc::get(ctx.lineno, 1, funcscope, NULL).getAsMDNode();
MDNode *inlineLocMd = DebugLoc::get(toplineno, 1, funcscope, NULL).
getAsMDNode();
#else
scope = (MDNode*)dbuilder.createLexicalBlockFile(SP,DIFile(dfil));
MDNode *inlineLocMd = DebugLoc::get(ctx.lineno, 1, funcscope, NULL).getAsMDNode(jl_LLVMContext);
MDNode *inlineLocMd = DebugLoc::get(toplineno, 1, funcscope, NULL).
getAsMDNode(jl_LLVMContext);
#endif
loc = DebugLoc::get(lno, 1, scope, inlineLocMd);
}
builder.SetCurrentDebugLocation(loc);
}
if (do_coverage)
coverageVisitLine(filename, lno);
ctx.lineno = lno;
ctx.lineno = lno; // NOO TOUCHIE; NO TOUCH! See #922
}
if (jl_is_labelnode(stmt)) {
if (prevlabel) continue;
2 changes: 2 additions & 0 deletions test/backtrace.jl
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@ eval(Expr(:function, Expr(:call, :test_inline_1),
# different-file inline
eval(Expr(:function, Expr(:call, :test_inline_2),
Expr(:block, LineNumberNode(symbol("backtrace.jl"), 99),
LineNumberNode(symbol("foobar.jl"), 666),
LineNumberNode(symbol("/foo/bar/baz.jl"), 111),
Expr(:call, :throw, "foo"))))

@@ -74,6 +75,7 @@ loc = functionloc(f12977)
@test endswith(loc[1], "backtrace.jl")
@test loc[2] == linenum

# issue #922: SimplifyCFG pass merges throws
code_loc(p, skipC=true) = ccall(:jl_lookup_code_address, Any, (Ptr{Void},Cint), p, skipC)

@noinline function test_throw_commoning(x)