Skip to content

Commit 2e63b4c

Browse files
committed
[semantic-arc-opts] Change Semantic ARC Opts to run only on the stdlib so it only sees ownership verified SIL.
The reason why I am doing this is now that once we have the OperandOwnershipKindMap I can write this optimization in a more robust, aggressive manner. My hope is that I can eliminate all copy_value of guaranteed parameters all of whose uses could accept a guaranteed parameter. This is given to me by the OperandOwnershipKindMap. Additionally, I found that the way the analysis was using the OwnershipVerifier was not sound on non-ownership verified SIL. Rather than fix it, I just turned it off for that case. rdar://44667493
1 parent b9b568b commit 2e63b4c

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

include/swift/SIL/SILModule.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ class SILModule {
378378
return wholeModule;
379379
}
380380

381+
bool isStdlibModule() const;
382+
381383
/// Returns true if it is the optimized OnoneSupport module.
382384
bool isOptimizedOnoneSupportModule() const;
383385

lib/SIL/SILModule.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,10 @@ void SILModule::setOptRecordStream(
660660
OptRecordRawStream = std::move(RawStream);
661661
}
662662

663+
bool SILModule::isStdlibModule() const {
664+
return TheSwiftModule->isStdlibModule();
665+
}
666+
663667
SILProperty *SILProperty::create(SILModule &M,
664668
bool Serialized,
665669
AbstractStorageDecl *Decl,

lib/SILOptimizer/Mandatory/SemanticARCOpts.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ struct SemanticARCOpts : SILFunctionTransform {
158158
void run() override {
159159
bool MadeChange = false;
160160
SILFunction *F = getFunction();
161+
if (!F->getModule().isStdlibModule()) {
162+
return;
163+
}
161164

162165
DeadEndBlocks DEBlocks(F);
163166
OwnershipChecker Checker{{}, {}, {}, {}, F->getModule(), DEBlocks};

test/SILOptimizer/semantic-arc-opts.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-sil-opt -enable-sil-verify-all -enable-sil-ownership -semantic-arc-opts %s | %FileCheck %s
1+
// RUN: %target-sil-opt -module-name Swift -enable-sil-verify-all -enable-sil-ownership -semantic-arc-opts %s | %FileCheck %s
22

33
sil_stage canonical
44

0 commit comments

Comments
 (0)