Skip to content

Commit 63e0ae0

Browse files
committed
SILGen: Remove confusing CallDepth counter that didn't seem to do anything, NFC
1 parent bbefeb2 commit 63e0ae0

File tree

1 file changed

+13
-41
lines changed

1 file changed

+13
-41
lines changed

lib/SILGen/SILGenApply.cpp

Lines changed: 13 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -391,18 +391,10 @@ class Callee {
391391

392392
void setSubstitutions(SILGenFunction &gen,
393393
SILLocation loc,
394-
ArrayRef<Substitution> newSubs,
395-
unsigned callDepth) {
396-
// Currently generic methods of generic types are the deepest we should
397-
// be able to stack specializations.
398-
// FIXME: Generic local functions can add type parameters to arbitrary
399-
// depth.
400-
assert(callDepth < 2 && "specialization below 'self' or argument depth?!");
394+
ArrayRef<Substitution> newSubs) {
401395
assert(Substitutions.empty() && "Already have substitutions?");
402396
Substitutions = newSubs;
403397

404-
assert(getNaturalUncurryLevel() >= callDepth
405-
&& "specializations below uncurry level?!");
406398
SpecializeLoc = loc;
407399
HasSubstitutions = true;
408400
}
@@ -808,13 +800,6 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
808800
std::vector<ApplyExpr*> CallSites;
809801
Expr *SideEffect = nullptr;
810802

811-
/// The depth of uncurries that we have seen.
812-
///
813-
/// *NOTE* This counter is incremented *after* we return from visiting a call
814-
/// site's children. This means that it is not valid until we finish visiting
815-
/// the expression.
816-
unsigned CallDepth = 0;
817-
818803
/// When visiting expressions, sometimes we need to emit self before we know
819804
/// what the actual callee is. In such cases, we assume that we are passing
820805
/// self at +0 and then after we know what the callee is, we check if the
@@ -826,8 +811,6 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
826811
{}
827812

828813
void setCallee(Callee &&c) {
829-
assert((SelfParam ? CallDepth == 1 : CallDepth == 0)
830-
&& "setting callee at non-zero call depth?!");
831814
assert(!ApplyCallee && "already set callee!");
832815
ApplyCallee.emplace(std::move(c));
833816
}
@@ -842,14 +825,12 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
842825
SelfParam = std::move(theSelfParam);
843826
SelfApplyExpr = theSelfApplyExpr;
844827
SelfType = theSelfApplyExpr->getType();
845-
++CallDepth;
846828
}
847829
void setSelfParam(ArgumentSource &&theSelfParam, Type selfType) {
848830
assert(!SelfParam && "already set this!");
849831
SelfParam = std::move(theSelfParam);
850832
SelfApplyExpr = nullptr;
851833
SelfType = selfType;
852-
++CallDepth;
853834
}
854835

855836
void decompose(Expr *e) {
@@ -933,7 +914,6 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
933914
CallSites.push_back(e);
934915
visit(e->getFn());
935916
}
936-
++CallDepth;
937917
}
938918

939919
/// Given a metatype value for the type, allocate an Objective-C
@@ -1041,9 +1021,8 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
10411021
setCallee(std::move(theCallee));
10421022

10431023
// If there are substitutions, add them now.
1044-
if (!subs.empty()) {
1045-
ApplyCallee->setSubstitutions(SGF, e, subs, CallDepth);
1046-
}
1024+
if (!subs.empty())
1025+
ApplyCallee->setSubstitutions(SGF, e, subs);
10471026

10481027
return;
10491028
}
@@ -1125,15 +1104,10 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
11251104
setCallee(Callee::forClassMethod(SGF, selfValue,
11261105
constant, getSubstFnType(), e));
11271106

