Skip to content

Commit 2187929

Browse files
committed
SILGen: Turn static collectParams() function into a method on SILGenFunction, NFC
1 parent b70e4d2 commit 2187929

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

lib/SILGen/SILGenFunction.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,12 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
14251425
CanType outputSubstType,
14261426
SGFContext ctx = SGFContext());
14271427

1428+
/// Used for emitting SILArguments of bare functions, such as thunks and
1429+
/// open-coded materializeForSet.
1430+
void collectThunkParams(SILLocation loc,
1431+
SmallVectorImpl<ManagedValue> &params,
1432+
bool allowPlusZero);
1433+
14281434
/// Build the type of a function transformation thunk.
14291435
CanSILFunctionType buildThunkType(ManagedValue fn,
14301436
CanSILFunctionType expectedType,

lib/SILGen/SILGenPoly.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -650,18 +650,16 @@ static ManagedValue manageParam(SILGenFunction &gen,
650650
llvm_unreachable("bad parameter convention");
651651
}
652652

653-
static void collectParams(SILGenFunction &gen,
654-
SILLocation loc,
655-
SmallVectorImpl<ManagedValue> &params,
656-
bool allowPlusZero) {
653+
void SILGenFunction::collectThunkParams(SILLocation loc,
654+
SmallVectorImpl<ManagedValue> &params,
655+
bool allowPlusZero) {
657656
auto paramTypes =
658-
gen.F.getLoweredFunctionType()->getParametersWithoutIndirectResult();
657+
F.getLoweredFunctionType()->getParametersWithoutIndirectResult();
659658
for (auto param : paramTypes) {
660-
auto paramTy = gen.F.mapTypeIntoContext(param.getSILType());
661-
auto paramValue = new (gen.SGM.M) SILArgument(gen.F.begin(),
662-
paramTy);
663-
664-
params.push_back(manageParam(gen, loc, paramValue, param, allowPlusZero));
659+
auto paramTy = F.mapTypeIntoContext(param.getSILType());
660+
auto paramValue = new (SGM.M) SILArgument(F.begin(), paramTy);
661+
auto paramMV = manageParam(*this, loc, paramValue, param, allowPlusZero);
662+
params.push_back(paramMV);
665663
}
666664
}
667665

@@ -1332,7 +1330,7 @@ static void buildThunkBody(SILGenFunction &gen, SILLocation loc,
13321330
SmallVector<ManagedValue, 8> params;
13331331
// TODO: Could accept +0 arguments here when forwardFunctionArguments/
13341332
// emitApply can.
1335-
collectParams(gen, loc, params, /*allowPlusZero*/ false);
1333+
gen.collectThunkParams(loc, params, /*allowPlusZero*/ false);
13361334

13371335
ManagedValue fnValue = params.pop_back_val();
13381336
auto fnType = fnValue.getType().castTo<SILFunctionType>();
@@ -1683,7 +1681,7 @@ SILGenFunction::emitVTableThunk(SILDeclRef derived,
16831681
}
16841682

16851683
SmallVector<ManagedValue, 8> thunkArgs;
1686-
collectParams(*this, loc, thunkArgs, /*allowPlusZero*/ true);
1684+
collectThunkParams(loc, thunkArgs, /*allowPlusZero*/ true);
16871685

16881686
SmallVector<ManagedValue, 8> substArgs;
16891687
// If the thunk and implementation share an indirect result type, use it
@@ -1826,7 +1824,7 @@ void SILGenFunction::emitProtocolWitness(ProtocolConformance *conformance,
18261824
SmallVector<ManagedValue, 8> origParams;
18271825
// TODO: Should be able to accept +0 values here, once
18281826
// forwardFunctionArguments/emitApply are able to.
1829-
collectParams(*this, loc, origParams, /*allowPlusZero*/ false);
1827+
collectThunkParams(loc, origParams, /*allowPlusZero*/ false);
18301828

18311829
// Handle special abstraction differences in "self".
18321830
// If the witness is a free function, drop it completely.

0 commit comments

Comments
 (0)