26#define DEBUG_TYPE "gc-empty-basic-blocks"
28STATISTIC(NumEmptyBlocksRemoved,
"Number of empty blocks removed");
50 return "Remove Empty Basic Blocks.";
69 MBB != LastMBB;
MBB = NextMBB) {
70 NextMBB = std::next(
MBB);
74 if (
MBB->isEHPad() ||
MBB->hasAddressTaken())
78 return !
MI.isPosition() && !
MI.isImplicitDef() && !
MI.isKill() &&
85 <<
" in function " << MF.
getName() <<
":\n"
89 for (
auto &Pred : Preds)
90 Pred->ReplaceUsesOfBlockWith(&*
MBB, &*NextMBB);
95 while (!
MBB->succ_empty())
96 MBB->removeSuccessor(
MBB->succ_end() - 1);
98 MBB->eraseFromParent();
101 NumEmptyBlocksRemoved += NumRemoved;
102 return NumRemoved != 0;
107 "Removes empty basic blocks and redirects their uses to their "
108 "fallthrough blocks.",
static bool removeEmptyBlocks(MachineFunction &MF)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
GCEmptyBasicBlocksLegacy()
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
MachineFunctionPass(char &ID)
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
const MachineBasicBlock & back() const
BasicBlockListType::iterator iterator
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
Representation of each machine instruction.
LLVM_ABI bool ReplaceMBBInJumpTables(MachineBasicBlock *Old, MachineBasicBlock *New)
ReplaceMBBInJumpTables - If Old is the target of any jump tables, update the jump tables to branch to...
static LLVM_ABI PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
This is an optimization pass for GlobalISel generic memory operations.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI void initializeGCEmptyBasicBlocksLegacyPass(PassRegistry &)
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI MachineFunctionPass * createGCEmptyBasicBlocksLegacyPass()
createGCEmptyBasicblocksPass - Empty basic blocks (basic blocks without real code) appear as the resu...