Skip to content

Commit d21d216

Browse files
committed
[5.10] [Profiler] Remove an assertion
Due to the recent change to how we simplify counters (rdar://118185163), we can now end up hitting this assertion for certain do-catch statements. The counter has always been wrong here, and previously would have underflowed at runtime (rdar://100470244). This issue has been properly fixed on main, but we haven't cherry-picked that fix to 5.10 since it requires a bunch of other changes. For now, just remove the assertion to maintain the previous behavior. rdar://118896974
1 parent bd4007f commit d21d216

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/SIL/IR/SILProfiler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,8 @@ struct CoverageMapping : public ASTWalker {
781781
/// Subtract \c Expr from \c Node's counter.
782782
void subtractFromCounter(ASTNode Node, CounterExpr Expr) {
783783
auto Counter = getCounter(Node);
784-
assert(!Counter.isZero() && "Cannot create a negative counter");
784+
// FIXME: This assertion ought to be restored (rdar://100470244)
785+
// assert(!Counter.isZero() && "Cannot create a negative counter");
785786
assignCounter(Node,
786787
CounterExpr::Sub(Counter, std::move(Expr), CounterBuilder));
787788
}

test/Profiler/rdar118896974.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %target-swift-frontend -profile-generate -profile-coverage-mapping -emit-ir %s
2+
3+
// rdar://118896974 - Make sure we don't crash.
4+
func foo() {
5+
do {
6+
return
7+
} catch {
8+
return
9+
}
10+
}

0 commit comments

Comments
 (0)