Skip to content

[DebugInfo] Set the autogenerated bit to request recycled locations #15929

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

Merged
merged 3 commits into from
Apr 13, 2018
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions lib/IRGen/IRGenDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
void finalize();

void setCurrentLoc(IRBuilder &Builder, const SILDebugScope *DS,
Optional<SILLocation> Loc = None);
SILLocation Loc);
void clearLoc(IRBuilder &Builder);
void pushLoc();
void popLoc();
Expand Down Expand Up @@ -1555,7 +1555,7 @@ void IRGenDebugInfoImpl::finalize() {

void IRGenDebugInfoImpl::setCurrentLoc(IRBuilder &Builder,
const SILDebugScope *DS,
Optional<SILLocation> Loc) {
SILLocation Loc) {
assert(DS && "empty scope");
auto *Scope = getOrCreateScope(DS);
if (!Scope)
Expand All @@ -1565,7 +1565,7 @@ void IRGenDebugInfoImpl::setCurrentLoc(IRBuilder &Builder,
SILFunction *Fn = DS->getInlinedFunction();
if (Fn && Fn->isThunk()) {
L = SILLocation::getCompilerGeneratedDebugLoc();
} else if (DS == LastScope && Loc && Loc->isAutoGenerated()) {
} else if (DS == LastScope && Loc.isAutoGenerated()) {
// Reuse the last source location if we are still in the same
// scope to get a more contiguous line table.
L = LastDebugLoc;
Expand All @@ -1574,7 +1574,7 @@ void IRGenDebugInfoImpl::setCurrentLoc(IRBuilder &Builder,
L = getDebugLocation(Loc);
// Otherwise use a line 0 artificial location, but the file from the
// location.
if (Loc && Loc->isAutoGenerated()) {
if (Loc.isAutoGenerated()) {
L.Line = 0;
L.Column = 0;
}
Expand Down Expand Up @@ -2056,7 +2056,7 @@ void IRGenDebugInfo::finalize() {
}

void IRGenDebugInfo::setCurrentLoc(IRBuilder &Builder, const SILDebugScope *DS,
Optional<SILLocation> Loc) {
SILLocation Loc) {
static_cast<IRGenDebugInfoImpl *>(this)->setCurrentLoc(Builder, DS, Loc);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/IRGen/IRGenDebugInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class IRGenDebugInfo {
/// Update the IRBuilder's current debug location to the location
/// Loc and the lexical scope DS.
void setCurrentLoc(IRBuilder &Builder, const SILDebugScope *DS,
Optional<SILLocation> Loc = None);
SILLocation Loc);

void clearLoc(IRBuilder &Builder);

Expand Down
7 changes: 5 additions & 2 deletions lib/IRGen/IRGenSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1789,8 +1789,11 @@ void IRGenSILFunction::visitSILBasicBlock(SILBasicBlock *BB) {
auto Prev = --I.getIterator();
if (Prev != BB->end())
DS = Prev->getDebugScope();
// Use an artificial (line 0) location.
IGM.DebugInfo->setCurrentLoc(Builder, DS);

// Use an artificial (line 0) location, to indicate we'd like to
// reuse the last debug loc.
IGM.DebugInfo->setCurrentLoc(
Builder, DS, RegularLocation::getAutoGeneratedLocation());
}

if (isa<TermInst>(&I))
Expand Down
15 changes: 15 additions & 0 deletions test/DebugInfo/returnlocation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,18 @@ public func cleanup_simple_complex(_ a: NSString) -> Int64 {
}

// ---------------------------------------------------------------------

// RUN: %FileCheck %s --check-prefix=CHECK_INIT < %t.ll
// CHECK_INIT: define {{.*}}$S4main6Class1CACSgycfc
public class Class1 {
public required init?() {
print("hello")
// CHECK_INIT: call {{.*}}@"$Ss5print_9separator10terminatoryypd_S2StF"{{.*}}, !dbg [[printLoc:![0-9]+]]
// CHECK_INIT-NEXT: call void @swift_bridgeObjectRelease{{.*}}, !dbg [[retnLoc:![0-9]+]]
// CHECK_INIT: br label {{.*}}, !dbg [[retnLoc]]

// CHECK_INIT: [[printLoc]] = !DILocation(line: [[@LINE-5]]
// CHECK_INIT: [[retnLoc]] = !DILocation(line: [[@LINE+1]]
return nil
}
}