Skip to content

Commit 921d41c

Browse files
committed
[SILGen] Eliminate emitApplyOfLibraryIntrinsic() for SubstitutionList.
There was only one caller; update it to use the SubstitutionMap version.
1 parent 42fe2c1 commit 921d41c

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

lib/SILGen/SILGenApply.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4469,18 +4469,6 @@ SILGenFunction::emitApplyOfLibraryIntrinsic(SILLocation loc,
44694469
finalArgs, calleeTypeInfo, ApplyOptions::None, ctx);
44704470
}
44714471

4472-
RValue
4473-
SILGenFunction::emitApplyOfLibraryIntrinsic(SILLocation loc,
4474-
FuncDecl *fn,
4475-
const SubstitutionList &subs,
4476-
ArrayRef<ManagedValue> args,
4477-
SGFContext ctx) {
4478-
SubstitutionMap subMap;
4479-
if (auto genericSig = fn->getGenericSignature())
4480-
subMap = genericSig->getSubstitutionMap(subs);
4481-
return emitApplyOfLibraryIntrinsic(loc, fn, subMap, args, ctx);
4482-
}
4483-
44844472
static StringRef
44854473
getMagicFunctionString(SILGenFunction &SGF) {
44864474
assert(SGF.MagicFunctionName

lib/SILGen/SILGenFunction.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,12 +1335,6 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
13351335
ArrayRef<ManagedValue> args,
13361336
SGFContext ctx);
13371337

1338-
RValue emitApplyOfLibraryIntrinsic(SILLocation loc,
1339-
FuncDecl *fn,
1340-
const SubstitutionList &subs,
1341-
ArrayRef<ManagedValue> args,
1342-
SGFContext ctx);
1343-
13441338
SILValue emitApplyWithRethrow(SILLocation loc, SILValue fn,
13451339
SILType substFnType,
13461340
SubstitutionMap subs,

lib/SILGen/SILGenPattern.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2588,10 +2588,24 @@ static void emitDiagnoseOfUnexpectedEnumCaseValue(SILGenFunction &SGF,
25882588
loweredRawType);
25892589
auto materializedRawValue = rawValue.materialize(SGF, loc);
25902590

2591-
Substitution subs[] = {
2592-
{switchedValueSwiftType, /*Conformances*/None},
2593-
{enumDecl->getRawType(), /*Conformances*/None},
2594-
};
2591+
auto genericSig = diagnoseFailure->getGenericSignature();
2592+
auto subs = genericSig->getSubstitutionMap(
2593+
[&](SubstitutableType *type) -> Type {
2594+
auto genericParam = cast<GenericTypeParamType>(type);
2595+
assert(genericParam->getDepth() == 0);
2596+
assert(genericParam->getIndex() < 2);
2597+
switch (genericParam->getIndex()) {
2598+
case 0:
2599+
return switchedValueSwiftType;
2600+
2601+
case 1:
2602+
return enumDecl->getRawType();
2603+
2604+
default:
2605+
llvm_unreachable("wrong generic signature for expected case value");
2606+
}
2607+
},
2608+
LookUpConformanceInSignature(*genericSig));
25952609

25962610
SGF.emitApplyOfLibraryIntrinsic(loc, diagnoseFailure, subs,
25972611
{ManagedValue::forUnmanaged(metatype),

0 commit comments

Comments
 (0)