LLVM: lib/CodeGen/GCEmptyBasicBlocks.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
22
23using namespace llvm;
24
25#define DEBUG_TYPE "gc-empty-basic-blocks"
26
27STATISTIC(NumEmptyBlocksRemoved, "Number of empty blocks removed");
28
30public:
32
35 }
36
38 return "Remove Empty Basic Blocks.";
39 }
40
42};
43
45 if (MF.size() < 2)
46 return false;
48 int NumRemoved = 0;
49
50
51
54 NextMBB;
55 MBB != LastMBB; MBB = NextMBB) {
56 NextMBB = std::next(MBB);
57
58
59
61 continue;
62
64 return .isPosition() &&
.isImplicitDef() &&
.isKill() &&
65 .isDebugInstr();
66 });
67 if (HasAnyRealCode)
68 continue;
69
71 << " in function " << MF.getName() << ":\n"
72 << *MBB << "\n");
74
75 for (auto &Pred : Preds)
76 Pred->ReplaceUsesOfBlockWith(&*MBB, &*NextMBB);
77
78 if (JTI)
80
83
85 ++NumRemoved;
86 }
87 NumEmptyBlocksRemoved += NumRemoved;
88 return NumRemoved != 0;
89}
90
93 "Removes empty basic blocks and redirects their uses to their "
94 "fallthrough blocks.",
95 false, false)
96
99}
#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)
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
bool isEHPad() const
Returns true if the block is a landing pad.
bool hasAddressTaken() const
Test whether this block is used as something other than the target of a terminator,...
void removeSuccessor(MachineBasicBlock *Succ, bool NormalizeSuccProbs=false)
Remove successor from the successors list of this MachineBasicBlock.
void eraseFromParent()
This method unlinks 'this' from the containing function and deletes it.
iterator_range< pred_iterator > predecessors()
StringRef getName() const
Return the name of the corresponding LLVM basic block, or an empty string.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
const MachineBasicBlock & back() const
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
Representation of each machine instruction.
bool ReplaceMBBInJumpTables(MachineBasicBlock *Old, MachineBasicBlock *New)
ReplaceMBBInJumpTables - If Old is the target of any jump tables, update the jump tables to branch to...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
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.
MachineFunctionPass * createGCEmptyBasicBlocksPass()
createGCEmptyBasicblocksPass - Empty basic blocks (basic blocks without real code) appear as the resu...
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void initializeGCEmptyBasicBlocksPass(PassRegistry &)