Skip to content

Commit f67c660

Browse files
committed
[embedded] Move isEmbedded check to MandatoryPerformanceOptimizations from VTableSpecializer
1 parent 06b6268 commit f67c660

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

SwiftCompilerSources/Sources/Optimizer/ModulePasses/MandatoryPerformanceOptimizations.swift

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private func optimizeFunctionsTopDown(using worklist: inout FunctionWorklist,
5050
return
5151
}
5252

53-
optimize(function: f, context, &worklist)
53+
optimize(function: f, context, &worklist, isEmbeddedSwift: moduleContext.options.enableEmbeddedSwift)
5454
}
5555
}
5656
}
@@ -60,7 +60,7 @@ fileprivate struct PathFunctionTuple: Hashable {
6060
var function: Function
6161
}
6262

63-
private func optimize(function: Function, _ context: FunctionPassContext, _ worklist: inout FunctionWorklist) {
63+
private func optimize(function: Function, _ context: FunctionPassContext, _ worklist: inout FunctionWorklist, isEmbeddedSwift: Bool) {
6464
var alreadyInlinedFunctions: Set<PathFunctionTuple> = Set()
6565

6666
var changed = true
@@ -75,12 +75,21 @@ private func optimize(function: Function, _ context: FunctionPassContext, _ work
7575
switch instruction {
7676
case let apply as FullApplySite:
7777
inlineAndDevirtualize(apply: apply, alreadyInlinedFunctions: &alreadyInlinedFunctions, context, simplifyCtxt)
78+
79+
// Embedded Swift specific transformations
7880
case let alloc as AllocRefInst:
79-
specializeVTableAndAddEntriesToWorklist(for: alloc.type, in: function, context, &worklist)
81+
if isEmbeddedSwift {
82+
specializeVTableAndAddEntriesToWorklist(for: alloc.type, in: function, context, &worklist)
83+
}
8084
case let metatype as MetatypeInst:
81-
specializeVTableAndAddEntriesToWorklist(for: metatype.type, in: function, context, &worklist)
85+
if isEmbeddedSwift {
86+
specializeVTableAndAddEntriesToWorklist(for: metatype.type, in: function, context, &worklist)
87+
}
8288
case let classMethod as ClassMethodInst:
83-
_ = context.specializeClassMethodInst(classMethod)
89+
if isEmbeddedSwift {
90+
_ = context.specializeClassMethodInst(classMethod)
91+
}
92+
8493
default:
8594
break
8695
}

lib/SILOptimizer/Transforms/VTableSpecializer.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ bool VTableSpecializer::specializeVTables(SILModule &module) {
106106

107107
SILVTable *swift::specializeVTableForType(SILType classTy, SILModule &module,
108108
SILTransform *transform) {
109-
if (!module.getASTContext().LangOpts.hasFeature(Feature::Embedded))
110-
return nullptr;
111-
112109
CanType astType = classTy.getASTType();
113110
BoundGenericClassType *genClassTy = dyn_cast<BoundGenericClassType>(astType);
114111
if (!genClassTy) return nullptr;
@@ -193,9 +190,6 @@ bool swift::specializeClassMethodInst(ClassMethodInst *cm) {
193190
SILFunction *f = cm->getFunction();
194191
SILModule &m = f->getModule();
195192

196-
if (!m.getASTContext().LangOpts.hasFeature(Feature::Embedded))
197-
return false;
198-
199193
SILValue instance = cm->getOperand();
200194
SILType classTy = instance->getType();
201195
CanType astType = classTy.getASTType();

0 commit comments

Comments
 (0)