Skip to content

Commit 9f0ff0b

Browse files
committed
[LegacyPassManager] Delete BasicBlockPass/Manager.
Summary: Delete the BasicBlockPass and BasicBlockManager, all its dependencies and update documentation. The BasicBlockManager was improperly tested and found to be potentially broken, and was deprecated as of rL373254. In light of the switch to the new pass manager coming before the next release, this patch is a first cleanup of the LegacyPassManager. Reviewers: chandlerc, echristo Subscribers: mehdi_amini, sanjoy.google, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D69121
1 parent f25f3d3 commit 9f0ff0b

19 files changed

+37
-565
lines changed

llvm/docs/OptBisect.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ to make this check uniform across all passes. These helper functions are:
157157
bool ModulePass::skipModule(Module &M);
158158
bool CallGraphSCCPass::skipSCC(CallGraphSCC &SCC);
159159
bool FunctionPass::skipFunction(const Function &F);
160-
bool BasicBlockPass::skipBasicBlock(const BasicBlock &BB);
161160
bool LoopPass::skipLoop(const Loop *L);
162161
163162
A MachineFunctionPass should use FunctionPass::skipFunction() as such:

llvm/docs/WritingAnLLVMPass.rst

Lines changed: 3 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ on how your pass works, you should inherit from the :ref:`ModulePass
2424
<writing-an-llvm-pass-CallGraphSCCPass>`, :ref:`FunctionPass
2525
<writing-an-llvm-pass-FunctionPass>` , or :ref:`LoopPass
2626
<writing-an-llvm-pass-LoopPass>`, or :ref:`RegionPass
27-
<writing-an-llvm-pass-RegionPass>`, or :ref:`BasicBlockPass
28-
<writing-an-llvm-pass-BasicBlockPass>` classes, which gives the system more
27+
<writing-an-llvm-pass-RegionPass>` classes, which gives the system more
2928
information about what your pass does, and how it can be combined with other
3029
passes. One of the main features of the LLVM Pass Framework is that it
3130
schedules passes to run in an efficient way based on the constraints that your
@@ -395,8 +394,7 @@ before callers). Deriving from ``CallGraphSCCPass`` provides some mechanics
395394
for building and traversing the ``CallGraph``, but also allows the system to
396395
optimize execution of ``CallGraphSCCPass``\ es. If your pass meets the
397396
requirements outlined below, and doesn't meet the requirements of a
398-
:ref:`FunctionPass <writing-an-llvm-pass-FunctionPass>` or :ref:`BasicBlockPass
399-
<writing-an-llvm-pass-BasicBlockPass>`, you should derive from
397+
:ref:`FunctionPass <writing-an-llvm-pass-FunctionPass>`, you should derive from
400398
``CallGraphSCCPass``.
401399

402400
``TODO``: explain briefly what SCC, Tarjan's algo, and B-U mean.
@@ -648,69 +646,6 @@ when the pass framework has finished calling :ref:`runOnRegion
648646
<writing-an-llvm-pass-runOnRegion>` for every region in the program being
649647
compiled.
650648

651-
.. _writing-an-llvm-pass-BasicBlockPass:
652-
653-
The ``BasicBlockPass`` class
654-
----------------------------
655-
656-
``BasicBlockPass``\ es are just like :ref:`FunctionPass's
657-
<writing-an-llvm-pass-FunctionPass>` , except that they must limit their scope
658-
of inspection and modification to a single basic block at a time. As such,
659-
they are **not** allowed to do any of the following:
660-
661-
#. Modify or inspect any basic blocks outside of the current one.
662-
#. Maintain state across invocations of :ref:`runOnBasicBlock
663-
<writing-an-llvm-pass-runOnBasicBlock>`.
664-
#. Modify the control flow graph (by altering terminator instructions)
665-
#. Any of the things forbidden for :ref:`FunctionPasses
666-
<writing-an-llvm-pass-FunctionPass>`.
667-
668-
``BasicBlockPass``\ es are useful for traditional local and "peephole"
669-
optimizations. They may override the same :ref:`doInitialization(Module &)
670-
<writing-an-llvm-pass-doInitialization-mod>` and :ref:`doFinalization(Module &)
671-
<writing-an-llvm-pass-doFinalization-mod>` methods that :ref:`FunctionPass's
672-
<writing-an-llvm-pass-FunctionPass>` have, but also have the following virtual
673-
methods that may also be implemented:
674-
675-
The ``doInitialization(Function &)`` method
676-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
677-
678-
.. code-block:: c++
679-
680-
virtual bool doInitialization(Function &F);
681-
682-
The ``doInitialization`` method is allowed to do most of the things that
683-
``BasicBlockPass``\ es are not allowed to do, but that ``FunctionPass``\ es
684-
can. The ``doInitialization`` method is designed to do simple initialization
685-
that does not depend on the ``BasicBlock``\ s being processed. The
686-
``doInitialization`` method call is not scheduled to overlap with any other
687-
pass executions (thus it should be very fast).
688-
689-
.. _writing-an-llvm-pass-runOnBasicBlock:
690-
691-
The ``runOnBasicBlock`` method
692-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
693-
694-
.. code-block:: c++
695-
696-
virtual bool runOnBasicBlock(BasicBlock &BB) = 0;
697-
698-
Override this function to do the work of the ``BasicBlockPass``. This function
699-
is not allowed to inspect or modify basic blocks other than the parameter, and
700-
are not allowed to modify the CFG. A ``true`` value must be returned if the
701-
basic block is modified.
702-
703-
The ``doFinalization(Function &)`` method
704-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
705-
706-
.. code-block:: c++
707-
708-
virtual bool doFinalization(Function &F);
709-
710-
The ``doFinalization`` method is an infrequently used method that is called
711-
when the pass framework has finished calling :ref:`runOnBasicBlock
712-
<writing-an-llvm-pass-runOnBasicBlock>` for every ``BasicBlock`` in the program
713-
being compiled. This can be used to perform per-function finalization.
714649

715650
The ``MachineFunctionPass`` class
716651
---------------------------------
@@ -864,8 +799,7 @@ certain circumstances that are related to ``addPreserved``. In particular, the
864799
modify the LLVM program at all (which is true for analyses), and the
865800
``setPreservesCFG`` method can be used by transformations that change
866801
instructions in the program but do not modify the CFG or terminator
867-
instructions (note that this property is implicitly set for
868-
:ref:`BasicBlockPass <writing-an-llvm-pass-BasicBlockPass>`\ es).
802+
instructions.
869803

870804
``addPreserved`` is particularly useful for transformations like
871805
``BreakCriticalEdges``. This pass knows how to update a small set of loop and

llvm/include/llvm/IR/IRPrintingPasses.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
namespace llvm {
2525
class Pass;
26-
class BasicBlockPass;
2726
class Function;
2827
class FunctionPass;
2928
class Module;
@@ -43,11 +42,6 @@ ModulePass *createPrintModulePass(raw_ostream &OS,
4342
FunctionPass *createPrintFunctionPass(raw_ostream &OS,
4443
const std::string &Banner = "");
4544

46-
/// Create and return a pass that writes the BB to the specified
47-
/// \c raw_ostream.
48-
BasicBlockPass *createPrintBasicBlockPass(raw_ostream &OS,
49-
const std::string &Banner = "");
50-
5145
/// Print out a name of an LLVM value without any prefixes.
5246
///
5347
/// The name is surrounded with ""'s and escaped if it has any special or

llvm/include/llvm/IR/LegacyPassManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class PassManager : public PassManagerBase {
6363
PassManagerImpl *PM;
6464
};
6565

66-
/// FunctionPassManager manages FunctionPasses and BasicBlockPassManagers.
66+
/// FunctionPassManager manages FunctionPasses.
6767
class FunctionPassManager : public PassManagerBase {
6868
public:
6969
/// FunctionPassManager ctor - This initializes the pass manager. It needs,

llvm/include/llvm/IR/LegacyPassManagers.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@
5353
// a place to implement common pass manager APIs. All pass managers derive from
5454
// PMDataManager.
5555
//
56-
// [o] class BBPassManager : public FunctionPass, public PMDataManager;
57-
//
58-
// BBPassManager manages BasicBlockPasses.
59-
//
6056
// [o] class FunctionPassManager;
6157
//
6258
// This is a external interface used to manage FunctionPasses. This
@@ -103,7 +99,6 @@ enum PassDebuggingString {
10399
EXECUTION_MSG, // "Executing Pass '" + PassName
104100
MODIFICATION_MSG, // "Made Modification '" + PassName
105101
FREEING_MSG, // " Freeing Pass '" + PassName
106-
ON_BASICBLOCK_MSG, // "' on BasicBlock '" + InstructionName + "'...\n"
107102
ON_FUNCTION_MSG, // "' on Function '" + FunctionName + "'...\n"
108103
ON_MODULE_MSG, // "' on Module '" + ModuleName + "'...\n"
109104
ON_REGION_MSG, // "' on Region '" + Msg + "'...\n'"

llvm/include/llvm/InitializePasses.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ void initializePostRAMachineSinkingPass(PassRegistry&);
334334
void initializePostRASchedulerPass(PassRegistry&);
335335
void initializePreISelIntrinsicLoweringLegacyPassPass(PassRegistry&);
336336
void initializePredicateInfoPrinterLegacyPassPass(PassRegistry&);
337-
void initializePrintBasicBlockPassPass(PassRegistry&);
338337
void initializePrintFunctionPassWrapperPass(PassRegistry&);
339338
void initializePrintModulePassWrapperPass(PassRegistry&);
340339
void initializeProcessImplicitDefsPass(PassRegistry&);

llvm/include/llvm/LinkAllPasses.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ namespace {
200200
llvm::raw_string_ostream os(buf);
201201
(void) llvm::createPrintModulePass(os);
202202
(void) llvm::createPrintFunctionPass(os);
203-
(void) llvm::createPrintBasicBlockPass(os);
204203
(void) llvm::createModuleDebugInfoPrinterPass();
205204
(void) llvm::createPartialInliningPass();
206205
(void) llvm::createLintPass();

llvm/include/llvm/Pass.h

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,11 @@ enum PassManagerType {
5757
PMT_FunctionPassManager, ///< FPPassManager
5858
PMT_LoopPassManager, ///< LPPassManager
5959
PMT_RegionPassManager, ///< RGPassManager
60-
PMT_BasicBlockPassManager, ///< BBPassManager
6160
PMT_Last
6261
};
6362

6463
// Different types of passes.
6564
enum PassKind {
66-
PT_BasicBlock,
6765
PT_Region,
6866
PT_Loop,
6967
PT_Function,
@@ -305,56 +303,6 @@ class FunctionPass : public Pass {
305303
bool skipFunction(const Function &F) const;
306304
};
307305

308-
//===----------------------------------------------------------------------===//
309-
/// Deprecated - do not create new passes as BasicBlockPasses. Use FunctionPass
310-
/// with a loop over the BasicBlocks instead.
311-
//
312-
/// BasicBlockPass class - This class is used to implement most local
313-
/// optimizations. Optimizations should subclass this class if they
314-
/// meet the following constraints:
315-
/// 1. Optimizations are local, operating on either a basic block or
316-
/// instruction at a time.
317-
/// 2. Optimizations do not modify the CFG of the contained function, or any
318-
/// other basic block in the function.
319-
/// 3. Optimizations conform to all of the constraints of FunctionPasses.
320-
///
321-
class BasicBlockPass : public Pass {
322-
public:
323-
explicit BasicBlockPass(char &pid) : Pass(PT_BasicBlock, pid) {}
324-
325-
/// createPrinterPass - Get a basic block printer pass.
326-
Pass *createPrinterPass(raw_ostream &OS,
327-
const std::string &Banner) const override;
328-
329-
using llvm::Pass::doInitialization;
330-
using llvm::Pass::doFinalization;
331-
332-
/// doInitialization - Virtual method overridden by BasicBlockPass subclasses
333-
/// to do any necessary per-function initialization.
334-
virtual bool doInitialization(Function &);
335-
336-
/// runOnBasicBlock - Virtual method overriden by subclasses to do the
337-
/// per-basicblock processing of the pass.
338-
virtual bool runOnBasicBlock(BasicBlock &BB) = 0;
339-
340-
/// doFinalization - Virtual method overriden by BasicBlockPass subclasses to
341-
/// do any post processing needed after all passes have run.
342-
virtual bool doFinalization(Function &);
343-
344-
void preparePassManager(PMStack &PMS) override;
345-
346-
void assignPassManager(PMStack &PMS, PassManagerType T) override;
347-
348-
/// Return what kind of Pass Manager can manage this pass.
349-
PassManagerType getPotentialPassManagerType() const override;
350-
351-
protected:
352-
/// Optional passes call this function to check whether the pass should be
353-
/// skipped. This is the case when Attribute::OptimizeNone is set or when
354-
/// optimization bisect is over the limit.
355-
bool skipBasicBlock(const BasicBlock &BB) const;
356-
};
357-
358306
/// If the user specifies the -time-passes argument on an LLVM tool command line
359307
/// then the value of this boolean will be true, otherwise false.
360308
/// This is the storage for the -time-passes option.

llvm/include/llvm/Transforms/Scalar.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
namespace llvm {
2020

21-
class BasicBlockPass;
2221
class Function;
2322
class FunctionPass;
2423
class ModulePass;
@@ -50,8 +49,7 @@ FunctionPass *createSCCPPass();
5049
//===----------------------------------------------------------------------===//
5150
//
5251
// DeadInstElimination - This pass quickly removes trivially dead instructions
53-
// without modifying the CFG of the function. It is a BasicBlockPass, so it
54-
// runs efficiently when queued next to other BasicBlockPass's.
52+
// without modifying the CFG of the function. It is a FunctionPass.
5553
//
5654
Pass *createDeadInstEliminationPass();
5755

llvm/include/llvm/Transforms/Vectorize.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
namespace llvm {
1818
class BasicBlock;
19-
class BasicBlockPass;
2019
class Pass;
2120

2221
//===----------------------------------------------------------------------===//

llvm/lib/IR/Core.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ void llvm::initializeCore(PassRegistry &Registry) {
4747
initializeDominatorTreeWrapperPassPass(Registry);
4848
initializePrintModulePassWrapperPass(Registry);
4949
initializePrintFunctionPassWrapperPass(Registry);
50-
initializePrintBasicBlockPassPass(Registry);
5150
initializeSafepointIRVerifierPass(Registry);
5251
initializeVerifierLegacyPassPass(Registry);
5352
}

llvm/lib/IR/IRPrintingPasses.cpp

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -109,28 +109,6 @@ class PrintFunctionPassWrapper : public FunctionPass {
109109
StringRef getPassName() const override { return "Print Function IR"; }
110110
};
111111

112-
class PrintBasicBlockPass : public BasicBlockPass {
113-
raw_ostream &Out;
114-
std::string Banner;
115-
116-
public:
117-
static char ID;
118-
PrintBasicBlockPass() : BasicBlockPass(ID), Out(dbgs()) {}
119-
PrintBasicBlockPass(raw_ostream &Out, const std::string &Banner)
120-
: BasicBlockPass(ID), Out(Out), Banner(Banner) {}
121-
122-
bool runOnBasicBlock(BasicBlock &BB) override {
123-
Out << Banner << BB;
124-
return false;
125-
}
126-
127-
void getAnalysisUsage(AnalysisUsage &AU) const override {
128-
AU.setPreservesAll();
129-
}
130-
131-
StringRef getPassName() const override { return "Print BasicBlock IR"; }
132-
};
133-
134112
}
135113

136114
char PrintModulePassWrapper::ID = 0;
@@ -139,9 +117,6 @@ INITIALIZE_PASS(PrintModulePassWrapper, "print-module",
139117
char PrintFunctionPassWrapper::ID = 0;
140118
INITIALIZE_PASS(PrintFunctionPassWrapper, "print-function",
141119
"Print function to stderr", false, true)
142-
char PrintBasicBlockPass::ID = 0;
143-
INITIALIZE_PASS(PrintBasicBlockPass, "print-bb", "Print BB to stderr", false,
144-
true)
145120

146121
ModulePass *llvm::createPrintModulePass(llvm::raw_ostream &OS,
147122
const std::string &Banner,
@@ -154,15 +129,9 @@ FunctionPass *llvm::createPrintFunctionPass(llvm::raw_ostream &OS,
154129
return new PrintFunctionPassWrapper(OS, Banner);
155130
}
156131

157-
BasicBlockPass *llvm::createPrintBasicBlockPass(llvm::raw_ostream &OS,
158-
const std::string &Banner) {
159-
return new PrintBasicBlockPass(OS, Banner);
160-
}
161-
162132
bool llvm::isIRPrintingPass(Pass *P) {
163133
const char *PID = (const char*)P->getPassID();
164134

165-
return (PID == &PrintModulePassWrapper::ID)
166-
|| (PID == &PrintFunctionPassWrapper::ID)
167-
|| (PID == &PrintBasicBlockPass::ID);
135+
return (PID == &PrintModulePassWrapper::ID) ||
136+
(PID == &PrintFunctionPassWrapper::ID);
168137
}

0 commit comments

Comments
 (0)