Skip to content

[SILGen] Make sure profile increments gets assigned the correct scope. #21620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/SILGen/SILGenStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,8 @@ void StmtEmitter::visitGuardStmt(GuardStmt *S) {
// Note that we don't push break/continue locations since they aren't valid
// in this statement.
SILGenSavedInsertionPoint savedIP(SGF, bodyBB.getBlock());
SGF.emitProfilerIncrement(S->getBody());
SGF.emitStmt(S->getBody());
SGF.emitProfilerIncrement(S->getBody());

// The body block must end in a noreturn call, return, break etc. It
// isn't valid to fall off into the normal flow. To model this, we emit
Expand Down
20 changes: 20 additions & 0 deletions test/SILOptimizer/profile_debugscope.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// RUN: %target-swift-frontend -Onone -emit-silgen -profile-generate \
// RUN: -sil-verify-all -Xllvm -sil-print-debuginfo %s | %FileCheck %s

// <rdar://problem/46686369>
// REQUIRES: objc_interop

// CHECK: bb4:
// CHECK: integer_literal $Builtin.Int64, 0, loc "{{.*}}":18:10, scope 2
// CHECK-NEXT: integer_literal $Builtin.Int32, 2, loc "{{.*}}":18:10, scope 2
// CHECK-NEXT: integer_literal $Builtin.Int32, 1, loc "{{.*}}":18:10, scope 2
// CHECK-NEXT: builtin "int_instrprof_increment"(%31 : $Builtin.RawPointer, %32 : $Builtin.Int64, %33 : $Builtin.Int32, %34 : $Builtin.Int32) : $(), loc "{{.*}}":18:10, scope 2
// CHECK-NEXT: unreachable , loc "{{.*}}":16:1, scope 2


import Foundation
guard let patatino: URL = {
return nil
}() else {
exit(0)
}