Skip to content

Commit f55d68d

Browse files
committed
Remove SpecializeOpaqueArchetypes for now
1 parent 14089c1 commit f55d68d

File tree

9 files changed

+18
-428
lines changed

9 files changed

+18
-428
lines changed

include/swift/SIL/SILCloner.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
121121
/// after mapping all blocks.
122122
void cloneReachableBlocks(SILBasicBlock *startBB,
123123
ArrayRef<SILBasicBlock *> exitBlocks,
124-
SILBasicBlock *insertAfterBB = nullptr,
125-
bool havePrepopulatedFunctionArgs = false);
124+
SILBasicBlock *insertAfterBB = nullptr);
126125

127126
/// Clone all blocks in this function and all instructions in those
128127
/// blocks.
@@ -580,15 +579,13 @@ void SILCloner<ImplClass>::visitInstructionsInBlock(SILBasicBlock* BB) {
580579
template <typename ImplClass>
581580
void SILCloner<ImplClass>::cloneReachableBlocks(
582581
SILBasicBlock *startBB, ArrayRef<SILBasicBlock *> exitBlocks,
583-
SILBasicBlock *insertAfterBB,
584-
bool havePrepopulatedFunctionArgs) {
582+
SILBasicBlock *insertAfterBB) {
585583

586584
SILFunction *F = startBB->getParent();
587585
assert(F == &Builder.getFunction()
588586
&& "cannot clone region across functions.");
589587
assert(BBMap.empty() && "This API does not allow clients to map blocks.");
590-
assert((havePrepopulatedFunctionArgs || ValueMap.empty()) &&
591-
"Stale ValueMap.");
588+
assert(ValueMap.empty() && "Stale ValueMap.");
592589

593590
auto *clonedStartBB = insertAfterBB ? F->createBasicBlockAfter(insertAfterBB)
594591
: F->createBasicBlock();

include/swift/SIL/SILType.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,10 @@ class SILType {
465465
///
466466
/// If the replacement types are generic, you must push a generic context
467467
/// first.
468-
SILType subst(SILModule &silModule, TypeSubstitutionFn subs,
468+
SILType subst(SILModule &silModule,
469+
TypeSubstitutionFn subs,
469470
LookupConformanceFn conformances,
470-
CanGenericSignature genericSig = CanGenericSignature(),
471-
bool shouldSubstituteOpaqueArchetypes = false) const;
471+
CanGenericSignature genericSig=CanGenericSignature()) const;
472472

473473
SILType subst(SILModule &silModule, SubstitutionMap subs) const;
474474

include/swift/SILOptimizer/PassManager/Passes.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,6 @@ PASS(NoReturnFolding, "noreturn-folding",
224224
"Prune Control Flow at No-Return Calls Using SIL unreachable")
225225
PASS(ObjectOutliner, "object-outliner",
226226
"Outlining of Global Objects")
227-
PASS(OpaqueArchetypeSpecializer, "opaque-archetype-specializer",
228-
"Opaque archetype specializer")
229227
PASS(Outliner, "outliner",
230228
"Function Outlining Optimization")
231229
PASS(OwnershipModelEliminator, "ownership-model-eliminator",

lib/SIL/SILFunctionType.cpp

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,21 +2274,17 @@ class SILTypeSubstituter :
22742274
// context signature.
22752275
CanGenericSignature Sig;
22762276

2277-
bool shouldSubstituteOpaqueArchetypes;
2278-
22792277
ASTContext &getASTContext() { return TheSILModule.getASTContext(); }
22802278

22812279
public:
22822280
SILTypeSubstituter(SILModule &silModule,
22832281
TypeSubstitutionFn Subst,
22842282
LookupConformanceFn Conformances,
2285-
CanGenericSignature Sig,
2286-
bool shouldSubstituteOpaqueArchetypes)
2283+
CanGenericSignature Sig)
22872284
: TheSILModule(silModule),
22882285
Subst(Subst),
22892286
Conformances(Conformances),
2290-
Sig(Sig),
2291-
shouldSubstituteOpaqueArchetypes(shouldSubstituteOpaqueArchetypes)
2287+
Sig(Sig)
22922288
{}
22932289

22942290
// SIL type lowering only does special things to tuples and functions.
@@ -2409,13 +2405,7 @@ class SILTypeSubstituter :
24092405
CanType visitType(CanType origType) {
24102406
assert(!isa<AnyFunctionType>(origType));
24112407
assert(!isa<LValueType>(origType) && !isa<InOutType>(origType));
2412-
2413-
SubstOptions substOptions(None);
2414-
if (shouldSubstituteOpaqueArchetypes)
2415-
substOptions = SubstFlags::SubstituteOpaqueArchetypes |
2416-
SubstFlags::AllowLoweredTypes;
2417-
auto substType =
2418-
origType.subst(Subst, Conformances, substOptions)->getCanonicalType();
2408+
auto substType = origType.subst(Subst, Conformances)->getCanonicalType();
24192409

24202410
// If the substitution didn't change anything, we know that the
24212411
// original type was a lowered type, so we're good.
@@ -2430,24 +2420,23 @@ class SILTypeSubstituter :
24302420

24312421
} // end anonymous namespace
24322422

2433-
SILType SILType::subst(SILModule &silModule, TypeSubstitutionFn subs,
2423+
SILType SILType::subst(SILModule &silModule,
2424+
TypeSubstitutionFn subs,
24342425
LookupConformanceFn conformances,
2435-
CanGenericSignature genericSig,
2436-
bool shouldSubstituteOpaqueArchetypes) const {
2437-
if (!hasArchetype() && !hasTypeParameter() &&
2438-
(!shouldSubstituteOpaqueArchetypes ||
2439-
!getASTType()->hasOpaqueArchetype()))
2426+
CanGenericSignature genericSig) const {
2427+
if (!hasArchetype() && !hasTypeParameter())
24402428
return *this;
24412429

24422430
if (!genericSig)
24432431
genericSig = silModule.Types.getCurGenericContext();
24442432
SILTypeSubstituter STST(silModule, subs, conformances,
2445-
genericSig, shouldSubstituteOpaqueArchetypes);
2433+
genericSig);
24462434
return STST.subst(*this);
24472435
}
24482436

24492437
SILType SILType::subst(SILModule &silModule, SubstitutionMap subs) const{
2450-
return subst(silModule, QuerySubstitutionMap{subs},
2438+
return subst(silModule,
2439+
QuerySubstitutionMap{subs},
24512440
LookUpConformanceInSubstitutionMap(subs));
24522441
}
24532442

@@ -2476,7 +2465,7 @@ SILFunctionType::substGenericArgs(SILModule &silModule,
24762465
LookupConformanceFn conformances) {
24772466
if (!isPolymorphic()) return CanSILFunctionType(this);
24782467
SILTypeSubstituter substituter(silModule, subs, conformances,
2479-
getGenericSignature(), false);
2468+
getGenericSignature());
24802469
return substituter.substSILFunctionType(CanSILFunctionType(this));
24812470
}
24822471

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,7 @@ void addSSAPasses(SILPassPipelinePlan &P, OptimizationLevelKind OpLevel) {
273273

274274
// Mainly for Array.append(contentsOf) optimization.
275275
P.addArrayElementPropagation();
276-
277-
// Specialize opaque archetypes.
278-
// This can expose oportunities for the generic specializer.
279-
P.addOpaqueArchetypeSpecializer();
280-
276+
281277
// Run the devirtualizer, specializer, and inliner. If any of these
282278
// makes a change we'll end up restarting the function passes on the
283279
// current function (after optimizing any new callees).

lib/SILOptimizer/Transforms/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ silopt_register_sources(
3232
SILSROA.cpp
3333
SimplifyCFG.cpp
3434
Sink.cpp
35-
SpecializeOpaqueArchetypes.cpp
3635
SpeculativeDevirtualizer.cpp
3736
StackPromotion.cpp
3837
UnsafeGuaranteedPeephole.cpp

lib/SILOptimizer/Transforms/SpecializeOpaqueArchetypes.cpp

Lines changed: 0 additions & 234 deletions
This file was deleted.

0 commit comments

Comments
 (0)