Skip to content

Commit a6db5e9

Browse files
author
Davide Italiano
committed
[SILGen] Make sure profile increments gets assigned the correct scope.
<rdar://problem/46686369>
1 parent c932f60 commit a6db5e9

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/SILGen/SILGenStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,8 +680,8 @@ void StmtEmitter::visitGuardStmt(GuardStmt *S) {
680680
// Note that we don't push break/continue locations since they aren't valid
681681
// in this statement.
682682
SILGenSavedInsertionPoint savedIP(SGF, bodyBB.getBlock());
683-
SGF.emitProfilerIncrement(S->getBody());
684683
SGF.emitStmt(S->getBody());
684+
SGF.emitProfilerIncrement(S->getBody());
685685

686686
// The body block must end in a noreturn call, return, break etc. It
687687
// isn't valid to fall off into the normal flow. To model this, we emit
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %target-swift-frontend -Onone -emit-silgen -profile-generate \
2+
// RUN: -sil-verify-all -Xllvm -sil-print-debuginfo %s | %FileCheck %s
3+
4+
// <rdar://problem/46686369>
5+
// REQUIRES: objc_interop
6+
7+
// CHECK: bb4:
8+
// CHECK: integer_literal $Builtin.Int64, 0, loc "{{.*}}":18:10, scope 2
9+
// CHECK-NEXT: integer_literal $Builtin.Int32, 2, loc "{{.*}}":18:10, scope 2
10+
// CHECK-NEXT: integer_literal $Builtin.Int32, 1, loc "{{.*}}":18:10, scope 2
11+
// CHECK-NEXT: builtin "int_instrprof_increment"(%31 : $Builtin.RawPointer, %32 : $Builtin.Int64, %33 : $Builtin.Int32, %34 : $Builtin.Int32) : $(), loc "{{.*}}":18:10, scope 2
12+
// CHECK-NEXT: unreachable , loc "{{.*}}":16:1, scope 2
13+
14+
15+
import Foundation
16+
guard let patatino: URL = {
17+
return nil
18+
}() else {
19+
exit(0)
20+
}

0 commit comments

Comments
 (0)