mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[ownership] Do some preliminary work for moving OME out of the diagnostics pipeline.
This disables a bunch of passes when ownership is enabled. This will allow me to keep transparent functions in ossa and skip most of the performance pipeline without being touched by passes that have not been updated for ownership. This is important so that we can in -Onone code import transparent functions and inline them into other ossa functions (you can't inline from ossa => non-ossa).
This commit is contained in:
@@ -265,10 +265,15 @@ class ARCSequenceOpts : public SILFunctionTransform {
|
||||
/// The entry point to the transformation.
|
||||
void run() override {
|
||||
auto *F = getFunction();
|
||||
|
||||
// If ARC optimizations are disabled, don't optimize anything and bail.
|
||||
if (!getOptions().EnableARCOptimizations)
|
||||
return;
|
||||
|
||||
// FIXME: We should support ownership.
|
||||
if (F->hasOwnership())
|
||||
return;
|
||||
|
||||
if (!EnableLoopARC) {
|
||||
auto *AA = getAnalysis<AliasAnalysis>();
|
||||
auto *POTA = getAnalysis<PostOrderAnalysis>();
|
||||
|
||||
@@ -63,7 +63,6 @@ class ExistentialSpecializer : public SILFunctionTransform {
|
||||
ClassHierarchyAnalysis *CHA;
|
||||
public:
|
||||
void run() override {
|
||||
|
||||
auto *F = getFunction();
|
||||
|
||||
/// Don't optimize functions that should not be optimized.
|
||||
@@ -71,6 +70,10 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
// FIXME: This pass should be able to support ownership.
|
||||
if (F->hasOwnership())
|
||||
return;
|
||||
|
||||
/// Get CallerAnalysis information handy.
|
||||
CA = PM->getAnalysis<CallerAnalysis>();
|
||||
|
||||
|
||||
@@ -581,6 +581,9 @@ void LetPropertiesOpt::run(SILModuleTransform *T) {
|
||||
// properties.
|
||||
bool NonRemovable = !F.shouldOptimize();
|
||||
|
||||
// FIXME: We should be able to handle ownership.
|
||||
NonRemovable &= !F.hasOwnership();
|
||||
|
||||
for (auto &BB : F) {
|
||||
for (auto &I : BB)
|
||||
// Look for any instructions accessing let properties.
|
||||
|
||||
@@ -1288,6 +1288,9 @@ public:
|
||||
|
||||
SILFunction *F = getFunction();
|
||||
assert(F);
|
||||
// FIXME: Update for ownership.
|
||||
if (F->hasOwnership())
|
||||
return;
|
||||
SILLoopInfo *LI = LA->get(F);
|
||||
assert(LI);
|
||||
DominanceInfo *DT = DA->get(F);
|
||||
|
||||
@@ -1160,6 +1160,10 @@ namespace {
|
||||
|
||||
class COWArrayOptPass : public SILFunctionTransform {
|
||||
void run() override {
|
||||
// FIXME: Update for ownership.
|
||||
if (getFunction()->hasOwnership())
|
||||
return;
|
||||
|
||||
LLVM_DEBUG(llvm::dbgs() << "COW Array Opts in Func "
|
||||
<< getFunction()->getName() << "\n");
|
||||
|
||||
@@ -1847,6 +1851,10 @@ class SwiftArrayOptPass : public SILFunctionTransform {
|
||||
|
||||
auto *Fn = getFunction();
|
||||
|
||||
// FIXME: Add support for ownership.
|
||||
if (Fn->hasOwnership())
|
||||
return;
|
||||
|
||||
// Don't hoist array property calls at Osize.
|
||||
if (Fn->optimizeForSize())
|
||||
return;
|
||||
|
||||
@@ -421,6 +421,10 @@ class LoopRotation : public SILFunctionTransform {
|
||||
|
||||
SILFunction *F = getFunction();
|
||||
assert(F);
|
||||
// FIXME: Add ownership support.
|
||||
if (F->hasOwnership())
|
||||
return;
|
||||
|
||||
SILLoopInfo *LI = LA->get(F);
|
||||
assert(LI);
|
||||
DominanceInfo *DT = DA->get(F);
|
||||
|
||||
@@ -229,6 +229,10 @@ namespace {
|
||||
// configuration.
|
||||
struct GuaranteedARCOpts : SILFunctionTransform {
|
||||
void run() override {
|
||||
// Skip ownership SIL. We are going to have a run of semantic arc opts here.
|
||||
if (getFunction()->hasOwnership())
|
||||
return;
|
||||
|
||||
GuaranteedARCOptsVisitor Visitor;
|
||||
|
||||
bool MadeChange = false;
|
||||
|
||||
@@ -345,6 +345,10 @@ class SILCombine : public SILFunctionTransform {
|
||||
|
||||
/// The entry point to the transformation.
|
||||
void run() override {
|
||||
// FIXME: We should be able to handle ownership.
|
||||
if (getFunction()->hasOwnership())
|
||||
return;
|
||||
|
||||
auto *AA = PM->getAnalysis<AliasAnalysis>();
|
||||
auto *DA = PM->getAnalysis<DominanceAnalysis>();
|
||||
auto *PCA = PM->getAnalysis<ProtocolConformanceAnalysis>();
|
||||
|
||||
@@ -1151,6 +1151,10 @@ public:
|
||||
if (!F->shouldOptimize())
|
||||
return;
|
||||
|
||||
// FIXME: Support ownership.
|
||||
if (F->hasOwnership())
|
||||
return;
|
||||
|
||||
LLVM_DEBUG(llvm::dbgs() << "*** ARCCM on function: " << F->getName()
|
||||
<< " ***\n");
|
||||
|
||||
|
||||
@@ -1130,6 +1130,10 @@ struct AccessEnforcementOpts : public SILFunctionTransform {
|
||||
if (F->empty())
|
||||
return;
|
||||
|
||||
// FIXME: Support ownership.
|
||||
if (F->hasOwnership())
|
||||
return;
|
||||
|
||||
LLVM_DEBUG(llvm::dbgs() << "Running local AccessEnforcementOpts on "
|
||||
<< F->getName() << "\n");
|
||||
|
||||
|
||||
@@ -217,6 +217,10 @@ struct AccessEnforcementReleaseSinking : public SILFunctionTransform {
|
||||
if (F->empty())
|
||||
return;
|
||||
|
||||
// FIXME: Support ownership.
|
||||
if (F->hasOwnership())
|
||||
return;
|
||||
|
||||
LLVM_DEBUG(llvm::dbgs() << "Running AccessEnforcementReleaseSinking on "
|
||||
<< F->getName() << "\n");
|
||||
|
||||
|
||||
@@ -184,6 +184,11 @@ public:
|
||||
|
||||
void run() override {
|
||||
auto &Fn = *getFunction();
|
||||
|
||||
// FIXME: Add ownership support.
|
||||
if (Fn.hasOwnership())
|
||||
return;
|
||||
|
||||
bool Changed = false;
|
||||
SmallVector<ApplyInst *, 16> DeadArrayCountCalls;
|
||||
// Propagate the count of array allocations to array.count users.
|
||||
|
||||
@@ -344,6 +344,10 @@ public:
|
||||
void run() override {
|
||||
auto &Fn = *getFunction();
|
||||
|
||||
// FIXME: Update for ownership.
|
||||
if (Fn.hasOwnership())
|
||||
return;
|
||||
|
||||
// Propagate the elements an of array value to its users.
|
||||
llvm::SmallVector<ArrayAllocation::GetElementReplacement, 16>
|
||||
GetElementReplacements;
|
||||
|
||||
@@ -1163,6 +1163,10 @@ class SILCSE : public SILFunctionTransform {
|
||||
bool RunsOnHighLevelSil;
|
||||
|
||||
void run() override {
|
||||
// FIXME: We should be able to support ownership.
|
||||
if (getFunction()->hasOwnership())
|
||||
return;
|
||||
|
||||
LLVM_DEBUG(llvm::dbgs() << "***** CSE on function: "
|
||||
<< getFunction()->getName() << " *****\n");
|
||||
|
||||
|
||||
@@ -105,6 +105,11 @@ private:
|
||||
bool Changed = false;
|
||||
|
||||
SILFunction *F = getFunction();
|
||||
|
||||
// FIXME: Add ownership support.
|
||||
if (F->hasOwnership())
|
||||
return;
|
||||
|
||||
for (SILBasicBlock &BB : *F) {
|
||||
if (auto *SEI = dyn_cast<SwitchEnumInst>(BB.getTerminator())) {
|
||||
Changed |= tryOptimize(SEI);
|
||||
|
||||
@@ -1474,6 +1474,10 @@ class CopyForwardingPass : public SILFunctionTransform
|
||||
if (!EnableCopyForwarding && !EnableDestroyHoisting)
|
||||
return;
|
||||
|
||||
// FIXME: We should be able to support [ossa].
|
||||
if (getFunction()->hasOwnership())
|
||||
return;
|
||||
|
||||
LLVM_DEBUG(llvm::dbgs() << "Copy Forwarding in Func "
|
||||
<< getFunction()->getName() << "\n");
|
||||
|
||||
@@ -1570,6 +1574,9 @@ class TempRValueOptPass : public SILFunctionTransform {
|
||||
|
||||
/// The main entry point of the pass.
|
||||
void TempRValueOptPass::run() {
|
||||
if (getFunction()->hasOwnership())
|
||||
return;
|
||||
|
||||
LLVM_DEBUG(llvm::dbgs() << "Copy Peephole in Func "
|
||||
<< getFunction()->getName() << "\n");
|
||||
|
||||
|
||||
@@ -111,6 +111,10 @@ class DCE : public SILFunctionTransform {
|
||||
|
||||
SILFunction *F = getFunction();
|
||||
|
||||
// FIXME: Support ownership.
|
||||
if (F->hasOwnership())
|
||||
return;
|
||||
|
||||
auto *DA = PM->getAnalysis<PostDominanceAnalysis>();
|
||||
PDT = DA->get(F);
|
||||
|
||||
|
||||
@@ -677,6 +677,10 @@ class DeadObjectElimination : public SILFunctionTransform {
|
||||
}
|
||||
|
||||
void run() override {
|
||||
// FIXME: We should support ownership eventually.
|
||||
if (getFunction()->hasOwnership())
|
||||
return;
|
||||
|
||||
if (processFunction(*getFunction())) {
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::CallsAndInstructions);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,11 @@ class GenericSpecializer : public SILFunctionTransform {
|
||||
/// The entry point to the transformation.
|
||||
void run() override {
|
||||
SILFunction &F = *getFunction();
|
||||
|
||||
// TODO: We should be able to handle ownership.
|
||||
if (F.hasOwnership())
|
||||
return;
|
||||
|
||||
LLVM_DEBUG(llvm::dbgs() << "***** GenericSpecializer on function:"
|
||||
<< F.getName() << " *****\n");
|
||||
|
||||
|
||||
@@ -1229,6 +1229,10 @@ public:
|
||||
void run() override {
|
||||
auto *Fun = getFunction();
|
||||
|
||||
// We do not support [ossa] now.
|
||||
if (Fun->hasOwnership())
|
||||
return;
|
||||
|
||||
// Only outline if we optimize for size.
|
||||
if (!Fun->optimizeForSize())
|
||||
return;
|
||||
|
||||
@@ -1641,6 +1641,10 @@ public:
|
||||
/// The entry point to the transformation.
|
||||
void run() override {
|
||||
SILFunction *F = getFunction();
|
||||
// FIXME: Handle ownership.
|
||||
if (F->hasOwnership())
|
||||
return;
|
||||
|
||||
LLVM_DEBUG(llvm::dbgs() << "*** RLE on function: " << F->getName()
|
||||
<< " ***\n");
|
||||
|
||||
|
||||
@@ -276,6 +276,9 @@ class SILLowerAggregate : public SILFunctionTransform {
|
||||
/// The entry point to the transformation.
|
||||
void run() override {
|
||||
SILFunction *F = getFunction();
|
||||
// FIXME: Can we support ownership?
|
||||
if (F->hasOwnership())
|
||||
return;
|
||||
LLVM_DEBUG(llvm::dbgs() << "***** LowerAggregate on function: " <<
|
||||
F->getName() << " *****\n");
|
||||
bool Changed = processFunction(*F);
|
||||
|
||||
@@ -940,6 +940,11 @@ class SILMem2Reg : public SILFunctionTransform {
|
||||
|
||||
void run() override {
|
||||
SILFunction *F = getFunction();
|
||||
|
||||
// FIXME: We should be able to support ownership.
|
||||
if (F->hasOwnership())
|
||||
return;
|
||||
|
||||
LLVM_DEBUG(llvm::dbgs() << "** Mem2Reg on function: " << F->getName()
|
||||
<< " **\n");
|
||||
|
||||
|
||||
@@ -332,6 +332,11 @@ class SILSROA : public SILFunctionTransform {
|
||||
/// The entry point to the transformation.
|
||||
void run() override {
|
||||
SILFunction *F = getFunction();
|
||||
|
||||
// FIXME: We should be able to handle ownership.
|
||||
if (F->hasOwnership())
|
||||
return;
|
||||
|
||||
LLVM_DEBUG(llvm::dbgs() << "***** SROA on function: " << F->getName()
|
||||
<< " *****\n");
|
||||
|
||||
|
||||
@@ -3591,6 +3591,10 @@ namespace {
|
||||
class SimplifyCFGPass : public SILFunctionTransform {
|
||||
public:
|
||||
void run() override {
|
||||
// FIXME: We should be able to handle ownership.
|
||||
if (getFunction()->hasOwnership())
|
||||
return;
|
||||
|
||||
if (SimplifyCFG(*getFunction(), *this, getOptions().VerifyAll,
|
||||
/*EnableJumpThread=*/false)
|
||||
.run())
|
||||
@@ -3608,6 +3612,9 @@ namespace {
|
||||
class JumpThreadSimplifyCFGPass : public SILFunctionTransform {
|
||||
public:
|
||||
void run() override {
|
||||
// FIXME: Handle ownership.
|
||||
if (getFunction()->hasOwnership())
|
||||
return;
|
||||
if (SimplifyCFG(*getFunction(), *this, getOptions().VerifyAll,
|
||||
/*EnableJumpThread=*/true)
|
||||
.run())
|
||||
|
||||
@@ -54,6 +54,10 @@ private:
|
||||
|
||||
void StackPromotion::run() {
|
||||
SILFunction *F = getFunction();
|
||||
// FIXME: We should be able to support ownership.
|
||||
if (F->hasOwnership())
|
||||
return;
|
||||
|
||||
LLVM_DEBUG(llvm::dbgs() << "** StackPromotion in " << F->getName() << " **\n");
|
||||
|
||||
auto *EA = PM->getAnalysis<EscapeAnalysis>();
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
// RUN: %target-sil-opt -guaranteed-arc-opts %s | %FileCheck %s
|
||||
|
||||
sil_stage raw
|
||||
|
||||
import Builtin
|
||||
|
||||
sil @kraken : $@convention(thin) () -> ()
|
||||
|
||||
// CHECK-LABEL: sil [ossa] @copyvalue_test1 : $@convention(thin) (Builtin.NativeObject, Builtin.NativeObject) -> () {
|
||||
// CHECK: bb0([[ARG1:%.*]] : @unowned $Builtin.NativeObject, [[ARG2:%.*]] : @unowned $Builtin.NativeObject):
|
||||
// CHECK-NOT: copy_value [[ARG1]]
|
||||
// CHECK: copy_value [[ARG2]]
|
||||
// CHECK-NOT: destroy_value [[ARG1]]
|
||||
sil [ossa] @copyvalue_test1 : $@convention(thin) (Builtin.NativeObject, Builtin.NativeObject) -> () {
|
||||
bb0(%0 : @unowned $Builtin.NativeObject, %1 : @unowned $Builtin.NativeObject):
|
||||
%2 = copy_value %0 : $Builtin.NativeObject
|
||||
copy_value %1 : $Builtin.NativeObject
|
||||
destroy_value %2 : $Builtin.NativeObject
|
||||
%9999 = tuple()
|
||||
return %9999 : $()
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil [ossa] @copyvalue_test2 : $@convention(thin) (Builtin.NativeObject, @in Builtin.Int32) -> Builtin.NativeObject {
|
||||
// CHECK: bb0([[ARG1:%.*]] : @unowned $Builtin.NativeObject
|
||||
// CHECK-NOT: copy_value
|
||||
// CHECK-NOT: destroy_value
|
||||
// CHECK: return [[ARG1]]
|
||||
sil [ossa] @copyvalue_test2 : $@convention(thin) (Builtin.NativeObject, @in Builtin.Int32) -> Builtin.NativeObject {
|
||||
bb0(%0 : @unowned $Builtin.NativeObject, %1 : $*Builtin.Int32):
|
||||
%2 = copy_value %0 : $Builtin.NativeObject
|
||||
%3 = integer_literal $Builtin.Int32, 0
|
||||
store %3 to [trivial] %1 : $*Builtin.Int32
|
||||
destroy_value %0 : $Builtin.NativeObject
|
||||
return %2 : $Builtin.NativeObject
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil [ossa] @copyvalue_test3 : $@convention(thin) (Builtin.NativeObject) -> () {
|
||||
// CHECK: copy_value
|
||||
// CHECK: destroy_value
|
||||
sil [ossa] @copyvalue_test3 : $@convention(thin) (Builtin.NativeObject) -> () {
|
||||
bb0(%0 : @unowned $Builtin.NativeObject):
|
||||
copy_value %0 : $Builtin.NativeObject
|
||||
%1 = function_ref @kraken : $@convention(thin) () -> ()
|
||||
apply %1() : $@convention(thin) () -> ()
|
||||
destroy_value %0 : $Builtin.NativeObject
|
||||
%9999 = tuple()
|
||||
return %9999 : $()
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil [ossa] @copyvalue_test4 : $@convention(thin) (Builtin.NativeObject) -> () {
|
||||
// CHECK: destroy_value
|
||||
sil [ossa] @copyvalue_test4 : $@convention(thin) (Builtin.NativeObject) -> () {
|
||||
bb0(%0 : @unowned $Builtin.NativeObject):
|
||||
destroy_value %0 : $Builtin.NativeObject
|
||||
%9999 = tuple()
|
||||
return %9999 : $()
|
||||
}
|
||||
Reference in New Issue
Block a user