Skip to content

Commit b50c075

Browse files
committed
---
yaml --- r: 346703 b: refs/heads/master c: f17a4a6 h: refs/heads/master i: 346701: 62e2ac1 346699: a8c699b 346695: 3eabf18 346687: 44ccaa5
1 parent cf59216 commit b50c075

File tree

11 files changed

+88
-60
lines changed

11 files changed

+88
-60
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 151eb53de93cdc43895ee2fbe6869d37c6d17762
2+
refs/heads/master: f17a4a6bef163bf8c520a872eae452e57fa4923b
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/include/swift/AST/SILOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ class SILOptions {
135135
/// Enable large loadable types IRGen pass.
136136
bool EnableLargeLoadableTypes = true;
137137

138+
/// Should the default pass pipelines strip ownership during the diagnostic
139+
/// pipeline.
140+
bool StripOwnershipDuringDiagnosticsPipeline = true;
141+
138142
/// The name of the file to which the backend should save YAML optimization
139143
/// records.
140144
std::string OptRecordFile;

trunk/include/swift/SILOptimizer/PassManager/PassPipeline.def

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,19 @@
1717
/// PASSPIPELINE(NAME, DESCRIPTION)
1818
///
1919
/// A pipeline with Name NAME and description DESCRIPTION. PassPipelinePlan
20-
/// constructor is assumed to not take a SILOptions value.
20+
/// constructor is assumed to take a SILOptions value.
2121
#ifndef PASSPIPELINE
2222
#define PASSPIPELINE(NAME, DESCRIPTION)
2323
#endif
2424

25-
/// PASSPIPELINE_WITH_OPTIONS(NAME, DESCRIPTION)
26-
///
27-
/// A pipeline with Name NAME and description DESCRIPTION. PassPipelinePlan
28-
/// constructor is assumed to take a SILOptions value.
29-
#ifndef PASSPIPELINE_WITH_OPTIONS
30-
#define PASSPIPELINE_WITH_OPTIONS(NAME, DESCRIPTION) PASSPIPELINE(NAME, DESCRIPTION)
31-
#endif
32-
33-
PASSPIPELINE_WITH_OPTIONS(Diagnostic, "Guaranteed Passes")
25+
PASSPIPELINE(Diagnostic, "Guaranteed Passes")
3426
PASSPIPELINE(OwnershipEliminator, "Utility pass to just run the ownership eliminator pass")
35-
PASSPIPELINE_WITH_OPTIONS(SILOptPrepare, "Passes that prepare SIL for -O")
36-
PASSPIPELINE_WITH_OPTIONS(Performance, "Passes run at -O")
27+
PASSPIPELINE(SILOptPrepare, "Passes that prepare SIL for -O")
28+
PASSPIPELINE(Performance, "Passes run at -O")
3729
PASSPIPELINE(Onone, "Passes run at -Onone")
3830
PASSPIPELINE(InstCount, "Utility pipeline to just run the inst count pass")
3931
PASSPIPELINE(Lowering, "SIL Address Lowering")
40-
PASSPIPELINE_WITH_OPTIONS(IRGenPrepare, "Pipeline to run during IRGen")
32+
PASSPIPELINE(IRGenPrepare, "Pipeline to run during IRGen")
4133

4234
#undef PASSPIPELINE_WITH_OPTIONS
4335
#undef PASSPIPELINE

trunk/include/swift/SILOptimizer/PassManager/PassPipeline.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,19 @@ enum class PassPipelineKind {
4141
};
4242

4343
class SILPassPipelinePlan final {
44+
const SILOptions &Options;
4445
std::vector<PassKind> Kinds;
4546
std::vector<SILPassPipeline> PipelineStages;
4647

4748
public:
48-
SILPassPipelinePlan() = default;
49+
SILPassPipelinePlan(const SILOptions &Options)
50+
: Options(Options), Kinds(), PipelineStages() {}
51+
4952
~SILPassPipelinePlan() = default;
5053
SILPassPipelinePlan(const SILPassPipelinePlan &) = default;
5154

55+
const SILOptions &getOptions() const { return Options; }
56+
5257
// Each pass gets its own add-function.
5358
#define PASS(ID, TAG, NAME) \
5459
void add##ID() { \
@@ -60,13 +65,13 @@ class SILPassPipelinePlan final {
6065
void addPasses(ArrayRef<PassKind> PassKinds);
6166

6267
#define PASSPIPELINE(NAME, DESCRIPTION) \
63-
static SILPassPipelinePlan get##NAME##PassPipeline();
64-
#define PASSPIPELINE_WITH_OPTIONS(NAME, DESCRIPTION) \
6568
static SILPassPipelinePlan get##NAME##PassPipeline(const SILOptions &Options);
6669
#include "swift/SILOptimizer/PassManager/PassPipeline.def"
6770

68-
static SILPassPipelinePlan getPassPipelineForKinds(ArrayRef<PassKind> Kinds);
69-
static SILPassPipelinePlan getPassPipelineFromFile(StringRef Filename);
71+
static SILPassPipelinePlan getPassPipelineForKinds(const SILOptions &Options,
72+
ArrayRef<PassKind> Kinds);
73+
static SILPassPipelinePlan getPassPipelineFromFile(const SILOptions &Options,
74+
StringRef Filename);
7075

7176
/// Our general format is as follows:
7277
///

trunk/lib/SILOptimizer/IPO/DeadFunctionElimination.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,5 +753,5 @@ void swift::performSILDeadFunctionElimination(SILModule *M) {
753753
SILPassManager PM(M);
754754
llvm::SmallVector<PassKind, 1> Pass = {PassKind::DeadFunctionElimination};
755755
PM.executePassPipelinePlan(
756-
SILPassPipelinePlan::getPassPipelineForKinds(Pass));
756+
SILPassPipelinePlan::getPassPipelineForKinds(M->getOptions(), Pass));
757757
}

trunk/lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ static void addDefiniteInitialization(SILPassPipelinePlan &P) {
7979
P.addRawSILInstLowering();
8080
}
8181

82-
static void addMandatoryOptPipeline(SILPassPipelinePlan &P,
83-
const SILOptions &Options) {
82+
static void addMandatoryOptPipeline(SILPassPipelinePlan &P) {
8483
P.startPipeline("Guaranteed Passes");
8584
P.addDiagnoseStaticExclusivity();
8685
P.addCapturePromotion();
@@ -99,11 +98,13 @@ static void addMandatoryOptPipeline(SILPassPipelinePlan &P,
9998
// pass. This will happen when OSSA is no longer eliminated before the
10099
// optimizer pipeline is run implying we can put a pass that requires OSSA
101100
// there.
101+
const auto &Options = P.getOptions();
102102
if (Options.EnableMandatorySemanticARCOpts && Options.shouldOptimize()) {
103103
P.addSemanticARCOpts();
104104
}
105105
P.addClosureLifetimeFixup();
106-
P.addOwnershipModelEliminator();
106+
if (Options.StripOwnershipDuringDiagnosticsPipeline)
107+
P.addOwnershipModelEliminator();
107108
P.addMandatoryInlining();
108109
P.addMandatorySILLinker();
109110

@@ -130,7 +131,7 @@ static void addMandatoryOptPipeline(SILPassPipelinePlan &P,
130131

131132
SILPassPipelinePlan
132133
SILPassPipelinePlan::getDiagnosticPassPipeline(const SILOptions &Options) {
133-
SILPassPipelinePlan P;
134+
SILPassPipelinePlan P(Options);
134135

135136
if (SILViewSILGenCFG) {
136137
addCFGPrinterPipeline(P, "SIL View SILGen CFG");
@@ -145,7 +146,7 @@ SILPassPipelinePlan::getDiagnosticPassPipeline(const SILOptions &Options) {
145146
}
146147

147148
// Otherwise run the rest of diagnostics.
148-
addMandatoryOptPipeline(P, Options);
149+
addMandatoryOptPipeline(P);
149150

150151
if (SILViewGuaranteedCFG) {
151152
addCFGPrinterPipeline(P, "SIL View Guaranteed CFG");
@@ -157,8 +158,9 @@ SILPassPipelinePlan::getDiagnosticPassPipeline(const SILOptions &Options) {
157158
// Ownership Eliminator Pipeline
158159
//===----------------------------------------------------------------------===//
159160

160-
SILPassPipelinePlan SILPassPipelinePlan::getOwnershipEliminatorPassPipeline() {
161-
SILPassPipelinePlan P;
161+
SILPassPipelinePlan SILPassPipelinePlan::getOwnershipEliminatorPassPipeline(
162+
const SILOptions &Options) {
163+
SILPassPipelinePlan P(Options);
162164
addOwnershipModelEliminatorPipeline(P);
163165
return P;
164166
}
@@ -240,8 +242,7 @@ void addHighLevelLoopOptPasses(SILPassPipelinePlan &P) {
240242
}
241243

242244
// Perform classic SSA optimizations.
243-
void addSSAPasses(SILPassPipelinePlan &P, OptimizationLevelKind OpLevel,
244-
bool stopAfterSerialization = false) {
245+
void addSSAPasses(SILPassPipelinePlan &P, OptimizationLevelKind OpLevel) {
245246
// Promote box allocations to stack allocations.
246247
P.addAllocBoxToStack();
247248

@@ -294,7 +295,12 @@ void addSSAPasses(SILPassPipelinePlan &P, OptimizationLevelKind OpLevel,
294295
// which reduces the ability of the compiler to optimize clients
295296
// importing this module.
296297
P.addSerializeSILPass();
297-
if (stopAfterSerialization)
298+
299+
// Now strip any transparent functions that still have ownership.
300+
if (!P.getOptions().StripOwnershipDuringDiagnosticsPipeline)
301+
P.addOwnershipModelEliminator();
302+
303+
if (P.getOptions().StopOptimizationAfterSerialization)
298304
return;
299305

300306
// Does inline semantics-functions (except "availability"), but not
@@ -370,6 +376,11 @@ static void addPerfEarlyModulePassPipeline(SILPassPipelinePlan &P) {
370376
// Get rid of apparently dead functions as soon as possible so that
371377
// we do not spend time optimizing them.
372378
P.addDeadFunctionElimination();
379+
380+
// Strip ownership from non-transparent functions.
381+
if (!P.getOptions().StripOwnershipDuringDiagnosticsPipeline)
382+
P.addNonTransparentFunctionOwnershipModelEliminator();
383+
373384
// Start by cloning functions from stdlib.
374385
P.addPerformanceSILLinker();
375386

@@ -399,11 +410,10 @@ static void addMidModulePassesStackPromotePassPipeline(SILPassPipelinePlan &P) {
399410
P.addStackPromotion();
400411
}
401412

402-
static bool addMidLevelPassPipeline(SILPassPipelinePlan &P,
403-
bool stopAfterSerialization) {
413+
static bool addMidLevelPassPipeline(SILPassPipelinePlan &P) {
404414
P.startPipeline("MidLevel");
405-
addSSAPasses(P, OptimizationLevelKind::MidLevel, stopAfterSerialization);
406-
if (stopAfterSerialization)
415+
addSSAPasses(P, OptimizationLevelKind::MidLevel);
416+
if (P.getOptions().StopOptimizationAfterSerialization)
407417
return true;
408418

409419
// Specialize partially applied functions with dead arguments as a preparation
@@ -538,8 +548,8 @@ static void addSILDebugInfoGeneratorPipeline(SILPassPipelinePlan &P) {
538548
/// Mandatory IRGen preparation. It is the caller's job to set the set stage to
539549
/// "lowered" after running this pipeline.
540550
SILPassPipelinePlan
541-
SILPassPipelinePlan::getLoweringPassPipeline() {
542-
SILPassPipelinePlan P;
551+
SILPassPipelinePlan::getLoweringPassPipeline(const SILOptions &Options) {
552+
SILPassPipelinePlan P(Options);
543553
P.startPipeline("Address Lowering");
544554
P.addIRGenPrepare();
545555
P.addAddressLowering();
@@ -549,7 +559,7 @@ SILPassPipelinePlan::getLoweringPassPipeline() {
549559

550560
SILPassPipelinePlan
551561
SILPassPipelinePlan::getIRGenPreparePassPipeline(const SILOptions &Options) {
552-
SILPassPipelinePlan P;
562+
SILPassPipelinePlan P(Options);
553563
P.startPipeline("IRGen Preparation");
554564
// Insert SIL passes to run during IRGen.
555565
// Hoist generic alloc_stack instructions to the entry block to enable better
@@ -563,7 +573,7 @@ SILPassPipelinePlan::getIRGenPreparePassPipeline(const SILOptions &Options) {
563573

564574
SILPassPipelinePlan
565575
SILPassPipelinePlan::getSILOptPreparePassPipeline(const SILOptions &Options) {
566-
SILPassPipelinePlan P;
576+
SILPassPipelinePlan P(Options);
567577

568578
if (Options.DebugSerialization) {
569579
addPerfDebugSerializationPipeline(P);
@@ -578,7 +588,7 @@ SILPassPipelinePlan::getSILOptPreparePassPipeline(const SILOptions &Options) {
578588

579589
SILPassPipelinePlan
580590
SILPassPipelinePlan::getPerformancePassPipeline(const SILOptions &Options) {
581-
SILPassPipelinePlan P;
591+
SILPassPipelinePlan P(Options);
582592

583593
if (Options.DebugSerialization) {
584594
addPerfDebugSerializationPipeline(P);
@@ -594,7 +604,7 @@ SILPassPipelinePlan::getPerformancePassPipeline(const SILOptions &Options) {
594604
addMidModulePassesStackPromotePassPipeline(P);
595605

596606
// Run an iteration of the mid-level SSA passes.
597-
if (addMidLevelPassPipeline(P, Options.StopOptimizationAfterSerialization))
607+
if (addMidLevelPassPipeline(P))
598608
return P;
599609

600610
// Perform optimizations that specialize.
@@ -624,8 +634,9 @@ SILPassPipelinePlan::getPerformancePassPipeline(const SILOptions &Options) {
624634
// Onone Pass Pipeline
625635
//===----------------------------------------------------------------------===//
626636

627-
SILPassPipelinePlan SILPassPipelinePlan::getOnonePassPipeline() {
628-
SILPassPipelinePlan P;
637+
SILPassPipelinePlan
638+
SILPassPipelinePlan::getOnonePassPipeline(const SILOptions &Options) {
639+
SILPassPipelinePlan P(Options);
629640

630641
// First specialize user-code.
631642
P.startPipeline("Prespecialization");
@@ -642,15 +653,20 @@ SILPassPipelinePlan SILPassPipelinePlan::getOnonePassPipeline() {
642653
// Finally serialize the SIL if we are asked to.
643654
P.addSerializeSILPass();
644655

656+
// And then strip ownership before we IRGen.
657+
if (!Options.StripOwnershipDuringDiagnosticsPipeline)
658+
P.addOwnershipModelEliminator();
659+
645660
return P;
646661
}
647662

648663
//===----------------------------------------------------------------------===//
649664
// Inst Count Pass Pipeline
650665
//===----------------------------------------------------------------------===//
651666

652-
SILPassPipelinePlan SILPassPipelinePlan::getInstCountPassPipeline() {
653-
SILPassPipelinePlan P;
667+
SILPassPipelinePlan
668+
SILPassPipelinePlan::getInstCountPassPipeline(const SILOptions &Options) {
669+
SILPassPipelinePlan P(Options);
654670
P.startPipeline("Inst Count");
655671
P.addInstCount();
656672
return P;
@@ -680,8 +696,9 @@ void SILPassPipelinePlan::addPasses(ArrayRef<PassKind> PassKinds) {
680696
}
681697

682698
SILPassPipelinePlan
683-
SILPassPipelinePlan::getPassPipelineForKinds(ArrayRef<PassKind> PassKinds) {
684-
SILPassPipelinePlan P;
699+
SILPassPipelinePlan::getPassPipelineForKinds(const SILOptions &Options,
700+
ArrayRef<PassKind> PassKinds) {
701+
SILPassPipelinePlan P(Options);
685702
P.startPipeline("Pass List Pipeline");
686703
P.addPasses(PassKinds);
687704
return P;
@@ -717,7 +734,8 @@ void SILPassPipelinePlan::print(llvm::raw_ostream &os) {
717734
}
718735

719736
SILPassPipelinePlan
720-
SILPassPipelinePlan::getPassPipelineFromFile(StringRef Filename) {
737+
SILPassPipelinePlan::getPassPipelineFromFile(const SILOptions &Options,
738+
StringRef Filename) {
721739
namespace yaml = llvm::yaml;
722740
LLVM_DEBUG(llvm::dbgs() << "Parsing Pass Pipeline from " << Filename << "\n");
723741

@@ -736,7 +754,7 @@ SILPassPipelinePlan::getPassPipelineFromFile(StringRef Filename) {
736754
yaml::Node *N = DI->getRoot();
737755
assert(N && "Failed to find a root");
738756

739-
SILPassPipelinePlan P;
757+
SILPassPipelinePlan P(Options);
740758

741759
auto *RootList = cast<yaml::SequenceNode>(N);
742760
llvm::SmallVector<PassKind, 32> Passes;

trunk/lib/SILOptimizer/PassManager/Passes.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ bool swift::runSILOwnershipEliminatorPass(SILModule &Module) {
7878

7979
SILPassManager PM(&Module);
8080
PM.executePassPipelinePlan(
81-
SILPassPipelinePlan::getOwnershipEliminatorPassPipeline());
81+
SILPassPipelinePlan::getOwnershipEliminatorPassPipeline(
82+
Module.getOptions()));
8283

8384
return Ctx.hadError();
8485
}
@@ -122,7 +123,8 @@ void swift::runSILPassesForOnone(SILModule &Module) {
122123
// We want to run the Onone passes also for function which have an explicit
123124
// Onone attribute.
124125
SILPassManager PM(&Module, "Onone", /*isMandatoryPipeline=*/ true);
125-
PM.executePassPipelinePlan(SILPassPipelinePlan::getOnonePassPipeline());
126+
PM.executePassPipelinePlan(
127+
SILPassPipelinePlan::getOnonePassPipeline(Module.getOptions()));
126128

127129
// Verify the module, if required.
128130
if (Module.getOptions().VerifyAll)
@@ -136,7 +138,7 @@ void swift::runSILOptimizationPassesWithFileSpecification(SILModule &M,
136138
StringRef Filename) {
137139
SILPassManager PM(&M);
138140
PM.executePassPipelinePlan(
139-
SILPassPipelinePlan::getPassPipelineFromFile(Filename));
141+
SILPassPipelinePlan::getPassPipelineFromFile(M.getOptions(), Filename));
140142
}
141143

142144
/// Get the Pass ID enum value from an ID string.
@@ -187,7 +189,8 @@ StringRef swift::PassKindTag(PassKind Kind) {
187189
// same stage of lowering.
188190
void swift::runSILLoweringPasses(SILModule &Module) {
189191
SILPassManager PM(&Module, "LoweringPasses", /*isMandatoryPipeline=*/ true);
190-
PM.executePassPipelinePlan(SILPassPipelinePlan::getLoweringPassPipeline());
192+
PM.executePassPipelinePlan(
193+
SILPassPipelinePlan::getLoweringPassPipeline(Module.getOptions()));
191194

192195
assert(Module.getStage() == SILStage::Lowered);
193196
}

trunk/lib/SILOptimizer/UtilityPasses/InstCount.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,5 +157,5 @@ void swift::performSILInstCountIfNeeded(SILModule *M) {
157157
return;
158158
SILPassManager PrinterPM(M);
159159
PrinterPM.executePassPipelinePlan(
160-
SILPassPipelinePlan::getInstCountPassPipeline());
160+
SILPassPipelinePlan::getInstCountPassPipeline(M->getOptions()));
161161
}

trunk/stdlib/public/Platform/winsdk.modulemap

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
module WinSDK [system] [extern_c] {
14+
module WinSock2 {
15+
header "WinSock2.h"
16+
header "WS2tcpip.h"
17+
export *
18+
}
19+
1420
module core {
1521
// api-ms-win-core-errhandling-l1-1-0.dll
1622
module errhandling {
@@ -42,6 +48,11 @@ module WinSDK [system] [extern_c] {
4248
export *
4349
}
4450

51+
module iphlp {
52+
header "iphlpapi.h"
53+
export *
54+
}
55+
4556
// api-ms-win-core-libloader-l1-1-0.dll
4657
module libloader {
4758
header "libloaderapi.h"

trunk/tools/sil-opt/SILOpt.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ static void runCommandLineSelectedPasses(SILModule *Module,
257257
#include "swift/SILOptimizer/PassManager/Passes.def"
258258
}
259259

260-
PM.executePassPipelinePlan(
261-
SILPassPipelinePlan::getPassPipelineForKinds(Passes));
260+
PM.executePassPipelinePlan(SILPassPipelinePlan::getPassPipelineForKinds(
261+
Module->getOptions(), Passes));
262262

263263
if (Module->getOptions().VerifyAll)
264264
Module->verify();

0 commit comments

Comments
 (0)