Skip to content

Commit

Permalink
[Profiler] Don't use presumed line numbers for profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
owenv committed May 26, 2020
1 parent 45bc578 commit 8b4d9ef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/SIL/IR/SILProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,8 +884,8 @@ struct CoverageMapping : public ASTWalker {
assert(Region.hasStartLoc() && "invalid region");
assert(Region.hasEndLoc() && "incomplete region");

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

Regions.emplace_back(Start.first, Start.second, End.first, End.second,
Expand Down
14 changes: 14 additions & 0 deletions test/Profiler/coverage_no_presumed_loc.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// RUN: %target-swift-frontend -suppress-warnings -profile-generate -profile-coverage-mapping -emit-sil -module-name coverage_no_presumed_loc %s | %FileCheck %s

func foo() {
var x : Int = 0

// CHECK-LABEL: sil_coverage_map {{.*}}// foo()
// CHECK: [[@LINE+3]]:10 -> [[@LINE+6]]:4
// CHECK-NOT: 200:10 -> 100:4
#sourceLocation(file: "foo.swift", line: 200)
repeat {
x += 1
#sourceLocation(file: "bar.swift", line: 100)
} while x < 10
}

0 comments on commit 8b4d9ef

Please sign in to comment.