From f8c7b54d28ee58c33a23efce62c3a57ce6711d3e Mon Sep 17 00:00:00 2001 From: Nadav Rotem Date: Thu, 6 Feb 2014 00:57:28 +0000 Subject: [PATCH] Delete the unused performXXX() functions. Swift SVN r13531 --- include/swift/SILPasses/Passes.h | 82 ----------------------- lib/SILPasses/ARCOpts.cpp | 14 ---- lib/SILPasses/AllocBoxToStack.cpp | 29 -------- lib/SILPasses/AllocRefElimination.cpp | 17 ----- lib/SILPasses/CSE.cpp | 18 ----- lib/SILPasses/CapturePromotion.cpp | 10 --- lib/SILPasses/ConstantPropagation.cpp | 9 --- lib/SILPasses/DataflowDiagnostics.cpp | 12 ---- lib/SILPasses/DeadCodeElimination.cpp | 5 -- lib/SILPasses/DefiniteInitialization.cpp | 14 ---- lib/SILPasses/Devirtualizer.cpp | 7 -- lib/SILPasses/InOutDeshadowing.cpp | 32 +-------- lib/SILPasses/MandatoryInlining.cpp | 10 +-- lib/SILPasses/Passes.cpp | 2 +- lib/SILPasses/PerformanceInliner.cpp | 30 --------- lib/SILPasses/PredictableMemOpt.cpp | 13 ---- lib/SILPasses/SILCleanup.cpp | 2 +- lib/SILPasses/SILCodeMotion.cpp | 25 ------- lib/SILPasses/SILCombine.cpp | 21 ------ lib/SILPasses/SILLowerAggregateInstrs.cpp | 18 ----- lib/SILPasses/SILMem2Reg.cpp | 11 +-- lib/SILPasses/SILSROA.cpp | 19 ------ lib/SILPasses/SimplifyCFG.cpp | 6 -- lib/SILPasses/Specializer.cpp | 6 +- lib/SILPasses/StripDebugInfo.cpp | 11 +-- 25 files changed, 11 insertions(+), 412 deletions(-) diff --git a/include/swift/SILPasses/Passes.h b/include/swift/SILPasses/Passes.h index 6e7aa728559..235279a33ed 100644 --- a/include/swift/SILPasses/Passes.h +++ b/include/swift/SILPasses/Passes.h @@ -30,47 +30,10 @@ namespace swift { /// \brief Run all the SIL performance optimization passes on \p M. void runSILOptimizationPasses(SILModule &M, const SILOptions &Options); - /// performSILDefiniteInitialization - Perform definitive initialization - /// analysis, applying flow sensitive analysis to the SILGen generated code - /// to determine whether unadorned assignment operations are actually - /// assignment or if they are initializations. - void performSILDefiniteInitialization(SILModule *M); - - /// performSILPredictableMemoryOptimizations - Perform predictable memory - /// optimizations, including promoting operations to SSA form so that later - /// analysis can depend on SSA use-def chains. - void performSILPredictableMemoryOptimizations(SILModule *M); - - /// performSILAllocBoxToStackPromotion - Promote alloc_box into stack - /// allocations. - void performSILAllocBoxToStackPromotion(SILModule *M); - - /// \brief Fold instructions with constant operands. Diagnose overflows when - /// possible. - void performSILConstantPropagation(SILModule *M); - /// \brief Detect and remove unreachable code. Diagnose provably unreachable /// user code. void performSILDeadCodeElimination(SILModule *M); - /// \brief Combine instructions to form fewer, simple instructions via a - /// simple worklist driven algorithm. - void performSILCombine(SILModule *M); - - /// \brief Perform constant subexpression elimination. - void performSILCSE(SILModule *M); - - /// \brief Simplify the CFG of SIL functions. - void performSimplifyCFG(SILModule *M); - - /// \brief Specialize generic functions by cloning them and replacing the - /// abstract type with the concrete type. - bool performSILSpecialization(SILModule *M); - - /// \brief Devirtualize virtual function calls into direct - /// function calls. - bool performSILDevirtualization(SILModule *M); - /// \brief Link a SILFunction declaration to the actual definition in the /// serialized modules. /// @@ -78,54 +41,9 @@ namespace swift { /// \param LinkAll when true, always link. For testing purposes. void performSILLinking(SILModule *M, bool LinkAll = false); - /// \brief Optimize away shadow variables for any inout arguments that don't - /// escape. - void performInOutDeshadowing(SILModule *M); - - /// \brief Inline functions marked transparent. Diagnose attempts to - /// circularly inline - void performSILMandatoryInlining(SILModule *M); - - /// \brief Perform Mem2Reg. - void performSILMem2Reg(SILModule *M); - - /// \brief Promote closure captures from [inout] to by-value. - void performSILCapturePromotion(SILModule *M); - - /// \brief Analyze the SIL module for correcntess and generate user - /// diagnostics if any. - void emitSILDataflowDiagnostics(SILModule *M); - /// \brief Cleanup instructions/builtin calls not suitable for IRGen. void performSILCleanup(SILModule *M); - /// \brief Perform SIL Inlining for Performance. - void performSILPerformanceInlining(SILModule *M, - unsigned inlineCostThreshold); - - /// \brief Perform SIL code motion optimizations. - void performSILCodeMotion(SILModule *M); - - /// \brief Replace aggregate instructions with scalar instructions. - void performSILLowerAggregateInstrs(SILModule *M); - - /// \brief Replace aggregate allocations with scalar allocations. - void performSILSROA(SILModule *M); - - /// \brief Remove redundant ARC memory operations. - void performSILARCOpts(SILModule *M); - - /// \brief Eliminate debug info instructions. - void performSILStripDebugInfo(SILModule *M); - - /// \brief Eliminate alloc_ref with well behaved destructors that have no uses - /// with side effects. - void performSILAllocRefElimination(SILModule *M); - - /// \brief Count the number of instructions in the module for all - /// instructions. - void performSILInstCount(SILModule *M); - // Diagnostics transformations. SILTransform *createCapturePromotion(); SILTransform *createInOutDeshadowing(); diff --git a/lib/SILPasses/ARCOpts.cpp b/lib/SILPasses/ARCOpts.cpp index 44b03bbaca4..25d174ee497 100644 --- a/lib/SILPasses/ARCOpts.cpp +++ b/lib/SILPasses/ARCOpts.cpp @@ -518,19 +518,6 @@ static void processFunction(SILFunction &F) { } } -void swift::performSILARCOpts(SILModule *M) { - DEBUG(llvm::dbgs() << "*** SIL ARC OPTS ***\n"); - // For each function in the module... - for (SILFunction &F : *M) { - // If the function has no basic blocks, skip it... - if (F.empty()) - continue; - - // Otherwise perform ARC optimizations. - processFunction(F); - } -} - class SILARCOpts : public SILFunctionTrans { virtual ~SILARCOpts() {} @@ -544,4 +531,3 @@ class SILARCOpts : public SILFunctionTrans { SILTransform *swift::createSILARCOpts() { return new SILARCOpts(); } - diff --git a/lib/SILPasses/AllocBoxToStack.cpp b/lib/SILPasses/AllocBoxToStack.cpp index 95d718e2ab9..e4fe62d045f 100644 --- a/lib/SILPasses/AllocBoxToStack.cpp +++ b/lib/SILPasses/AllocBoxToStack.cpp @@ -340,35 +340,6 @@ static bool optimizeAllocBox(AllocBoxInst *ABI, return true; } -//===----------------------------------------------------------------------===// -// Top Level Driver -//===----------------------------------------------------------------------===// - -void swift::performSILAllocBoxToStackPromotion(SILModule *M) { - - for (auto &Fn : *M) { - // PostDomInfo - This is the post dominance information for the specified - // function. It is lazily generated only if needed. - llvm::OwningPtr PostDomInfo; - - for (auto &BB : Fn) { - auto I = BB.begin(), E = BB.end(); - while (I != E) { - if (auto *ABI = dyn_cast(I)) - if (optimizeAllocBox(ABI, PostDomInfo)) { - ++NumStackPromoted; - // Carefully move iterator to avoid invalidation problems. - ++I; - ABI->eraseFromParent(); - continue; - } - - ++I; - } - } - } -} - class SILStackPromotion : public SILFunctionTrans { virtual ~SILStackPromotion() {} diff --git a/lib/SILPasses/AllocRefElimination.cpp b/lib/SILPasses/AllocRefElimination.cpp index 6b1f56c8bac..44f4c6a5b5e 100644 --- a/lib/SILPasses/AllocRefElimination.cpp +++ b/lib/SILPasses/AllocRefElimination.cpp @@ -337,23 +337,6 @@ processFunction(SILFunction &Fn, llvm::DenseMap &Cache) { // Top Level Driver //===----------------------------------------------------------------------===// -void swift::performSILAllocRefElimination(SILModule *M) { - DEBUG(llvm::dbgs() << "*** SIL Alloc Ref Elimination ***\n"); - - llvm::DenseMap DestructorAnalysisCache; - - for (auto &F : *M) { - // If F has no basic blocks, skip it. - if (F.empty()) - continue; - - // Otherwise process it. - processFunction(F, DestructorAnalysisCache); - } -} - - - class SILAllocRefElimination : public SILFunctionTrans { virtual ~SILAllocRefElimination() {} diff --git a/lib/SILPasses/CSE.cpp b/lib/SILPasses/CSE.cpp index c5b6d040ad1..59d73c16934 100644 --- a/lib/SILPasses/CSE.cpp +++ b/lib/SILPasses/CSE.cpp @@ -385,23 +385,6 @@ bool CSE::processNode(DominanceInfoNode *Node) { return Changed; } -//===----------------------------------------------------------------------===// -// Top Level Driver -//===----------------------------------------------------------------------===// - -void swift::performSILCSE(SILModule *M) { - CSE C; - for (SILFunction &F : *M) { - // If F is just a declaration and not a definition, skip it since it has no - // BB's to process. - if (F.empty()) - continue; - - // Perform CSE. - C.processFunction(F); - } -} - class SILCSE : public SILFunctionTrans { virtual ~SILCSE() {} @@ -417,4 +400,3 @@ class SILCSE : public SILFunctionTrans { SILTransform *swift::createCSE() { return new SILCSE(); } - diff --git a/lib/SILPasses/CapturePromotion.cpp b/lib/SILPasses/CapturePromotion.cpp index a54632c3ee0..b34aec94c5d 100644 --- a/lib/SILPasses/CapturePromotion.cpp +++ b/lib/SILPasses/CapturePromotion.cpp @@ -789,15 +789,6 @@ runOnFunction(SILFunction *F, SmallVectorImpl &Worklist) { processPartialApplyInst(IndicesPair.first, IndicesPair.second, Worklist); } -void -swift::performSILCapturePromotion(SILModule *M) { - SmallVector Worklist; - for (auto &F : *M) - runOnFunction(&F, Worklist); - while (!Worklist.empty()) - runOnFunction(Worklist.pop_back_val(), Worklist); -} - class CapturePromotionPass : public SILModuleTrans { virtual ~CapturePromotionPass() {} @@ -816,4 +807,3 @@ class CapturePromotionPass : public SILModuleTrans { SILTransform *swift::createCapturePromotion() { return new CapturePromotionPass(); } - diff --git a/lib/SILPasses/ConstantPropagation.cpp b/lib/SILPasses/ConstantPropagation.cpp index 2be2b09255b..2463be1ce72 100644 --- a/lib/SILPasses/ConstantPropagation.cpp +++ b/lib/SILPasses/ConstantPropagation.cpp @@ -809,14 +809,6 @@ static bool CCPFunctionBody(SILFunction &F) { return false; } -//===----------------------------------------------------------------------===// -// Top Level Driver -//===----------------------------------------------------------------------===// -void swift::performSILConstantPropagation(SILModule *M) { - for (auto &Fn : *M) - CCPFunctionBody(Fn); -} - class ConstantPropagation : public SILFunctionTrans { virtual ~ConstantPropagation() {} @@ -830,4 +822,3 @@ class ConstantPropagation : public SILFunctionTrans { SILTransform *swift::createConstantPropagation() { return new ConstantPropagation(); } - diff --git a/lib/SILPasses/DataflowDiagnostics.cpp b/lib/SILPasses/DataflowDiagnostics.cpp index 0f0a22c080c..b995444f4c8 100644 --- a/lib/SILPasses/DataflowDiagnostics.cpp +++ b/lib/SILPasses/DataflowDiagnostics.cpp @@ -147,16 +147,6 @@ static void diagnoseStaticReports(const SILInstruction *I, } } -void swift::emitSILDataflowDiagnostics(SILModule *M) { - for (auto &Fn : *M) - for (auto &BB : Fn) - for (auto &I : BB) { - diagnoseUnreachable(&I, M->getASTContext()); - diagnoseReturn(&I, M->getASTContext()); - diagnoseStaticReports(&I, *M); - } -} - class EmitDFDiagnostics : public SILFunctionTrans { virtual ~EmitDFDiagnostics() {} @@ -175,5 +165,3 @@ class EmitDFDiagnostics : public SILFunctionTrans { SILTransform *swift::createEmitDFDiagnostics() { return new EmitDFDiagnostics(); } - - diff --git a/lib/SILPasses/DeadCodeElimination.cpp b/lib/SILPasses/DeadCodeElimination.cpp index fa45363aa2d..2cbd209c49a 100644 --- a/lib/SILPasses/DeadCodeElimination.cpp +++ b/lib/SILPasses/DeadCodeElimination.cpp @@ -627,10 +627,6 @@ static bool removeUnreachableBlocks(SILFunction &F, SILModule &M, return true; } -//===----------------------------------------------------------------------===// -// Top Level Driver -//===----------------------------------------------------------------------===// - void swift::performSILDeadCodeElimination(SILModule *M) { for (auto &Fn : *M) { DEBUG(llvm::errs() << "*** Dead Code Elimination processing: " @@ -687,4 +683,3 @@ class DCE : public SILModuleTrans { SILTransform *swift::createDCE() { return new DCE(); } - diff --git a/lib/SILPasses/DefiniteInitialization.cpp b/lib/SILPasses/DefiniteInitialization.cpp index 469eed96c6f..eabe5f613a6 100644 --- a/lib/SILPasses/DefiniteInitialization.cpp +++ b/lib/SILPasses/DefiniteInitialization.cpp @@ -1557,19 +1557,6 @@ static void lowerRawSILOperations(SILFunction &Fn) { /// performSILDefiniteInitialization - Perform definitive initialization /// analysis and promote alloc_box uses into SSA registers for later SSA-based /// dataflow passes. -void swift::performSILDefiniteInitialization(SILModule *M) { - for (auto &Fn : *M) { - // Walk through and promote all of the alloc_box's that we can. - checkDefiniteInitialization(Fn); - DEBUG(Fn.verify()); - - // Lower raw-sil only instructions used by this pass, like "assign". - lowerRawSILOperations(Fn); - DEBUG(Fn.verify()); - } -} - - class DefiniteInitialization : public SILFunctionTrans { virtual ~DefiniteInitialization() {} @@ -1591,4 +1578,3 @@ class DefiniteInitialization : public SILFunctionTrans { SILTransform *swift::createDefiniteInitialization() { return new DefiniteInitialization(); } - diff --git a/lib/SILPasses/Devirtualizer.cpp b/lib/SILPasses/Devirtualizer.cpp index 5319e4db7d8..7b7a8cda4fe 100644 --- a/lib/SILPasses/Devirtualizer.cpp +++ b/lib/SILPasses/Devirtualizer.cpp @@ -474,13 +474,6 @@ void SILDevirtualizer::optimizeApplyInst(ApplyInst *AI) { DEBUG(llvm::dbgs() << " *** Could not find a witness table for: " << *PMI); } -bool swift::performSILDevirtualization(SILModule *M) { - bool Changed = false; - for (auto &F : *M) - Changed |= SILDevirtualizer(&F).run(); - return Changed; -} - class SILDevirtualizationPass : public SILFunctionTrans { virtual ~SILDevirtualizationPass() {} diff --git a/lib/SILPasses/InOutDeshadowing.cpp b/lib/SILPasses/InOutDeshadowing.cpp index cc7f909d999..38c20d5b5ab 100644 --- a/lib/SILPasses/InOutDeshadowing.cpp +++ b/lib/SILPasses/InOutDeshadowing.cpp @@ -131,39 +131,10 @@ static bool processInOutValue(SILArgument *InOutArg) { for (auto UI : InOutArg->getUses()) llvm::dbgs() << " " << *UI->getUser(); }); - + return false; } -//===----------------------------------------------------------------------===// -// Top Level Driver -//===----------------------------------------------------------------------===// - -void swift::performInOutDeshadowing(SILModule *M) { - DEBUG(llvm::dbgs() << "*** inout Deshadowing\n"); - - for (auto &Fn : *M) { - if (Fn.empty()) continue; - SILBasicBlock &EntryBlock = Fn.front(); - - // For each function, find any inout arguments and try to optimize each of - // them. - SILFunctionType *FTI = Fn.getLoweredFunctionType(); - - for (unsigned arg = 0, e = FTI->getInterfaceParameters().size(); arg != e; ++arg) { - if (!FTI->getInterfaceParameters()[arg].isIndirectInOut()) continue; - - DEBUG(llvm::dbgs() << " " << Fn.getName() << ": argument #" - << arg << "\n"); - - if (processInOutValue(EntryBlock.getBBArgs()[arg])) - ++NumShadowsRemoved; - else { - ++NumShadowsKept; - } - } - } -} class InOutDeshadowing : public SILFunctionTrans { virtual ~InOutDeshadowing() {} @@ -194,4 +165,3 @@ class InOutDeshadowing : public SILFunctionTrans { SILTransform *swift::createInOutDeshadowing() { return new InOutDeshadowing(); } - diff --git a/lib/SILPasses/MandatoryInlining.cpp b/lib/SILPasses/MandatoryInlining.cpp index 59da130d9ec..3ec53b706d9 100644 --- a/lib/SILPasses/MandatoryInlining.cpp +++ b/lib/SILPasses/MandatoryInlining.cpp @@ -421,13 +421,13 @@ runOnFunctionRecursively(SILFunction *F, ApplyInst* AI, // Top Level Driver //===----------------------------------------------------------------------===// -void swift::performSILMandatoryInlining(SILModule *M) { +static void performSILMandatoryInlining(SILModule *M) { DenseFunctionSet FullyInlinedSet; ImmutableFunctionSet::Factory SetFactory; for (auto &F : *M) runOnFunctionRecursively(&F, nullptr, FullyInlinedSet, SetFactory, SetFactory.getEmptySet()); - + // Now that we've inlined some functions, clean up. If there are any // transparent functions that are deserialized from another module that are // now unused, just remove them from the module. @@ -438,19 +438,19 @@ void swift::performSILMandatoryInlining(SILModule *M) { SILFunction &F = *FI++; if (F.getRefCount() != 0) continue; - + // We can always remove transparent functions. We can also remove functions // that came from closures. if (!F.isTransparent() && (!F.hasLocation() || !F.getLocation().isASTNode() || !F.getLocation().isASTNode())) continue; - + // We discard functions that don't have external linkage, e.g. deserialized // functions, internal functions, and thunks. Being marked transparent // controls this. if (isPossiblyUsedExternally(F.getLinkage())) continue; - + // Okay, just erase the function from the module. M->getFunctionList().erase(&F); } diff --git a/lib/SILPasses/Passes.cpp b/lib/SILPasses/Passes.cpp index 74109067e90..737bd3e245b 100644 --- a/lib/SILPasses/Passes.cpp +++ b/lib/SILPasses/Passes.cpp @@ -53,10 +53,10 @@ bool swift::runSILDiagnosticPasses(SILModule &Module, PM.add(createPredictableMemoryOptimizations()); PM.add(createConstantPropagation()); PM.add(createDCE()); + PM.add(createEmitDFDiagnostics()); PM.run(); // Generate diagnostics. - emitSILDataflowDiagnostics(&Module); Module.setStage(SILStage::Canonical); // If errors were produced during SIL analysis, return true. diff --git a/lib/SILPasses/PerformanceInliner.cpp b/lib/SILPasses/PerformanceInliner.cpp index e671f4f9c63..9b54befa304 100644 --- a/lib/SILPasses/PerformanceInliner.cpp +++ b/lib/SILPasses/PerformanceInliner.cpp @@ -359,35 +359,6 @@ void SILPerformanceInliner::inlineCallsIntoFunction(SILFunction *Caller) { } } -//===----------------------------------------------------------------------===// -// Top Level Driver -//===----------------------------------------------------------------------===// - -void swift::performSILPerformanceInlining(SILModule *M, - unsigned inlineCostThreshold) { - DEBUG(llvm::dbgs() << "*** SIL Performance Inlining ***\n\n"); - - if (inlineCostThreshold == 0) { - DEBUG(llvm::dbgs() << "*** The SIL performance Inliner is disabled ***\n"); - return; - } - - // Collect a call-graph bottom-up list of functions. - std::vector Worklist; - topDownCallGraphOrder(M, Worklist); - - SILPerformanceInliner inliner(inlineCostThreshold); - - // For each function in the worklist, attempt to inline its list of apply - // inst. - while (!Worklist.empty()) { - SILFunction *F = Worklist.back(); - Worklist.pop_back(); - - inliner.inlineCallsIntoFunction(F); - } -} - class SILPerformanceInlinerPass : public SILModuleTrans { unsigned Threshold; @@ -422,4 +393,3 @@ public: SILTransform *swift::createPerfInliner(unsigned threshold) { return new SILPerformanceInlinerPass(threshold); } - diff --git a/lib/SILPasses/PredictableMemOpt.cpp b/lib/SILPasses/PredictableMemOpt.cpp index 7274c7ead9b..8b76715e3ad 100644 --- a/lib/SILPasses/PredictableMemOpt.cpp +++ b/lib/SILPasses/PredictableMemOpt.cpp @@ -959,19 +959,6 @@ static void optimizeMemoryAllocations(SILFunction &Fn) { } } -/// performSILPredictableMemoryOptimizations - Perform predictable memory -/// optimizations, including promoting operations to SSA form so that later -/// analysis can depend on SSA use-def chains. -void swift::performSILPredictableMemoryOptimizations(SILModule *M) { - for (auto &Fn : *M) { - optimizeMemoryAllocations(Fn); - -#ifndef NDEBUG - Fn.verify(); -#endif - } -} - class PredictableMemoryOptimizations : public SILFunctionTrans { virtual ~PredictableMemoryOptimizations() {} diff --git a/lib/SILPasses/SILCleanup.cpp b/lib/SILPasses/SILCleanup.cpp index f7bb1a0d134..b3c69c625e9 100644 --- a/lib/SILPasses/SILCleanup.cpp +++ b/lib/SILPasses/SILCleanup.cpp @@ -65,4 +65,4 @@ class SILCleanup : public swift::SILFunctionTrans { SILTransform *swift::createSILCleanup() { return new SILCleanup(); -} \ No newline at end of file +} diff --git a/lib/SILPasses/SILCodeMotion.cpp b/lib/SILPasses/SILCodeMotion.cpp index 27f56cee196..e1cdc0958a0 100644 --- a/lib/SILPasses/SILCodeMotion.cpp +++ b/lib/SILPasses/SILCodeMotion.cpp @@ -295,30 +295,6 @@ static void sinkCodeFromPredecessors(SILBasicBlock *BB) { } } -//===----------------------------------------------------------------------===// -// Top Level Driver -//===----------------------------------------------------------------------===// - -void swift::performSILCodeMotion(SILModule *M) { - DEBUG(llvm::dbgs() << "***** SIL CODE MOTION *****\n"); - - for (SILFunction &F : *M) { - AliasAnalysis AA; - - DEBUG(llvm::dbgs() << "*** Visiting: " << F.getName() << " ***\n"); - - // Remove dead stores and merge duplicate loads. - DEBUG(llvm::dbgs() << "PROMOTING MEMORY OPERATIONS:\n"); - for (auto &BB : F) - promoteMemoryOperationsInBlock(&BB, AA); - - // Sink duplicated code from predecessors. - DEBUG(llvm::dbgs() << "SINKING DUPLICATE CODE:\n"); - for (auto &BB : F) - sinkCodeFromPredecessors(&BB); - } -} - class SILCodeMotion : public SILFunctionTrans { virtual ~SILCodeMotion() {} @@ -344,4 +320,3 @@ class SILCodeMotion : public SILFunctionTrans { SILTransform *swift::createCodeMotion() { return new SILCodeMotion(); } - diff --git a/lib/SILPasses/SILCombine.cpp b/lib/SILPasses/SILCombine.cpp index 80ee72bc577..41d0b789ba0 100644 --- a/lib/SILPasses/SILCombine.cpp +++ b/lib/SILPasses/SILCombine.cpp @@ -739,27 +739,6 @@ SILCombiner::visitRefToRawPointerInst(RefToRawPointerInst *RRPI) { return nullptr; } - -//===----------------------------------------------------------------------===// -// Top Level Driver -//===----------------------------------------------------------------------===// - -void swift::performSILCombine(SILModule *M) { - SILCombiner Combiner; - - // Process each function in M. - for (SILFunction &F : *M) { - // If F is just a declaration without any basic blocks, skip it. - if (F.empty()) - continue; - - // Combine instructions in F. - Combiner.runOnFunction(F); - } - - deleteDeadFunctions(M); -} - class SILCombine : public SILFunctionTrans { virtual ~SILCombine() {} diff --git a/lib/SILPasses/SILLowerAggregateInstrs.cpp b/lib/SILPasses/SILLowerAggregateInstrs.cpp index bb08654b48a..3a554f3f5ce 100644 --- a/lib/SILPasses/SILLowerAggregateInstrs.cpp +++ b/lib/SILPasses/SILLowerAggregateInstrs.cpp @@ -247,24 +247,6 @@ static void processFunction(SILFunction &Fn) { } } -void swift::performSILLowerAggregateInstrs(SILModule *M) { - - DEBUG(llvm::dbgs() << "*** SIL LowerAggregateInstrs ***\n"); - - // For each function Fn in M... - for (auto &Fn : *M) { - - // If Fn has no basic blocks skip it. - if (Fn.empty()) - continue; - - DEBUG(llvm::dbgs() << "***** Visiting " << Fn.getName() << " *****\n"); - - // Otherwise perform LowerAggregateInstrs. - processFunction(Fn); - } -} - class SILLowerAggregate : public SILFunctionTrans { virtual ~SILLowerAggregate() {} diff --git a/lib/SILPasses/SILMem2Reg.cpp b/lib/SILPasses/SILMem2Reg.cpp index bf607d472d3..c8c22a97d1b 100644 --- a/lib/SILPasses/SILMem2Reg.cpp +++ b/lib/SILPasses/SILMem2Reg.cpp @@ -721,21 +721,13 @@ void MemoryToRegisters::run() { } } -void promoteAllocasInFunction(SILFunction &F) { MemoryToRegisters(F).run(); } - -void swift::performSILMem2Reg(SILModule *M) { - for (auto &F : *M) - if (!F.isExternalDeclaration()) - promoteAllocasInFunction(F); -} - class SILMem2Reg : public SILFunctionTrans { virtual ~SILMem2Reg() {} virtual void runOnFunction(SILFunction &F, SILPassManager *PM) { DEBUG(llvm::dbgs() << "***** Mem2Reg on function: " << F.getName() << " *****\n"); - promoteAllocasInFunction(F); + MemoryToRegisters(F).run(); PM->invalidateAllAnalysis(&F, SILAnalysis::InvalidationKind::Instructions); } }; @@ -743,4 +735,3 @@ class SILMem2Reg : public SILFunctionTrans { SILTransform *swift::createMem2Reg() { return new SILMem2Reg(); } - diff --git a/lib/SILPasses/SILSROA.cpp b/lib/SILPasses/SILSROA.cpp index 79bebd2165c..1f57f102307 100644 --- a/lib/SILPasses/SILSROA.cpp +++ b/lib/SILPasses/SILSROA.cpp @@ -292,22 +292,6 @@ static void runSROAOnFunction(SILFunction &Fn) { } } -void swift::performSILSROA(SILModule *M) { - DEBUG(llvm::dbgs() << "*** SIL SROA ***\n"); - - // For each function Fn in M... - for (auto &Fn : *M) { - - // If Fn has no basic blocks skip it... - if (Fn.empty()) - continue; - - - // Otherwise perform SROA on Fn. - runSROAOnFunction(Fn); - } -} - class SILSROA : public SILFunctionTrans { virtual ~SILSROA() {} @@ -324,6 +308,3 @@ class SILSROA : public SILFunctionTrans { SILTransform *swift::createSROA() { return new SILSROA(); } - - - diff --git a/lib/SILPasses/SimplifyCFG.cpp b/lib/SILPasses/SimplifyCFG.cpp index fefd6450dbe..91451363bb9 100644 --- a/lib/SILPasses/SimplifyCFG.cpp +++ b/lib/SILPasses/SimplifyCFG.cpp @@ -525,12 +525,6 @@ void SimplifyCFG::run() { } } -/// \brief Simplify the CFG of SIL functions. -void swift::performSimplifyCFG(SILModule *M) { - for (auto &Fn : *M) - SimplifyCFG(Fn).run(); -} - class SimplifyCFGPass : public SILFunctionTrans { virtual ~SimplifyCFGPass() {} diff --git a/lib/SILPasses/Specializer.cpp b/lib/SILPasses/Specializer.cpp index 780e199e022..4b456cd3a96 100644 --- a/lib/SILPasses/Specializer.cpp +++ b/lib/SILPasses/Specializer.cpp @@ -431,10 +431,6 @@ bool GenericSpecializer::specializeApplyInstGroup(SILFunction *F, AIList &List) return Changed; } -bool swift::performSILSpecialization(SILModule *M) { - return GenericSpecializer(M).specialize(); -} - class SILGenericSpecializerTransform : public SILModuleTrans { public: @@ -448,7 +444,7 @@ public: CGA->bottomUpCallGraphOrder(Worklist); bool Changed = GenericSpecializer(&M).specialize(); - + if (Changed) PM->scheduleAnotherIteration(); diff --git a/lib/SILPasses/StripDebugInfo.cpp b/lib/SILPasses/StripDebugInfo.cpp index 306df17a2c0..bfecfdab7ed 100644 --- a/lib/SILPasses/StripDebugInfo.cpp +++ b/lib/SILPasses/StripDebugInfo.cpp @@ -34,15 +34,6 @@ static void stripFunction(SILFunction *F) { } } -void swift::performSILStripDebugInfo(SILModule *M) { - for (auto &F : *M) { - if (F.empty()) - continue; - - stripFunction(&F); - } -} - class StripDebugInfo : public swift::SILFunctionTrans { virtual ~StripDebugInfo() {} @@ -55,4 +46,4 @@ class StripDebugInfo : public swift::SILFunctionTrans { SILTransform *swift::createStripDebug() { return new StripDebugInfo(); -} \ No newline at end of file +}