Skip to content

Commit 1aa84cb

Browse files
Merge pull request #64651 from nate-chandler/nfc/rename-destroy-addr-hoisting
[NFC] Renamed DestroyAddrHoisting.
2 parents 36676c8 + 1a7c4a4 commit 1aa84cb

File tree

10 files changed

+42
-43
lines changed

10 files changed

+42
-43
lines changed

include/swift/AST/SILOptions.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ enum class CopyPropagationOption : uint8_t {
5959
};
6060

6161
enum class DestroyHoistingOption : uint8_t {
62-
// Do not run SSADestroyHoisting.
62+
// Do not run DestroyAddrHoisting.
6363
Off = 0,
6464

65-
// Run SSADestroyHoisting pass after AllocBoxToStack in the function passes.
65+
// Run DestroyAddrHoisting pass after AllocBoxToStack in the function passes.
6666
On = 1
6767
};
6868

@@ -98,7 +98,7 @@ class SILOptions {
9898
/// When this is 'On' the pipeline has default behavior.
9999
CopyPropagationOption CopyPropagation = CopyPropagationOption::On;
100100

101-
/// Whether to run the SSADestroyHoisting pass.
101+
/// Whether to run the DestroyAddrHoisting pass.
102102
///
103103
/// When this 'On' the pipeline has the default behavior.
104104
DestroyHoistingOption DestroyHoisting = DestroyHoistingOption::On;

include/swift/SILOptimizer/PassManager/Passes.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ PASS(DefiniteInitialization, "definite-init",
182182
"Definite Initialization for Diagnostics")
183183
PASS(DestroyHoisting, "destroy-hoisting",
184184
"Hoisting of value destroys")
185-
PASS(SSADestroyHoisting, "ssa-destroy-hoisting",
185+
PASS(DestroyAddrHoisting, "destroy-addr-hoisting",
186186
"Hoist destroy_addr for uniquely identified values")
187187
PASS(Devirtualizer, "devirtualizer",
188188
"Indirect Call Devirtualization")

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ void addFunctionPasses(SILPassPipelinePlan &P,
382382
P.addAllocBoxToStack();
383383

384384
if (P.getOptions().DestroyHoisting == DestroyHoistingOption::On) {
385-
P.addSSADestroyHoisting();
385+
P.addDestroyAddrHoisting();
386386
}
387387

388388
// Propagate copies through stack locations. Should run after

lib/SILOptimizer/Transforms/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ target_sources(swiftSILOptimizer PRIVATE
3333
SILLowerAggregateInstrs.cpp
3434
SILMem2Reg.cpp
3535
SILSROA.cpp
36-
SSADestroyHoisting.cpp
36+
DestroyAddrHoisting.cpp
3737
SimplifyCFG.cpp
3838
Sink.cpp
3939
SpeculativeDevirtualizer.cpp

lib/SILOptimizer/Transforms/SSADestroyHoisting.cpp renamed to lib/SILOptimizer/Transforms/DestroyAddrHoisting.cpp

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
//===--- SSADestroyHoisting.cpp - SSA-based destroy hoisting --------------===//
1+
//===--- DestroyAddrHoisting.cpp - SSA-based destroy_addr hoisting --------===//
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -87,7 +87,7 @@
8787
///
8888
/// ===--------------------------------------------------------------------===//
8989

90-
#define DEBUG_TYPE "ssa-destroy-hoisting"
90+
#define DEBUG_TYPE "destroy-addr-hoisting"
9191

9292
#include "swift/AST/Type.h"
9393
#include "swift/Basic/GraphNodeWorklist.h"
@@ -121,8 +121,8 @@ struct KnownStorageUses : UniqueStorageUseVisitor {
121121
preserveDebugInfo(function->preserveDebugInfo()) {}
122122

123123
bool empty() const {
124-
return storageUsers.empty() && originalDestroys.empty()
125-
&& debugInsts.empty();
124+
return storageUsers.empty() && originalDestroys.empty() &&
125+
debugInsts.empty();
126126
}
127127

128128
SILFunction *getFunction() const { return function; }
@@ -449,8 +449,7 @@ class HoistDestroys {
449449
void insertDestroy(SILInstruction *barrier, SILInstruction *insertBefore,
450450
const KnownStorageUses &knownUses);
451451

452-
void createDestroy(SILInstruction *insertBefore,
453-
const SILDebugScope *scope);
452+
void createDestroy(SILInstruction *insertBefore, const SILDebugScope *scope);
454453

455454
void createSuccessorDestroys(SILBasicBlock *barrierBlock);
456455

@@ -810,16 +809,16 @@ void HoistDestroys::insertDestroy(SILInstruction *barrier,
810809
destroyMergeBlocks.insert(branch->getDestBB());
811810
}
812811
// Avoid mutating SIL for no reason. This could lead to infinite loops.
813-
if (isa<DestroyAddrInst>(insertBefore)
814-
|| isa<DestroyValueInst>(insertBefore)) {
815-
if (llvm::find(knownUses.originalDestroys, insertBefore)
816-
!= knownUses.originalDestroys.end()) {
812+
if (isa<DestroyAddrInst>(insertBefore) ||
813+
isa<DestroyValueInst>(insertBefore)) {
814+
if (llvm::find(knownUses.originalDestroys, insertBefore) !=
815+
knownUses.originalDestroys.end()) {
817816
reusedDestroys.insert(insertBefore);
818817
return;
819818
}
820819
}
821-
const SILDebugScope *scope = barrier
822-
? barrier->getDebugScope() : getFunction()->getDebugScope();
820+
const SILDebugScope *scope =
821+
barrier ? barrier->getDebugScope() : getFunction()->getDebugScope();
823822
createDestroy(insertBefore, scope);
824823
}
825824

@@ -829,10 +828,10 @@ void HoistDestroys::createDestroy(SILInstruction *insertBefore,
829828
SILInstruction *newDestroy;
830829
if (storageRoot->getType().isAddress()) {
831830
newDestroy =
832-
SILBuilder(insertBefore, scope).createDestroyAddr(loc, storageRoot);
831+
SILBuilder(insertBefore, scope).createDestroyAddr(loc, storageRoot);
833832
} else {
834833
newDestroy =
835-
SILBuilder(insertBefore, scope).createDestroyValue(loc, storageRoot);
834+
SILBuilder(insertBefore, scope).createDestroyValue(loc, storageRoot);
836835
}
837836
deleter.getCallbacks().createdNewInst(newDestroy);
838837
}
@@ -841,8 +840,8 @@ void HoistDestroys::mergeDestroys(SILBasicBlock *mergeBlock) {
841840
SmallVector<SILInstruction *, 4> deadDestroys;
842841
for (auto *predecessors : mergeBlock->getPredecessorBlocks()) {
843842
auto *tailDestroy = predecessors->getTerminator()->getPreviousInstruction();
844-
if (!tailDestroy || (!isa<DestroyAddrInst>(tailDestroy)
845-
&& !isa<DestroyValueInst>(tailDestroy))) {
843+
if (!tailDestroy || (!isa<DestroyAddrInst>(tailDestroy) &&
844+
!isa<DestroyValueInst>(tailDestroy))) {
846845
return;
847846
}
848847
if (tailDestroy->getOperand(0) != storageRoot)
@@ -894,15 +893,15 @@ bool hoistDestroys(SILValue root, bool ignoreDeinitBarriers,
894893
// =============================================================================
895894

896895
namespace {
897-
class SSADestroyHoisting : public swift::SILFunctionTransform {
896+
class DestroyAddrHoisting : public swift::SILFunctionTransform {
898897
void run() override;
899898
};
900899
} // end anonymous namespace
901900

902901
// TODO: Handle alloc_box the same way, as long as the box doesn't escape.
903902
//
904903
// TODO: Handle address and boxes that are captured in no-escape closures.
905-
void SSADestroyHoisting::run() {
904+
void DestroyAddrHoisting::run() {
906905
if (!getFunction()->hasOwnership())
907906
return;
908907

@@ -1067,6 +1066,6 @@ void SSADestroyHoisting::run() {
10671066
}
10681067
}
10691068

1070-
SILTransform *swift::createSSADestroyHoisting() {
1071-
return new SSADestroyHoisting();
1069+
SILTransform *swift::createDestroyAddrHoisting() {
1070+
return new DestroyAddrHoisting();
10721071
}

test/SILOptimizer/disable-copy-propagation-frontend-flag.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,30 +74,30 @@
7474
// RUN: 2>&1 | %FileCheck -check-prefix CHECK-CPON-DHON %s
7575

7676
// CHECK-CPUNSPEC-DHUNSPEC: copy-propagation
77-
// CHECK-CPUNSPEC-DHUNSPEC: ssa-destroy-hoisting
77+
// CHECK-CPUNSPEC-DHUNSPEC: destroy-addr-hoisting
7878

7979
// CHECK-CPUNSPEC-DHOFF: copy-propagation
80-
// CHECK-CPUNSPEC-DHOFF-NOT: ssa-destroy-hoisting
80+
// CHECK-CPUNSPEC-DHOFF-NOT: destroy-addr-hoisting
8181

8282
// CHECK-CPUNSPEC-DHON: copy-propagation
83-
// CHECK-CPUNSPEC-DHON: ssa-destroy-hoisting
83+
// CHECK-CPUNSPEC-DHON: destroy-addr-hoisting
8484

8585
// CHECK-CPOFF-DHUNSPEC-NOT: copy-propagation
86-
// CHECK-CPOFF-DHUNSPEC-NOT: ssa-destroy-hoisting
86+
// CHECK-CPOFF-DHUNSPEC-NOT: destroy-addr-hoisting
8787

8888
// CHECK-CPOFF-DHOFF-NOT: copy-propagation
89-
// CHECK-CPOFF-DHOFF-NOT: ssa-destroy-hoisting
89+
// CHECK-CPOFF-DHOFF-NOT: destroy-addr-hoisting
9090

9191
// CHECK-CPOFF-DHON-NOT: copy-propagation
92-
// CHECK-CPOFF-DHON: ssa-destroy-hoisting
92+
// CHECK-CPOFF-DHON: destroy-addr-hoisting
9393

9494
// CHECK-CPON-DHUNSPEC: copy-propagation
95-
// CHECK-CPON-DHUNSPEC: ssa-destroy-hoisting
95+
// CHECK-CPON-DHUNSPEC: destroy-addr-hoisting
9696

9797
// CHECK-CPON-DHOFF: copy-propagation
98-
// CHECK-CPON-DHOFF-NOT: ssa-destroy-hoisting
98+
// CHECK-CPON-DHOFF-NOT: destroy-addr-hoisting
9999

100100
// CHECK-CPON-DHON: copy-propagation
101-
// CHECK-CPON-DHON: ssa-destroy-hoisting
101+
// CHECK-CPON-DHON: destroy-addr-hoisting
102102

103103
func foo() {}

test/SILOptimizer/hoist_destroy_addr.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-sil-opt -opt-mode=none -enable-sil-verify-all %s -compute-side-effects -ssa-destroy-hoisting | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECKDEB --check-prefix=CHECK-DEB
2-
// RUN: %target-sil-opt -opt-mode=speed -enable-sil-verify-all %s -compute-side-effects -ssa-destroy-hoisting | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECKOPT --check-prefix=CHECK-OPT
1+
// RUN: %target-sil-opt -opt-mode=none -enable-sil-verify-all %s -compute-side-effects -destroy-addr-hoisting | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECKDEB --check-prefix=CHECK-DEB
2+
// RUN: %target-sil-opt -opt-mode=speed -enable-sil-verify-all %s -compute-side-effects -destroy-addr-hoisting | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECKOPT --check-prefix=CHECK-OPT
33
//
44
// TODO: migrate the remaining tests from destroy_hoisting.sil.
55

test/SILOptimizer/hoist_destroy_addr_loop.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-sil-opt -opt-mode=none -enable-sil-verify-all %s -ssa-destroy-hoisting | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECKDEB
2-
// RUN: %target-sil-opt -opt-mode=speed -enable-sil-verify-all %s -ssa-destroy-hoisting | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECKOPT
1+
// RUN: %target-sil-opt -opt-mode=none -enable-sil-verify-all %s -destroy-addr-hoisting | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECKDEB
2+
// RUN: %target-sil-opt -opt-mode=speed -enable-sil-verify-all %s -destroy-addr-hoisting | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECKOPT
33

44
sil_stage canonical
55

test/SILOptimizer/hoist_destroy_addr_resilient.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// RUN: -emit-module-path=%t/resilient_struct.swiftmodule \
44
// RUN: -module-name=resilient_struct %S/../Inputs/resilient_struct.swift
55

6-
// RUN: %target-sil-opt -I %t -opt-mode=speed -enable-sil-verify-all %s -ssa-destroy-hoisting | %FileCheck %s --check-prefix=CHECK
6+
// RUN: %target-sil-opt -I %t -opt-mode=speed -enable-sil-verify-all %s -destroy-addr-hoisting | %FileCheck %s --check-prefix=CHECK
77

88
import resilient_struct
99

validation-test/SILOptimizer/hoist_destroy_addr.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-sil-opt -opt-mode=none -enable-sil-verify-all %s -ssa-destroy-hoisting | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECKDEB
2-
// RUN: %target-sil-opt -opt-mode=speed -enable-sil-verify-all %s -ssa-destroy-hoisting | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECKOPT
1+
// RUN: %target-sil-opt -opt-mode=none -enable-sil-verify-all %s -destroy-addr-hoisting | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECKDEB
2+
// RUN: %target-sil-opt -opt-mode=speed -enable-sil-verify-all %s -destroy-addr-hoisting | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECKOPT
33

44
// REQUIRES: rdar98890125
55
// REQUIRES: long_test

0 commit comments

Comments
 (0)