LLVM  13.0.0git
SimplifyCFGPass.cpp
Go to the documentation of this file.
1 //===- SimplifyCFGPass.cpp - CFG Simplification Pass ----------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements dead code elimination and basic block merging, along
10 // with a collection of other peephole control flow optimizations. For example:
11 //
12 // * Removes basic blocks with no predecessors.
13 // * Merges a basic block into its predecessor if there is only one and the
14 // predecessor only has one successor.
15 // * Eliminates PHI nodes for basic blocks with a single predecessor.
16 // * Eliminates a basic block that only contains an unconditional branch.
17 // * Changes invoke instructions to nounwind functions to be calls.
18 // * Change things like "if (x) if (y)" into "if (x&y)".
19 // * etc..
20 //
21 //===----------------------------------------------------------------------===//
22 
23 #include "llvm/ADT/SmallPtrSet.h"
24 #include "llvm/ADT/SmallVector.h"
25 #include "llvm/ADT/Statistic.h"
27 #include "llvm/Analysis/CFG.h"
31 #include "llvm/IR/Attributes.h"
32 #include "llvm/IR/CFG.h"
33 #include "llvm/IR/Constants.h"
34 #include "llvm/IR/DataLayout.h"
35 #include "llvm/IR/Dominators.h"
36 #include "llvm/IR/Instructions.h"
37 #include "llvm/IR/IntrinsicInst.h"
38 #include "llvm/IR/Module.h"
39 #include "llvm/IR/ValueHandle.h"
40 #include "llvm/InitializePasses.h"
41 #include "llvm/Pass.h"
43 #include "llvm/Transforms/Scalar.h"
47 #include <utility>
48 using namespace llvm;
49 
50 #define DEBUG_TYPE "simplifycfg"
51 
53  "bonus-inst-threshold", cl::Hidden, cl::init(1),
54  cl::desc("Control the number of bonus instructions (default = 1)"));
55 
57  "keep-loops", cl::Hidden, cl::init(true),
58  cl::desc("Preserve canonical loop structure (default = true)"));
59 
61  "switch-to-lookup", cl::Hidden, cl::init(false),
62  cl::desc("Convert switches to lookup tables (default = false)"));
63 
65  "forward-switch-cond", cl::Hidden, cl::init(false),
66  cl::desc("Forward switch condition to phi ops (default = false)"));
67 
69  "hoist-common-insts", cl::Hidden, cl::init(false),
70  cl::desc("hoist common instructions (default = false)"));
71 
73  "sink-common-insts", cl::Hidden, cl::init(false),
74  cl::desc("Sink common instructions (default = false)"));
75 
76 
77 STATISTIC(NumSimpl, "Number of blocks simplified");
78 
79 /// If we have more than one empty (other than phi node) return blocks,
80 /// merge them together to promote recursive block merging.
82  bool Changed = false;
83 
84  std::vector<DominatorTree::UpdateType> Updates;
86 
87  BasicBlock *RetBlock = nullptr;
88 
89  // Scan all the blocks in the function, looking for empty return blocks.
91  if (DTU && DTU->isBBPendingDeletion(&BB))
92  continue;
93 
94  // Only look at return blocks.
95  ReturnInst *Ret = dyn_cast<ReturnInst>(BB.getTerminator());
96  if (!Ret) continue;
97 
98  // Only look at the block if it is empty or the only other thing in it is a
99  // single PHI node that is the operand to the return.
100  if (Ret != &BB.front()) {
101  // Check for something else in the block.
103  --I;
104  // Skip over debug info.
105  while (isa<DbgInfoIntrinsic>(I) && I != BB.begin())
106  --I;
107  if (!isa<DbgInfoIntrinsic>(I) &&
108  (!isa<PHINode>(I) || I != BB.begin() || Ret->getNumOperands() == 0 ||
109  Ret->getOperand(0) != &*I))
110  continue;
111  }
112 
113  // If this is the first returning block, remember it and keep going.
114  if (!RetBlock) {
115  RetBlock = &BB;
116  continue;
117  }
118 
119  // Skip merging if this would result in a CallBr instruction with a
120  // duplicate destination. FIXME: See note in CodeGenPrepare.cpp.
121  bool SkipCallBr = false;
122  for (pred_iterator PI = pred_begin(&BB), E = pred_end(&BB);
123  PI != E && !SkipCallBr; ++PI) {
124  if (auto *CBI = dyn_cast<CallBrInst>((*PI)->getTerminator()))
125  for (unsigned i = 0, e = CBI->getNumSuccessors(); i != e; ++i)
126  if (RetBlock == CBI->getSuccessor(i)) {
127  SkipCallBr = true;
128  break;
129  }
130  }
131  if (SkipCallBr)
132  continue;
133 
134  // Otherwise, we found a duplicate return block. Merge the two.
135  Changed = true;
136 
137  // Case when there is no input to the return or when the returned values
138  // agree is trivial. Note that they can't agree if there are phis in the
139  // blocks.
140  if (Ret->getNumOperands() == 0 ||
141  Ret->getOperand(0) ==
142  cast<ReturnInst>(RetBlock->getTerminator())->getOperand(0)) {
143  // All predecessors of BB should now branch to RetBlock instead.
144  if (DTU) {
146  SmallPtrSet<BasicBlock *, 2> PredsOfRetBlock(pred_begin(RetBlock),
147  pred_end(RetBlock));
148  Updates.reserve(Updates.size() + 2 * PredsOfBB.size());
149  for (auto *Predecessor : PredsOfBB)
150  // But, iff Predecessor already branches to RetBlock,
151  // don't (re-)add DomTree edge, because it already exists.
152  if (!PredsOfRetBlock.contains(Predecessor))
153  Updates.push_back({DominatorTree::Insert, Predecessor, RetBlock});
154  for (auto *Predecessor : PredsOfBB)
155  Updates.push_back({DominatorTree::Delete, Predecessor, &BB});
156  }
157  BB.replaceAllUsesWith(RetBlock);
158  DeadBlocks.emplace_back(&BB);
159  continue;
160  }
161 
162  // If the canonical return block has no PHI node, create one now.
163  PHINode *RetBlockPHI = dyn_cast<PHINode>(RetBlock->begin());
164  if (!RetBlockPHI) {
165  Value *InVal = cast<ReturnInst>(RetBlock->getTerminator())->getOperand(0);
166  pred_iterator PB = pred_begin(RetBlock), PE = pred_end(RetBlock);
167  RetBlockPHI = PHINode::Create(Ret->getOperand(0)->getType(),
168  std::distance(PB, PE), "merge",
169  &RetBlock->front());
170 
171  for (pred_iterator PI = PB; PI != PE; ++PI)
172  RetBlockPHI->addIncoming(InVal, *PI);
173  RetBlock->getTerminator()->setOperand(0, RetBlockPHI);
174  }
175 
176  // Turn BB into a block that just unconditionally branches to the return
177  // block. This handles the case when the two return blocks have a common
178  // predecessor but that return different things.
179  RetBlockPHI->addIncoming(Ret->getOperand(0), &BB);
180  BB.getTerminator()->eraseFromParent();
181  BranchInst::Create(RetBlock, &BB);
182  if (DTU)
183  Updates.push_back({DominatorTree::Insert, &BB, RetBlock});
184  }
185 
186  if (DTU) {
187  DTU->applyUpdates(Updates);
188  for (auto *BB : DeadBlocks)
189  DTU->deleteBB(BB);
190  } else {
191  for (auto *BB : DeadBlocks)
192  BB->eraseFromParent();
193  }
194 
195  return Changed;
196 }
197 
198 /// Call SimplifyCFG on all the blocks in the function,
199 /// iterating until no more changes are made.
201  DomTreeUpdater *DTU,
202  const SimplifyCFGOptions &Options) {
203  bool Changed = false;
204  bool LocalChange = true;
205 
207  FindFunctionBackedges(F, Edges);
208  SmallPtrSet<BasicBlock *, 16> UniqueLoopHeaders;
209  for (unsigned i = 0, e = Edges.size(); i != e; ++i)
210  UniqueLoopHeaders.insert(const_cast<BasicBlock *>(Edges[i].second));
211 
212  SmallVector<WeakVH, 16> LoopHeaders(UniqueLoopHeaders.begin(),
213  UniqueLoopHeaders.end());
214 
215  while (LocalChange) {
216  LocalChange = false;
217 
218  // Loop over all of the basic blocks and remove them if they are unneeded.
219  for (Function::iterator BBIt = F.begin(); BBIt != F.end(); ) {
220  BasicBlock &BB = *BBIt++;
221  if (DTU) {
222  assert(
223  !DTU->isBBPendingDeletion(&BB) &&
224  "Should not end up trying to simplify blocks marked for removal.");
225  // Make sure that the advanced iterator does not point at the blocks
226  // that are marked for removal, skip over all such blocks.
227  while (BBIt != F.end() && DTU->isBBPendingDeletion(&*BBIt))
228  ++BBIt;
229  }
230  if (simplifyCFG(&BB, TTI, DTU, Options, LoopHeaders)) {
231  LocalChange = true;
232  ++NumSimpl;
233  }
234  }
235  Changed |= LocalChange;
236  }
237  return Changed;
238 }
239 
241  DominatorTree *DT,
242  const SimplifyCFGOptions &Options) {
244 
245  bool EverChanged = removeUnreachableBlocks(F, DT ? &DTU : nullptr);
246  EverChanged |= mergeEmptyReturnBlocks(F, DT ? &DTU : nullptr);
247  EverChanged |= iterativelySimplifyCFG(F, TTI, DT ? &DTU : nullptr, Options);
248 
249  // If neither pass changed anything, we're done.
250  if (!EverChanged) return false;
251 
252  // iterativelySimplifyCFG can (rarely) make some loops dead. If this happens,
253  // removeUnreachableBlocks is needed to nuke them, which means we should
254  // iterate between the two optimizations. We structure the code like this to
255  // avoid rerunning iterativelySimplifyCFG if the second pass of
256  // removeUnreachableBlocks doesn't do anything.
257  if (!removeUnreachableBlocks(F, DT ? &DTU : nullptr))
258  return true;
259 
260  do {
261  EverChanged = iterativelySimplifyCFG(F, TTI, DT ? &DTU : nullptr, Options);
262  EverChanged |= removeUnreachableBlocks(F, DT ? &DTU : nullptr);
263  } while (EverChanged);
264 
265  return true;
266 }
267 
269  DominatorTree *DT,
270  const SimplifyCFGOptions &Options) {
273  "Original domtree is invalid?");
274 
275  bool Changed = simplifyFunctionCFGImpl(F, TTI, DT, Options);
276 
279  "Failed to maintain validity of domtree!");
280 
281  return Changed;
282 }
283 
284 // Command-line settings override compile-time settings.
286  if (UserBonusInstThreshold.getNumOccurrences())
298 }
299 
302 }
303 
305  : Options(Opts) {
307 }
308 
311  auto &TTI = AM.getResult<TargetIRAnalysis>(F);
312  Options.AC = &AM.getResult<AssumptionAnalysis>(F);
313  DominatorTree *DT = nullptr;
315  DT = &AM.getResult<DominatorTreeAnalysis>(F);
316  if (F.hasFnAttribute(Attribute::OptForFuzzing)) {
317  Options.setSimplifyCondBranch(false).setFoldTwoEntryPHINode(false);
318  } else {
319  Options.setSimplifyCondBranch(true).setFoldTwoEntryPHINode(true);
320  }
321  if (!simplifyFunctionCFG(F, TTI, DT, Options))
322  return PreservedAnalyses::all();
326  PA.preserve<GlobalsAA>();
327  return PA;
328 }
329 
330 namespace {
331 struct CFGSimplifyPass : public FunctionPass {
332  static char ID;
333  SimplifyCFGOptions Options;
334  std::function<bool(const Function &)> PredicateFtor;
335 
336  CFGSimplifyPass(SimplifyCFGOptions Options_ = SimplifyCFGOptions(),
337  std::function<bool(const Function &)> Ftor = nullptr)
338  : FunctionPass(ID), Options(Options_), PredicateFtor(std::move(Ftor)) {
339 
341 
342  // Check for command-line overrides of options for debug/customization.
344  }
345 
346  bool runOnFunction(Function &F) override {
347  if (skipFunction(F) || (PredicateFtor && !PredicateFtor(F)))
348  return false;
349 
350  Options.AC = &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
351  DominatorTree *DT = nullptr;
353  DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
354  if (F.hasFnAttribute(Attribute::OptForFuzzing)) {
355  Options.setSimplifyCondBranch(false)
356  .setFoldTwoEntryPHINode(false);
357  } else {
358  Options.setSimplifyCondBranch(true)
359  .setFoldTwoEntryPHINode(true);
360  }
361 
362  auto &TTI = getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
363  return simplifyFunctionCFG(F, TTI, DT, Options);
364  }
365  void getAnalysisUsage(AnalysisUsage &AU) const override {
373  }
374 };
375 }
376 
377 char CFGSimplifyPass::ID = 0;
378 INITIALIZE_PASS_BEGIN(CFGSimplifyPass, "simplifycfg", "Simplify the CFG", false,
379  false)
383 INITIALIZE_PASS_END(CFGSimplifyPass, "simplifycfg", "Simplify the CFG", false,
384  false)
385 
386 // Public interface to the CFGSimplification pass
387 FunctionPass *
389  std::function<bool(const Function &)> Ftor) {
390  return new CFGSimplifyPass(Options, std::move(Ftor));
391 }
i
i
Definition: README.txt:29
llvm::GlobalsAA
Analysis pass providing a never-invalidated alias analysis result.
Definition: GlobalsModRef.h:132
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:155
UserHoistCommonInsts
static cl::opt< bool > UserHoistCommonInsts("hoist-common-insts", cl::Hidden, cl::init(false), cl::desc("hoist common instructions (default = false)"))
AssumptionCache.h
llvm::TargetIRAnalysis
Analysis pass providing the TargetTransformInfo.
Definition: TargetTransformInfo.h:2265
llvm
Definition: AllocatorList.h:23
llvm::DomTreeUpdater::deleteBB
void deleteBB(BasicBlock *DelBB)
Delete DelBB.
Definition: DomTreeUpdater.cpp:177
llvm::ReturnInst
Return a value (possibly void), from a function.
Definition: Instructions.h:2923
iterativelySimplifyCFG
static bool iterativelySimplifyCFG(Function &F, const TargetTransformInfo &TTI, DomTreeUpdater *DTU, const SimplifyCFGOptions &Options)
Call SimplifyCFG on all the blocks in the function, iterating until no more changes are made.
Definition: SimplifyCFGPass.cpp:200
llvm::SimplifyCFGPass::SimplifyCFGPass
SimplifyCFGPass()
The default constructor sets the pass options to create canonical IR, rather than optimal IR.
Definition: SimplifyCFGPass.cpp:300
llvm::BasicBlock::iterator
InstListType::iterator iterator
Instruction iterators...
Definition: BasicBlock.h:90
llvm::FindFunctionBackedges
void FindFunctionBackedges(const Function &F, SmallVectorImpl< std::pair< const BasicBlock *, const BasicBlock * > > &Result)
Analyze the specified function to find all of the loop backedges in the function and return them.
Definition: CFG.cpp:34
IntrinsicInst.h
llvm::AnalysisManager::getResult
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:785
Scalar.h
llvm::DomTreeUpdater::applyUpdates
void applyUpdates(ArrayRef< DominatorTree::UpdateType > Updates)
Submit updates to all available trees.
Definition: DomTreeUpdater.cpp:230
llvm::SimplifyCFGOptions::setFoldTwoEntryPHINode
SimplifyCFGOptions & setFoldTwoEntryPHINode(bool B)
Definition: SimplifyCFGOptions.h:69
llvm::Function
Definition: Function.h:61
Pass.h
CFG
Simplify the CFG
Definition: SimplifyCFGPass.cpp:383
llvm::createCFGSimplificationPass
FunctionPass * createCFGSimplificationPass(SimplifyCFGOptions Options=SimplifyCFGOptions(), std::function< bool(const Function &)> Ftor=nullptr)
Definition: SimplifyCFGPass.cpp:388
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
Statistic.h
llvm::SimplifyCFGOptions::BonusInstThreshold
int BonusInstThreshold
Definition: SimplifyCFGOptions.h:24
llvm::TargetTransformInfo
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
Definition: TargetTransformInfo.h:168
DomTreeUpdater.h
Local.h
llvm::DominatorTree
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:151
GlobalsModRef.h
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:140
llvm::removeUnreachableBlocks
bool removeUnreachableBlocks(Function &F, DomTreeUpdater *DTU=nullptr, MemorySSAUpdater *MSSAU=nullptr)
Remove all blocks that can not be reached from the function's entry.
Definition: Local.cpp:2478
Module.h
llvm::SimplifyCFGOptions::ConvertSwitchToLookupTable
bool ConvertSwitchToLookupTable
Definition: SimplifyCFGOptions.h:26
llvm::DominatorTreeBase< BasicBlock, false >::Insert
static constexpr UpdateKind Insert
Definition: GenericDomTree.h:242
llvm::SmallPtrSet
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:449
llvm::MipsISD::Ret
@ Ret
Definition: MipsISelLowering.h:116
llvm::JumpTable::Full
@ Full
Definition: TargetOptions.h:50
llvm::SimplifyCFGOptions::HoistCommonInsts
bool HoistCommonInsts
Definition: SimplifyCFGOptions.h:28
INITIALIZE_PASS_END
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
Definition: RegBankSelect.cpp:69
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
CommandLine.h
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition: PassRegistry.cpp:31
Constants.h
llvm::DomTreeUpdater::isBBPendingDeletion
bool isBBPendingDeletion(BasicBlock *DelBB) const
Returns true if DelBB is awaiting deletion.
Definition: DomTreeUpdater.cpp:166
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::SimplifyCFGOptions::setSimplifyCondBranch
SimplifyCFGOptions & setSimplifyCondBranch(bool B)
Definition: SimplifyCFGOptions.h:64
llvm::BasicBlock::begin
iterator begin()
Instruction iterator methods.
Definition: BasicBlock.h:296
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
UserForwardSwitchCond
static cl::opt< bool > UserForwardSwitchCond("forward-switch-cond", cl::Hidden, cl::init(false), cl::desc("Forward switch condition to phi ops (default = false)"))
llvm::SimplifyCFGOptions::AC
AssumptionCache * AC
Definition: SimplifyCFGOptions.h:33
false
Definition: StackSlotColoring.cpp:142
simplifyFunctionCFGImpl
static bool simplifyFunctionCFGImpl(Function &F, const TargetTransformInfo &TTI, DominatorTree *DT, const SimplifyCFGOptions &Options)
Definition: SimplifyCFGPass.cpp:240
llvm::DominatorTreeWrapperPass
Legacy analysis pass which computes a DominatorTree.
Definition: Dominators.h:281
llvm::STATISTIC
STATISTIC(NumFunctions, "Total number of functions")
llvm::cl::Option::getNumOccurrences
int getNumOccurrences() const
Definition: CommandLine.h:401
llvm::DomTreeUpdater
Definition: DomTreeUpdater.h:28
SmallPtrSet.h
CFG.h
INITIALIZE_PASS_BEGIN
INITIALIZE_PASS_BEGIN(CFGSimplifyPass, "simplifycfg", "Simplify the CFG", false, false) INITIALIZE_PASS_END(CFGSimplifyPass
mergeEmptyReturnBlocks
static bool mergeEmptyReturnBlocks(Function &F, DomTreeUpdater *DTU)
If we have more than one empty (other than phi node) return blocks, merge them together to promote re...
Definition: SimplifyCFGPass.cpp:81
llvm::cl::opt
Definition: CommandLine.h:1419
llvm::TargetTransformInfoWrapperPass
Wrapper pass for TargetTransformInfo.
Definition: TargetTransformInfo.h:2321
const
aarch64 promote const
Definition: AArch64PromoteConstant.cpp:232
llvm::SmallPtrSetImpl::end
iterator end() const
Definition: SmallPtrSet.h:407
llvm::AssumptionAnalysis
A function analysis which provides an AssumptionCache.
Definition: AssumptionCache.h:169
INITIALIZE_PASS_DEPENDENCY
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
llvm::PreservedAnalyses::preserve
void preserve()
Mark an analysis as preserved.
Definition: PassManager.h:176
llvm::PHINode::addIncoming
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
Definition: Instructions.h:2720
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:58
llvm::BranchInst::Create
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
Definition: Instructions.h:3061
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:440
llvm::make_early_inc_range
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
Definition: STLExtras.h:581
llvm::SmallPtrSetImpl::begin
iterator begin() const
Definition: SmallPtrSet.h:402
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::SimplifyCFGOptions::NeedCanonicalLoop
bool NeedCanonicalLoop
Definition: SimplifyCFGOptions.h:27
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1563
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:83
UserBonusInstThreshold
static cl::opt< unsigned > UserBonusInstThreshold("bonus-inst-threshold", cl::Hidden, cl::init(1), cl::desc("Control the number of bonus instructions (default = 1)"))
llvm::initializeCFGSimplifyPassPass
void initializeCFGSimplifyPassPass(PassRegistry &)
llvm::simplifyCFG
bool simplifyCFG(BasicBlock *BB, const TargetTransformInfo &TTI, DomTreeUpdater *DTU=nullptr, const SimplifyCFGOptions &Options={}, ArrayRef< WeakVH > LoopHeaders={})
Definition: SimplifyCFG.cpp:6712
llvm::User::setOperand
void setOperand(unsigned i, Value *Val)
Definition: User.h:174
CFG.h
llvm::AssumptionCacheTracker
An immutable pass that tracks lazily created AssumptionCache objects.
Definition: AssumptionCache.h:200
DataLayout.h
Simplify
assume Assume Simplify
Definition: AssumeBundleBuilder.cpp:602
llvm::AnalysisUsage::addPreserved
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
Definition: PassAnalysisSupport.h:98
llvm::DomTreeUpdater::UpdateStrategy::Eager
@ Eager
llvm::PredIterator
Definition: CFG.h:43
llvm::SimplifyCFGOptions::ForwardSwitchCondToPhi
bool ForwardSwitchCondToPhi
Definition: SimplifyCFGOptions.h:25
llvm::RequireAndPreserveDomTree
cl::opt< bool > RequireAndPreserveDomTree
This function is used to do simplification of a CFG.
ValueHandle.h
applyCommandLineOverridesToOptions
static void applyCommandLineOverridesToOptions(SimplifyCFGOptions &Options)
Definition: SimplifyCFGPass.cpp:285
llvm::BasicBlock::getTerminator
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Definition: BasicBlock.cpp:148
UserKeepLoops
static cl::opt< bool > UserKeepLoops("keep-loops", cl::Hidden, cl::init(true), cl::desc("Preserve canonical loop structure (default = true)"))
llvm::SmallPtrSetImplBase::size
size_type size() const
Definition: SmallPtrSet.h:92
llvm::BasicBlock::front
const Instruction & front() const
Definition: BasicBlock.h:308
UserSwitchToLookup
static cl::opt< bool > UserSwitchToLookup("switch-to-lookup", cl::Hidden, cl::init(false), cl::desc("Convert switches to lookup tables (default = false)"))
Attributes.h
runOnFunction
static bool runOnFunction(Function &F, bool PostInlining)
Definition: EntryExitInstrumenter.cpp:69
std
Definition: BitVector.h:837
llvm::PreservedAnalyses::all
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:161
llvm::PHINode::Create
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
Definition: Instructions.h:2612
llvm::pred_end
Interval::pred_iterator pred_end(Interval *I)
Definition: Interval.h:112
SimplifyCFGOptions.h
llvm::pred_begin
Interval::pred_iterator pred_begin(Interval *I)
pred_begin/pred_end - define methods so that Intervals may be used just like BasicBlocks can with the...
Definition: Interval.h:109
llvm::DominatorTreeAnalysis
Analysis pass which computes a DominatorTree.
Definition: Dominators.h:252
llvm::SimplifyCFGOptions
Definition: SimplifyCFGOptions.h:23
Instructions.h
SmallVector.h
Dominators.h
simplifyFunctionCFG
static bool simplifyFunctionCFG(Function &F, const TargetTransformInfo &TTI, DominatorTree *DT, const SimplifyCFGOptions &Options)
Definition: SimplifyCFGPass.cpp:268
llvm::GlobalsAAWrapperPass
Legacy wrapper pass to provide the GlobalsAAResult object.
Definition: GlobalsModRef.h:143
llvm::DominatorTreeBase::verify
bool verify(VerificationLevel VL=VerificationLevel::Full) const
verify - checks if the tree is correct.
Definition: GenericDomTree.h:802
TargetTransformInfo.h
llvm::PHINode
Definition: Instructions.h:2572
llvm::SimplifyCFGOptions::SinkCommonInsts
bool SinkCommonInsts
Definition: SimplifyCFGOptions.h:29
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:43
llvm::SimplifyCFGPass::run
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Run the pass over the function.
Definition: SimplifyCFGPass.cpp:309
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:298
BB
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
Definition: README.txt:39
llvm::AnalysisUsage::addRequired
AnalysisUsage & addRequired()
Definition: PassAnalysisSupport.h:75
llvm::cl::desc
Definition: CommandLine.h:411
llvm::SmallPtrSetImpl::contains
bool contains(ConstPtrType Ptr) const
Definition: SmallPtrSet.h:388
SimplifyCFG.h
UserSinkCommonInsts
static cl::opt< bool > UserSinkCommonInsts("sink-common-insts", cl::Hidden, cl::init(false), cl::desc("Sink common instructions (default = false)"))
simplifycfg
simplifycfg
Definition: SimplifyCFGPass.cpp:383
InitializePasses.h
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::DominatorTreeBase< BasicBlock, false >::Delete
static constexpr UpdateKind Delete
Definition: GenericDomTree.h:243
llvm::SmallVectorImpl::emplace_back
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:908
llvm::Function::iterator
BasicBlockListType::iterator iterator
Definition: Function.h:66
llvm::SmallPtrSetImpl::insert
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition: SmallPtrSet.h:364
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38