1128-
// setSelfParam bumps the callDepth, but we aren't really past the
1129-
// 'self' call depth in this case.
1130-
--CallDepth;
1131-
11321107
// If there are substitutions, add them.
11331108
if (e->getDeclRef().isSpecialized()) {
11341109
ApplyCallee->setSubstitutions(SGF, e,
1135-
e->getDeclRef().getSubstitutions(),
1136-
CallDepth);
1110+
e->getDeclRef().getSubstitutions());
11371111
}
11381112

11391113
return;
@@ -1192,12 +1166,12 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
11921166
}
11931167
}
11941168

1195-
// If there are substitutions, add them, always at depth 0.
1169+
// If there are substitutions, add them.
11961170
if (!subs.empty() &&
11971171
(!afd ||
11981172
!afd->getDeclContext()->isLocalContext() ||
11991173
afd->getCaptureInfo().hasGenericParamCaptures()))
1200-
ApplyCallee->setSubstitutions(SGF, e, subs, 0);
1174+
ApplyCallee->setSubstitutions(SGF, e, subs);
12011175
}
12021176

12031177
void visitAbstractClosureExpr(AbstractClosureExpr *e) {
@@ -1242,9 +1216,9 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
12421216
captures);
12431217
ApplyCallee->setCaptures(std::move(captures));
12441218
}
1245-
// If there are substitutions, add them, always at depth 0.
1219+
// If there are substitutions, add them.
12461220
if (!subs.empty())
1247-
ApplyCallee->setSubstitutions(SGF, e, subs, 0);
1221+
ApplyCallee->setSubstitutions(SGF, e, subs);
12481222
}
12491223

12501224
void visitOtherConstructorDeclRefExpr(OtherConstructorDeclRefExpr *e) {
@@ -1257,8 +1231,7 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
12571231

12581232
// If there are substitutions, add them.
12591233
if (e->getDeclRef().isSpecialized())
1260-
ApplyCallee->setSubstitutions(SGF, e, e->getDeclRef().getSubstitutions(),
1261-
CallDepth);
1234+
ApplyCallee->setSubstitutions(SGF, e, e->getDeclRef().getSubstitutions());
12621235
}
12631236
void visitDotSyntaxBaseIgnoredExpr(DotSyntaxBaseIgnoredExpr *e) {
12641237
setSideEffect(e->getLHS());
@@ -1326,7 +1299,7 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
13261299

13271300
// If there are any substitutions for the callee, apply them now.
13281301
if (!substitutions.empty())
1329-
ApplyCallee->setSubstitutions(SGF, fn, substitutions, CallDepth-1);
1302+
ApplyCallee->setSubstitutions(SGF, fn, substitutions);
13301303
}
13311304

13321305
/// Walk the given \c selfArg expression that produces the appropriate
@@ -1518,8 +1491,7 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
15181491
// Set up the substitutions, if we have any.
15191492
if (ctorRef->getDeclRef().isSpecialized())
15201493
ApplyCallee->setSubstitutions(SGF, fn,
1521-
ctorRef->getDeclRef().getSubstitutions(),
1522-
CallDepth-1);
1494+
ctorRef->getDeclRef().getSubstitutions());
15231495

15241496
return true;
15251497
}
@@ -4266,7 +4238,7 @@ SILGenFunction::emitApplyOfLibraryIntrinsic(SILLocation loc,
42664238
}
42674239

42684240
auto callee = Callee::forDirect(*this, SILDeclRef(fn), substFormalType, loc);
4269-
callee.setSubstitutions(*this, loc, subs, 0);
4241+
callee.setSubstitutions(*this, loc, subs);
42704242

42714243
ManagedValue mv;
42724244
CanSILFunctionType substFnType;
@@ -4438,7 +4410,7 @@ emitSpecializedAccessorFunctionRef(SILGenFunction &gen,
44384410
// FIXME: Generic subscript operator could add another layer of
44394411
// substitutions.
44404412
if (!substitutions.empty()) {
4441-
callee.setSubstitutions(gen, loc, substitutions, 0);
4413+
callee.setSubstitutions(gen, loc, substitutions);
44424414
}
44434415
return callee;
44444416
}

0 commit comments

Comments
 (0)