Skip to content

Commit 0562a83

Browse files
authored
Merge pull request swiftlang#32022 from owenv/profiler-fix
[Profiler] Don't use presumed line numbers for profiling
2 parents 5cd8ca4 + 8b4d9ef commit 0562a83

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/SIL/IR/SILProfiler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -884,8 +884,8 @@ struct CoverageMapping : public ASTWalker {
884884
assert(Region.hasStartLoc() && "invalid region");
885885
assert(Region.hasEndLoc() && "incomplete region");
886886

887-
auto Start = SM.getPresumedLineAndColumnForLoc(Region.getStartLoc());
888-
auto End = SM.getPresumedLineAndColumnForLoc(Region.getEndLoc());
887+
auto Start = SM.getLineAndColumnInBuffer(Region.getStartLoc());
888+
auto End = SM.getLineAndColumnInBuffer(Region.getEndLoc());
889889
assert(Start.first <= End.first && "region start and end out of order");
890890

891891
Regions.emplace_back(Start.first, Start.second, End.first, End.second,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %target-swift-frontend -suppress-warnings -profile-generate -profile-coverage-mapping -emit-sil -module-name coverage_no_presumed_loc %s | %FileCheck %s
2+
3+
func foo() {
4+
var x : Int = 0
5+
6+
// CHECK-LABEL: sil_coverage_map {{.*}}// foo()
7+
// CHECK: [[@LINE+3]]:10 -> [[@LINE+6]]:4
8+
// CHECK-NOT: 200:10 -> 100:4
9+
#sourceLocation(file: "foo.swift", line: 200)
10+
repeat {
11+
x += 1
12+
#sourceLocation(file: "bar.swift", line: 100)
13+
} while x < 10
14+
}

0 commit comments

Comments
 (0)