Skip to content

Commit d784822

Browse files
committed
[embedded] Move loweredFunctionHasGenericArguments to .isGeneric() on SILFunction
1 parent 4fa9e53 commit d784822

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

include/swift/SIL/SILFunction.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,12 @@ class SILFunction
781781
return getLoweredFunctionType()->hasIndirectFormalResults();
782782
}
783783

784+
// Returns true if the function has any generic arguments.
785+
bool isGeneric() const {
786+
auto s = getLoweredFunctionType()->getInvocationGenericSignature();
787+
return s && !s->areAllParamsConcrete();
788+
}
789+
784790
/// Returns true if this function ie either a class method, or a
785791
/// closure that captures the 'self' value or its metatype.
786792
///

lib/IRGen/GenDecl.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,11 +1261,6 @@ static bool isLazilyEmittedFunction(SILFunction &f, SILModule &m) {
12611261
return true;
12621262
}
12631263

1264-
static bool loweredFunctionHasGenericArguments(SILFunction *f) {
1265-
auto s = f->getLoweredFunctionType()->getInvocationGenericSignature();
1266-
return s && !s->areAllParamsConcrete();
1267-
}
1268-
12691264
void IRGenerator::emitGlobalTopLevel(
12701265
const std::vector<std::string> &linkerDirectives) {
12711266
// Generate order numbers for the functions in the SIL module that
@@ -1305,8 +1300,7 @@ void IRGenerator::emitGlobalTopLevel(
13051300
// unspecialized classes and class vtables in SIL.
13061301
//
13071302
// if (SIL.getASTContext().LangOpts.hasFeature(Feature::Embedded)) {
1308-
// bool isGeneric = loweredFunctionHasGenericArguments(&f);
1309-
// if (isGeneric) {
1303+
// if (f.isGeneric()) {
13101304
// llvm::errs() << "Unspecialized function: \n" << f << "\n";
13111305
// llvm_unreachable("unspecialized function present in embedded Swift");
13121306
// }
@@ -1437,7 +1431,7 @@ void IRGenerator::emitLazyDefinitions() {
14371431
assert(LazyFieldDescriptors.empty());
14381432
// LazyFunctionDefinitions are allowed, but they must not be generic
14391433
for (SILFunction *f : LazyFunctionDefinitions) {
1440-
assert(!loweredFunctionHasGenericArguments(f));
1434+
assert(!f->isGeneric());
14411435
}
14421436
assert(LazyWitnessTables.empty());
14431437
assert(LazyCanonicalSpecializedMetadataAccessors.empty());
@@ -1567,7 +1561,7 @@ void IRGenerator::addLazyFunction(SILFunction *f) {
15671561

15681562
// Embedded Swift doesn't expect any generic functions to be referenced.
15691563
if (SIL.getASTContext().LangOpts.hasFeature(Feature::Embedded)) {
1570-
assert(!loweredFunctionHasGenericArguments(f));
1564+
assert(!f->isGeneric());
15711565
}
15721566

15731567
assert(!FinishedEmittingLazyDefinitions);

lib/SILOptimizer/IPO/DeadFunctionElimination.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ STATISTIC(NumDeadGlobals, "Number of dead global variables eliminated");
3131

3232
namespace {
3333

34-
static bool loweredFunctionHasGenericArguments(const SILFunction *f) {
35-
auto s = f->getLoweredFunctionType()->getInvocationGenericSignature();
36-
return s && !s->areAllParamsConcrete();
37-
}
38-
3934
class DeadFunctionAndGlobalElimination {
4035
/// Represents a function which is implementing a vtable or witness table
4136
/// method.
@@ -100,7 +95,7 @@ class DeadFunctionAndGlobalElimination {
10095
// In embedded Swift, (even public) generic functions *after serialization*
10196
// cannot be used externally and are not anchors.
10297
bool embedded = Module->getOptions().EmbeddedSwift;
103-
bool generic = loweredFunctionHasGenericArguments(F);
98+
bool generic = F->isGeneric();
10499
bool isSerialized = Module->isSerialized();
105100
if (embedded && generic && isSerialized)
106101
return false;

0 commit comments

Comments
 (0)