Skip to content

Commit 7217722

Browse files
committed
Optimizer: remove the now unused NonTransparentFunctionOwnershipModelEliminator pass
Also remove the `skipStdlibModule` flag from the OwnershipModelEliminator, because it's always false
1 parent a322fd9 commit 7217722

File tree

7 files changed

+11
-98
lines changed

7 files changed

+11
-98
lines changed

include/swift/SIL/SILModule.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,6 @@ class SILModule {
393393

394394
bool parsedAsSerializedSIL;
395395

396-
/// Set if we have registered a deserialization notification handler for
397-
/// lowering ownership in non transparent functions.
398-
/// This gets set in NonTransparent OwnershipModelEliminator pass.
399-
bool regDeserializationNotificationHandlerForNonTransparentFuncOME;
400396
/// Set if we have registered a deserialization notification handler for
401397
/// lowering ownership in transparent functions.
402398
/// This gets set in OwnershipModelEliminator pass.
@@ -449,15 +445,9 @@ class SILModule {
449445
deserializationNotificationHandlers.erase(handler);
450446
}
451447

452-
bool hasRegisteredDeserializationNotificationHandlerForNonTransparentFuncOME() {
453-
return regDeserializationNotificationHandlerForNonTransparentFuncOME;
454-
}
455448
bool hasRegisteredDeserializationNotificationHandlerForAllFuncOME() {
456449
return regDeserializationNotificationHandlerForAllFuncOME;
457450
}
458-
void setRegisteredDeserializationNotificationHandlerForNonTransparentFuncOME() {
459-
regDeserializationNotificationHandlerForNonTransparentFuncOME = true;
460-
}
461451
void setRegisteredDeserializationNotificationHandlerForAllFuncOME() {
462452
regDeserializationNotificationHandlerForAllFuncOME = true;
463453
}

include/swift/SILOptimizer/PassManager/Passes.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,6 @@ LEGACY_PASS(ModulePrinter, "module-printer",
377377
"Print the module")
378378
LEGACY_PASS(NestedSemanticFunctionCheck, "nested-semantic-function-check",
379379
"Diagnose improperly nested '@_semantics' functions")
380-
LEGACY_PASS(NonTransparentFunctionOwnershipModelEliminator,
381-
"non-transparent-func-ownership-model-eliminator",
382-
"Eliminate Ownership Annotations from non-transparent SIL Functions")
383380
LEGACY_PASS(RCIdentityDumper, "rc-id-dumper",
384381
"Print Reference Count Identities")
385382
LEGACY_PASS(AlwaysInlineInliner, "always-inline",

lib/SIL/IR/SILModule.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ SILModule::SILModule(llvm::PointerUnion<FileUnit *, ModuleDecl *> context,
112112
: Stage(SILStage::Raw), loweredAddresses(!Options.EnableSILOpaqueValues),
113113
indexTrieRoot(new IndexTrieNode()), Options(Options),
114114
irgenOptions(irgenOptions), serialized(false),
115-
regDeserializationNotificationHandlerForNonTransparentFuncOME(false),
116115
regDeserializationNotificationHandlerForAllFuncOME(false),
117116
hasAccessMarkerHandler(false),
118117
prespecializedFunctionDeclsImported(false), SerializeSILAction(),

lib/SILOptimizer/Mandatory/OwnershipModelEliminator.cpp

Lines changed: 7 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -871,17 +871,6 @@ static bool stripOwnership(SILFunction &func) {
871871
return madeChange;
872872
}
873873

874-
static void prepareNonTransparentSILFunctionForOptimization(ModuleDecl *,
875-
SILFunction *f) {
876-
if (!f->hasOwnership() || f->isTransparent())
877-
return;
878-
879-
LLVM_DEBUG(llvm::dbgs() << "After deserialization, stripping ownership in:"
880-
<< f->getName() << "\n");
881-
882-
stripOwnership(*f);
883-
}
884-
885874
static void prepareSILFunctionForOptimization(ModuleDecl *, SILFunction *f) {
886875
if (!f->hasOwnership())
887876
return;
@@ -895,11 +884,7 @@ static void prepareSILFunctionForOptimization(ModuleDecl *, SILFunction *f) {
895884
namespace {
896885

897886
struct OwnershipModelEliminator : SILFunctionTransform {
898-
bool skipTransparent;
899-
bool skipStdlibModule;
900-
901-
OwnershipModelEliminator(bool skipTransparent, bool skipStdlibModule)
902-
: skipTransparent(skipTransparent), skipStdlibModule(skipStdlibModule) {}
887+
OwnershipModelEliminator() {}
903888

904889
void run() override {
905890
if (DumpBefore.size()) {
@@ -909,20 +894,9 @@ struct OwnershipModelEliminator : SILFunctionTransform {
909894
auto *f = getFunction();
910895
auto &mod = getFunction()->getModule();
911896

912-
// If we are supposed to skip the stdlib module and we are in the stdlib
913-
// module bail.
914-
if (skipStdlibModule && mod.isStdlibModule()) {
915-
return;
916-
}
917-
918897
if (!f->hasOwnership())
919898
return;
920899

921-
// If we were asked to not strip ownership from transparent functions in
922-
// /our/ module, return.
923-
if (skipTransparent && f->isTransparent())
924-
return;
925-
926900
// Verify here to make sure ownership is correct before we strip.
927901
{
928902
// Add a pretty stack trace entry to tell users who see a verification
@@ -950,37 +924,20 @@ struct OwnershipModelEliminator : SILFunctionTransform {
950924
invalidateAnalysis(InvalidKind);
951925
}
952926

953-
// If we were asked to strip transparent, we are at the beginning of the
954-
// performance pipeline. In such a case, we register a handler so that all
955-
// future things we deserialize have ownership stripped.
927+
// Register a handler so that all future things we deserialize have ownership stripped.
956928
using NotificationHandlerTy =
957929
FunctionBodyDeserializationNotificationHandler;
958930
std::unique_ptr<DeserializationNotificationHandler> ptr;
959-
if (skipTransparent) {
960-
if (!mod.hasRegisteredDeserializationNotificationHandlerForNonTransparentFuncOME()) {
961-
ptr.reset(new NotificationHandlerTy(
962-
prepareNonTransparentSILFunctionForOptimization));
963-
mod.registerDeserializationNotificationHandler(std::move(ptr));
964-
mod.setRegisteredDeserializationNotificationHandlerForNonTransparentFuncOME();
965-
}
966-
} else {
967-
if (!mod.hasRegisteredDeserializationNotificationHandlerForAllFuncOME()) {
968-
ptr.reset(new NotificationHandlerTy(prepareSILFunctionForOptimization));
969-
mod.registerDeserializationNotificationHandler(std::move(ptr));
970-
mod.setRegisteredDeserializationNotificationHandlerForAllFuncOME();
971-
}
931+
if (!mod.hasRegisteredDeserializationNotificationHandlerForAllFuncOME()) {
932+
ptr.reset(new NotificationHandlerTy(prepareSILFunctionForOptimization));
933+
mod.registerDeserializationNotificationHandler(std::move(ptr));
934+
mod.setRegisteredDeserializationNotificationHandlerForAllFuncOME();
972935
}
973936
}
974937
};
975938

976939
} // end anonymous namespace
977940

978941
SILTransform *swift::createOwnershipModelEliminator() {
979-
return new OwnershipModelEliminator(false /*skip transparent*/,
980-
false /*ignore stdlib*/);
981-
}
982-
983-
SILTransform *swift::createNonTransparentFunctionOwnershipModelEliminator() {
984-
return new OwnershipModelEliminator(true /*skip transparent*/,
985-
false /*ignore stdlib*/);
942+
return new OwnershipModelEliminator();
986943
}

lib/SILOptimizer/PassManager/PassManager.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,6 @@ void SILPassManager::dumpPassInfo(const char *Title, unsigned TransIdx,
577577

578578
bool SILPassManager::isMandatoryFunctionPass(SILFunctionTransform *sft) {
579579
return isMandatory ||
580-
sft->getPassKind() ==
581-
PassKind::NonTransparentFunctionOwnershipModelEliminator ||
582580
sft->getPassKind() == PassKind::OwnershipModelEliminator;
583581
}
584582

test/SILOptimizer/ome_non_transparent.sil

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

test/SILOptimizer/ome_strip_deserialize.sil

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %target-swift-frontend -parse-sil -module-name OMEStripDeserializationInput %S/Inputs/ome_strip_deserialize_input.sil -emit-module -o %t/OMEStripDeserializationInput.swiftmodule
3-
// RUN: %target-sil-opt -non-transparent-func-ownership-model-eliminator -performance-linker -I %t %s | %FileCheck %s
4-
// RUN: %target-sil-opt -ownership-model-eliminator -performance-linker -I %t %s | %FileCheck --check-prefix=CHECK-STRIP-ALL %s
3+
// RUN: %target-sil-opt -ownership-model-eliminator -performance-linker -I %t %s | %FileCheck %s
54

65
sil_stage canonical
76

@@ -11,22 +10,14 @@ import OMEStripDeserializationInput
1110
// ownership SIL.
1211

1312
// CHECK-LABEL: sil public_external [serialized] @bar : $@convention(thin) () -> ()
14-
// CHECK: } // end sil function 'bar'
15-
16-
// CHECK-STRIP-ALL-LABEL: sil public_external [serialized] @bar : $@convention(thin) () -> ()
17-
// CHECK-STRIP-ALL: } // end sil function 'bar'
13+
// CHECK: } // end sil function 'bar'
1814
sil [ossa] @bar : $@convention(thin) () -> ()
1915

20-
// CHECK-LABEL: sil public_external [transparent] [serialized] [ossa] @transparent_bar : $@convention(thin) () -> ()
21-
// CHECK: } // end sil function 'transparent_bar'
22-
23-
// CHECK-STRIP-ALL-LABEL: sil public_external [transparent] [serialized] @transparent_bar : $@convention(thin) () -> ()
24-
// CHECK-STRIP-ALL: } // end sil function 'transparent_bar'
16+
// CHECK-LABEL: sil public_external [transparent] [serialized] @transparent_bar : $@convention(thin) () -> ()
17+
// CHECK: } // end sil function 'transparent_bar'
2518

2619
sil [transparent] [ossa] @transparent_bar : $@convention(thin) () -> ()
2720

28-
// CHECK-LABEL: sil @foo : $@convention(thin) () -> () {
29-
// CHECK: } // end sil function 'foo'
3021
sil [ossa] @foo : $@convention(thin) () -> () {
3122
bb0:
3223
%0 = function_ref @bar : $@convention(thin) () -> ()

0 commit comments

Comments
 (0)