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

debug-info: Add checks for instructions without source locations #4251

Closed
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
5 changes: 5 additions & 0 deletions toolchain/lower/function_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ auto FunctionContext::LowerInst(SemIR::InstId inst_id) -> void {
CARBON_VLOG() << "Lowering " << inst_id << ": " << inst << "\n";
builder_.getInserter().SetCurrentInstId(inst_id);
auto loc = file_context_->GetDiagnosticLoc(inst_id);
CARBON_CHECK(loc.filename == di_subprogram_->getFile()->getFilename())
<< "Instructions located in a different file from their enclosing "
"function aren't handled yet";
CARBON_CHECK(loc.line_number >= 1 && loc.column_number >= 1)
<< "Instructions without line locations aren't handled yet";
Comment on lines +101 to +105
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, I think this isn't catching the existing issues because it's not used everywhere GetDiagnosticLoc is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be sure, what I was noting here was that file_context.cpp also queries ConvertLoc. Since it won't use this code, the function missing a line number could be missed. That is, this would miss:

// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "__global_init", scope: null, file: !3, line: 4294967295, type: !5, spFlags: DISPFlagDefinition, unit: !2)

#4252 fixes this.

builder_.SetCurrentDebugLocation(
llvm::DILocation::get(builder_.getContext(), loc.line_number,
loc.column_number, di_subprogram_));
Expand Down
Loading