Skip to content

Commit 421d118

Browse files
authored
Merge pull request swiftlang#36062 from adrian-prantl/74538257
2 parents e854ac4 + c4c9981 commit 421d118

File tree

6 files changed

+26
-12
lines changed

6 files changed

+26
-12
lines changed

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5432,6 +5432,8 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
54325432
for (SILInstruction &SI : *BB) {
54335433
if (SI.isMetaInstruction())
54345434
continue;
5435+
if (SI.getLoc().getKind() == SILLocation::CleanupKind)
5436+
continue;
54355437

54365438
// If we haven't seen this debug scope yet, update the
54375439
// map and go on.

lib/SILGen/SILGenEpilog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ void SILGenFunction::emitRethrowEpilog(SILLocation topLevel) {
297297

298298
Cleanups.emitCleanupsForReturn(ThrowDest.getCleanupLocation(), IsForUnwind);
299299

300-
B.createThrow(throwLoc, exn);
300+
B.createThrow(CleanupLocation(throwLoc), exn);
301301

302302
ThrowDest = JumpDest::invalid();
303303
}

lib/SILGen/SILGenStmt.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,11 +729,10 @@ void StmtEmitter::visitGuardStmt(GuardStmt *S) {
729729
// Emit the condition bindings, branching to the bodyBB if they fail.
730730
auto NumFalseTaken = SGF.loadProfilerCount(S->getBody());
731731
auto NumNonTaken = SGF.loadProfilerCount(S);
732-
SGF.emitStmtCondition(S->getCond(), bodyBB, S, NumNonTaken, NumFalseTaken);
733-
734732
// Begin a new 'guard' scope, which is popped when the next innermost debug
735733
// scope ends.
736734
SGF.enterDebugScope(S, /*isGuardScope=*/true);
735+
SGF.emitStmtCondition(S->getCond(), bodyBB, S, NumNonTaken, NumFalseTaken);
737736
}
738737

739738
void StmtEmitter::visitWhileStmt(WhileStmt *S) {

test/DebugInfo/guard-let-scope.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %target-swift-frontend -emit-sil -Xllvm -sil-print-debuginfo %s \
2+
// RUN: | %FileCheck %s
3+
func f(c: AnyObject?) {
4+
let x = c
5+
// CHECK: sil_scope [[S1:[0-9]+]] { loc "{{.*}}":[[@LINE-2]]:23 parent
6+
// CHECK: sil_scope [[S2:[0-9]+]] { loc "{{.*}}":[[@LINE+3]]:3 parent [[S1]] }
7+
// CHECK: debug_value %0 : $Optional<AnyObject>, let, name "x"{{.*}} scope [[S1]]
8+
// CHECK: debug_value %6 : $AnyObject, let, name "x", {{.*}} scope [[S2]]
9+
guard let x = x else {
10+
fatalError(".")
11+
}
12+
print(x)
13+
}

test/DebugInfo/local-vars.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ public func constvar_${name}() {
141141
// DWARF: DW_AT_name ("self")
142142
// DWARF-NOT: DW_TAG
143143
// DWARF: DW_AT_artificial
144-
// DWARF-NOT: DW_TAG
145144
// DWARF: DW_TAG_variable
146145
// DWARF-NOT: DW_TAG
147146
// DWARF: DW_AT_name ("$swift.type.{{T|U}}")
@@ -266,6 +265,7 @@ public func guard_let_${name}() {
266265
fatalError()
267266
}
268267
// DWARF-NOT: DW_TAG
268+
// DWARF: DW_TAG_lexical_block
269269
// DWARF: DW_TAG_variable
270270
// DWARF-NOT: DW_TAG
271271
// DWARF: DW_AT_location

test/SILOptimizer/definite-init-wrongscope.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ public class M {
3030

3131
// CHECK-LABEL: sil [ossa] @$s3del1MC4fromAcA12WithDelegate_p_tKcfc : $@convention(method) (@in WithDelegate, @owned M) -> (@owned M, @error Error)
3232

33-
// CHECK: [[I:%.*]] = integer_literal $Builtin.Int2, 1, loc {{.*}}:20:12, scope 4
34-
// CHECK: [[V:%.*]] = load [trivial] %2 : $*Builtin.Int2, loc {{.*}}:20:12, scope 4
35-
// CHECK: [[OR:%.*]] = builtin "or_Int2"([[V]] : $Builtin.Int2, [[I]] : $Builtin.Int2) : $Builtin.Int2, loc {{.*}}:20:12, scope 4
36-
// CHECK: store [[OR]] to [trivial] %2 : $*Builtin.Int2, loc {{.*}}:20:12, scope 4
37-
// CHECK: store %{{.*}} to [init] %{{.*}} : $*C, loc {{.*}}:23:20, scope 4
33+
// CHECK: [[I:%.*]] = integer_literal $Builtin.Int2, 1, loc {{.*}}:20:12, scope 3
34+
// CHECK: [[V:%.*]] = load [trivial] %2 : $*Builtin.Int2, loc {{.*}}:20:12, scope 3
35+
// CHECK: [[OR:%.*]] = builtin "or_Int2"([[V]] : $Builtin.Int2, [[I]] : $Builtin.Int2) : $Builtin.Int2, loc {{.*}}:20:12, scope 3
36+
// CHECK: store [[OR]] to [trivial] %2 : $*Builtin.Int2, loc {{.*}}:20:12, scope 3
37+
// CHECK: store %{{.*}} to [init] %{{.*}} : $*C, loc {{.*}}:23:20, scope 3
3838

3939
// Make sure the dealloc_stack gets the same scope of the instructions surrounding it.
4040

41-
// CHECK: destroy_addr %0 : $*WithDelegate, loc {{.*}}:26:5, scope 4
42-
// CHECK: dealloc_stack %2 : $*Builtin.Int2, loc {{.*}}:20:12, scope 4
43-
// CHECK: throw %{{.*}} : $Error, loc {{.*}}:20:12, scope 4
41+
// CHECK: destroy_addr %0 : $*WithDelegate, loc {{.*}}:26:5, scope 3
42+
// CHECK: dealloc_stack %2 : $*Builtin.Int2, loc {{.*}}:20:12, scope 3
43+
// CHECK: throw %{{.*}} : $Error, loc {{.*}}:20:12, scope 1

0 commit comments

Comments
 (0)