Skip to content

Commit 8c204f7

Browse files
authored
Merge pull request #2779 from swiftwasm/main
[pull] swiftwasm from main
2 parents 94c2875 + 93a28da commit 8c204f7

File tree

8 files changed

+43
-17
lines changed

8 files changed

+43
-17
lines changed

lib/IRGen/GenMeta.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5221,10 +5221,10 @@ GenericRequirementsMetadata irgen::addGenericRequirements(
52215221
assert(sig);
52225222
GenericRequirementsMetadata metadata;
52235223
for (auto &requirement : requirements) {
5224-
++metadata.NumRequirements;
5225-
52265224
switch (auto kind = requirement.getKind()) {
52275225
case RequirementKind::Layout:
5226+
++metadata.NumRequirements;
5227+
52285228
switch (auto layoutKind =
52295229
requirement.getLayoutConstraint()->getKind()) {
52305230
case LayoutConstraintKind::Class: {
@@ -5249,9 +5249,11 @@ GenericRequirementsMetadata irgen::addGenericRequirements(
52495249
->getDecl();
52505250

52515251
// Marker protocols do not record generic requirements at all.
5252-
if (protocol->isMarkerProtocol())
5252+
if (protocol->isMarkerProtocol()) {
52535253
break;
5254+
}
52545255

5256+
++metadata.NumRequirements;
52555257
bool needsWitnessTable =
52565258
Lowering::TypeConverter::protocolRequiresWitnessTable(protocol);
52575259
auto flags = GenericRequirementFlags(GenericRequirementKind::Protocol,
@@ -5286,6 +5288,7 @@ GenericRequirementsMetadata irgen::addGenericRequirements(
52865288

52875289
case RequirementKind::SameType:
52885290
case RequirementKind::Superclass: {
5291+
++metadata.NumRequirements;
52895292
auto abiKind = kind == RequirementKind::SameType
52905293
? GenericRequirementKind::SameType
52915294
: GenericRequirementKind::BaseClass;

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/IRGen/marker_protocol.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@
1111
extension Int: P { }
1212
extension Array: P where Element: P { }
1313

14+
// CHECK: @"$s15marker_protocol1QMp" = {{(protected )?}}constant
15+
// CHECK-SAME: i32 trunc{{.*}}s15marker_protocolMXM{{.*}}s15marker_protocol1QMp
16+
// CHECK-SAME: i32 0, i32 5, i32 0
17+
public protocol Q: P {
18+
func f()
19+
func g()
20+
func h()
21+
func i()
22+
func j()
23+
}
24+
1425
// Note: no witness tables
1526
// CHECK: swiftcc void @"$s15marker_protocol7genericyyxAA1PRzlF"(%swift.opaque* noalias nocapture %0, %swift.type* %T)
1627
public func generic<T: P>(_: T) { }
@@ -19,5 +30,3 @@ public func testGeneric(i: Int, array: [Int]) {
1930
generic(i)
2031
generic(array)
2132
}
22-
23-
public protocol Q: P { }

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)