Skip to content

Commit 5f6d8e8

Browse files
committed
[DebugInfo] Set the autogenerated bit to request recycled locations
IRGenDebugInfo expects to see an autogenerated bit before allowing reuse of the last seen debug location for a new instruction. rdar://28544248
1 parent c3ba8ff commit 5f6d8e8

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,8 +1789,11 @@ void IRGenSILFunction::visitSILBasicBlock(SILBasicBlock *BB) {
17891789
auto Prev = --I.getIterator();
17901790
if (Prev != BB->end())
17911791
DS = Prev->getDebugScope();
1792-
// Use an artificial (line 0) location.
1793-
IGM.DebugInfo->setCurrentLoc(Builder, DS, None);
1792+
1793+
// Use an artificial (line 0) location, to indicate we'd like to
1794+
// reuse the last debug loc.
1795+
IGM.DebugInfo->setCurrentLoc(
1796+
Builder, DS, RegularLocation::getAutoGeneratedLocation());
17941797
}
17951798

17961799
if (isa<TermInst>(&I))

test/DebugInfo/returnlocation.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,18 @@ public func cleanup_simple_complex(_ a: NSString) -> Int64 {
178178
}
179179

180180
// ---------------------------------------------------------------------
181+
182+
// RUN: %FileCheck %s --check-prefix=CHECK_INIT < %t.ll
183+
// CHECK_INIT: define {{.*}}$S4main6Class1CACSgycfc
184+
public class Class1 {
185+
public required init?() {
186+
print("hello")
187+
// CHECK_INIT: call {{.*}}@"$Ss5print_9separator10terminatoryypd_S2StF"{{.*}}, !dbg [[printLoc:![0-9]+]]
188+
// CHECK_INIT-NEXT: call void @swift_bridgeObjectRelease{{.*}}, !dbg [[retnLoc:![0-9]+]]
189+
// CHECK_INIT: br label {{.*}}, !dbg [[retnLoc]]
190+
191+
// CHECK_INIT: [[printLoc]] = !DILocation(line: [[@LINE-5]]
192+
// CHECK_INIT: [[retnLoc]] = !DILocation(line: [[@LINE+1]]
193+
return nil
194+
}
195+
}

0 commit comments

Comments
 (0)