Skip to content

Commit 5baa90c

Browse files
committed
[irgen-prepare] Move SILCleanup to ./lib/SILOptimizer/Mandatory and rename it to IRGenPrepare.
I am going to be adding logic here to enable #1550 to be completed. The rename makes sense due to precedent from LLVM's codegen prepare and also since I am going to be expanding what the pass is doing beyond just "cleaning up". It is really a grab bag pass for performing simple transformations that we do not want to pollute IRGen's logic with. #15502 rdar://39335800
1 parent 81d4ec8 commit 5baa90c

File tree

6 files changed

+12
-15
lines changed

6 files changed

+12
-15
lines changed

include/swift/SILOptimizer/PassManager/Passes.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ PASS(TempRValueOpt, "temp-rvalue-opt",
232232
"Remove short-lived immutable temporary copies")
233233
PASS(SideEffectsDumper, "side-effects-dump",
234234
"Print Side-Effect Information for all Functions")
235-
PASS(SILCleanup, "cleanup",
236-
"SIL Cleanup Preparation for IRGen")
235+
PASS(IRGenPrepare, "irgen-prepare",
236+
"Cleanup SIL in preparation for IRGen")
237237
PASS(SILCombine, "sil-combine",
238238
"Combine SIL Instructions via Peephole Optimization")
239239
PASS(SILDebugInfoGenerator, "sil-debuginfo-gen",

lib/SILOptimizer/Mandatory/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ set(MANDATORY_SOURCES
22
Mandatory/AccessEnforcementSelection.cpp
33
Mandatory/AccessMarkerElimination.cpp
44
Mandatory/AddressLowering.cpp
5+
Mandatory/ConstantPropagation.cpp
56
Mandatory/DefiniteInitialization.cpp
67
Mandatory/DIMemoryUseCollector.cpp
78
Mandatory/DIMemoryUseCollectorOwnership.cpp
@@ -10,8 +11,8 @@ set(MANDATORY_SOURCES
1011
Mandatory/DiagnoseStaticExclusivity.cpp
1112
Mandatory/DiagnoseUnreachable.cpp
1213
Mandatory/GuaranteedARCOpts.cpp
14+
Mandatory/IRGenPrepare.cpp
1315
Mandatory/MandatoryInlining.cpp
1416
Mandatory/PredictableMemOpt.cpp
15-
Mandatory/ConstantPropagation.cpp
1617
Mandatory/SemanticARCOpts.cpp
1718
PARENT_SCOPE)

lib/SILOptimizer/Transforms/SILCleanup.cpp renamed to lib/SILOptimizer/Mandatory/IRGenPrepare.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
//===--- SILCleanup.cpp - Removes diagnostics instructions ----------------===//
1+
//===--- IRGenPrepare.cpp -------------------------------------------------===//
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2018 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
@@ -13,9 +13,6 @@
1313
// Cleanup SIL to make it suitable for IRGen. Specifically, removes the calls to
1414
// Builtin.staticReport(), which are not needed post SIL.
1515
//
16-
// FIXME: This pass is mandatory so should probably be in
17-
// SILOptimizer/Mandatory.
18-
//
1916
//===----------------------------------------------------------------------===//
2017

2118
#include "swift/SILOptimizer/PassManager/Passes.h"
@@ -50,7 +47,7 @@ static void cleanFunction(SILFunction &Fn) {
5047
}
5148

5249
namespace {
53-
class SILCleanup : public swift::SILFunctionTransform {
50+
class IRGenPrepare : public swift::SILFunctionTransform {
5451

5552
/// The entry point to the transformation.
5653
void run() override {
@@ -62,6 +59,6 @@ class SILCleanup : public swift::SILFunctionTransform {
6259
} // end anonymous namespace
6360

6461

65-
SILTransform *swift::createSILCleanup() {
66-
return new SILCleanup();
62+
SILTransform *swift::createIRGenPrepare() {
63+
return new IRGenPrepare();
6764
}

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ SILPassPipelinePlan
456456
SILPassPipelinePlan::getLoweringPassPipeline() {
457457
SILPassPipelinePlan P;
458458
P.startPipeline("Address Lowering");
459-
P.addSILCleanup();
459+
P.addIRGenPrepare();
460460
P.addAddressLowering();
461461

462462
return P;

lib/SILOptimizer/Transforms/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ set(TRANSFORMS_SOURCES
2323
Transforms/RedundantOverflowCheckRemoval.cpp
2424
Transforms/ReleaseDevirtualizer.cpp
2525
Transforms/RemovePin.cpp
26-
Transforms/SILCleanup.cpp
2726
Transforms/SILCodeMotion.cpp
2827
Transforms/SILLowerAggregateInstrs.cpp
2928
Transforms/SILMem2Reg.cpp

utils/pass-pipeline/src/passes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
PerfInliner = Pass('PerfInliner')
4141
PerformanceConstantPropagation = Pass('PerformanceConstantPropagation')
4242
PredictableMemoryOptimizations = Pass('PredictableMemoryOptimizations')
43-
SILCleanup = Pass('SILCleanup')
43+
IRGenPrepare = Pass('IRGenPrepare')
4444
SILCombine = Pass('SILCombine')
4545
SILLinker = Pass('SILLinker')
4646
SROA = Pass('SROA')
@@ -89,7 +89,7 @@
8989
PerfInliner,
9090
PerformanceConstantPropagation,
9191
PredictableMemoryOptimizations,
92-
SILCleanup,
92+
IRGenPrepare,
9393
SILCombine,
9494
SILLinker,
9595
SROA,

0 commit comments

Comments
 (0)