LLVM 22.0.0git
BreakCriticalEdges.cpp
Go to the documentation of this file.
1//===- BreakCriticalEdges.cpp - Critical Edge Elimination 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// BreakCriticalEdges pass - Break all of the critical edges in the CFG by
10// inserting a dummy basic block. This pass may be "required" by passes that
11// cannot deal with critical edges. For this usage, the structure type is
12// forward declared. This pass obviously invalidates the CFG, but can update
13// dominator trees.
14//
15//===----------------------------------------------------------------------===//
16
18#include "llvm/ADT/SetVector.h"
20#include "llvm/ADT/Statistic.h"
23#include "llvm/Analysis/CFG.h"
27#include "llvm/IR/CFG.h"
28#include "llvm/IR/Dominators.h"
35using namespace llvm;
36
37#define DEBUG_TYPE "break-crit-edges"
38
39STATISTIC(NumBroken, "Number of blocks inserted");
40
41namespace {
42struct BreakCriticalEdges : public FunctionPass {
43 static char ID; // Pass identification, replacement for typeid
44 BreakCriticalEdges() : FunctionPass(ID) {
46 }
47
48 bool runOnFunction(Function &F) override {
49 auto *DTWP = getAnalysisIfAvailable<DominatorTreeWrapperPass>();
50 auto *DT = DTWP ? &DTWP->getDomTree() : nullptr;
51
52 auto *PDTWP = getAnalysisIfAvailable<PostDominatorTreeWrapperPass>();
53 auto *PDT = PDTWP ? &PDTWP->getPostDomTree() : nullptr;
54
55 auto *LIWP = getAnalysisIfAvailable<LoopInfoWrapperPass>();
56 auto *LI = LIWP ? &LIWP->getLoopInfo() : nullptr;
57 unsigned N = SplitAllCriticalEdges(
58 F, CriticalEdgeSplittingOptions(DT, LI, nullptr, PDT));
59 NumBroken += N;
60 return N > 0;
61 }
62
63 void getAnalysisUsage(AnalysisUsage &AU) const override {
64 AU.addPreserved<DominatorTreeWrapperPass>();
65 AU.addPreserved<LoopInfoWrapperPass>();
66
67 // No loop canonicalization guarantees are broken by this pass.
69 }
70};
71} // namespace
72
73char BreakCriticalEdges::ID = 0;
74INITIALIZE_PASS(BreakCriticalEdges, "break-crit-edges",
75 "Break critical edges in CFG", false, false)
76
77// Publicly exposed interface to pass...
78char &llvm::BreakCriticalEdgesID = BreakCriticalEdges::ID;
79
81 return new BreakCriticalEdges();
82}
83
97
98//===----------------------------------------------------------------------===//
99// Implementation of the external critical edge manipulation functions
100//===----------------------------------------------------------------------===//
101
104 const Twine &BBName) {
105 if (!isCriticalEdge(TI, SuccNum, Options.MergeIdenticalEdges))
106 return nullptr;
107
108 return SplitKnownCriticalEdge(TI, SuccNum, Options, BBName);
109}
110
114 const Twine &BBName) {
115 BasicBlock *TIBB = TI->getParent();
116 BasicBlock *DestBB = TI->getSuccessor(SuccNum);
117
118 // Splitting the critical edge to a pad block is non-trivial.
119 // And we cannot split block with IndirectBr as a terminator.
120 // Don't do it in this generic function.
121 if (DestBB->isEHPad() || isa<IndirectBrInst>(TI))
122 return nullptr;
123
124 if (Options.IgnoreUnreachableDests &&
126 return nullptr;
127
128 auto *LI = Options.LI;
130 // Check if extra modifications will be required to preserve loop-simplify
131 // form after splitting. If it would require splitting blocks with IndirectBr
132 // terminators, bail out if preserving loop-simplify form is requested.
133 if (LI) {
134 if (Loop *TIL = LI->getLoopFor(TIBB)) {
135
136 // The only way that we can break LoopSimplify form by splitting a
137 // critical edge is if after the split there exists some edge from TIL to
138 // DestBB *and* the only edge into DestBB from outside of TIL is that of
139 // NewBB. If the first isn't true, then LoopSimplify still holds, NewBB
140 // is the new exit block and it has no non-loop predecessors. If the
141 // second isn't true, then DestBB was not in LoopSimplify form prior to
142 // the split as it had a non-loop predecessor. In both of these cases,
143 // the predecessor must be directly in TIL, not in a subloop, or again
144 // LoopSimplify doesn't hold.
145 for (BasicBlock *P : predecessors(DestBB)) {
146 if (P == TIBB)
147 continue; // The new block is known.
148 if (LI->getLoopFor(P) != TIL) {
149 // No need to re-simplify, it wasn't to start with.
150 LoopPreds.clear();
151 break;
152 }
153 LoopPreds.push_back(P);
154 }
155 // Loop-simplify form can be preserved, if we can split all in-loop
156 // predecessors.
157 if (any_of(LoopPreds, [](BasicBlock *Pred) {
158 return isa<IndirectBrInst>(Pred->getTerminator());
159 })) {
160 if (Options.PreserveLoopSimplify)
161 return nullptr;
162 LoopPreds.clear();
163 }
164 }
165 }
166
167 // Create a new basic block, linking it into the CFG.
168 BasicBlock *NewBB = nullptr;
169 if (BBName.str() != "")
170 NewBB = BasicBlock::Create(TI->getContext(), BBName);
171 else
172 NewBB = BasicBlock::Create(TI->getContext(), TIBB->getName() + "." +
173 DestBB->getName() +
174 "_crit_edge");
175 // Create our unconditional branch.
176 BranchInst *NewBI = BranchInst::Create(DestBB, NewBB);
177 NewBI->setDebugLoc(TI->getDebugLoc());
178 if (auto *LoopMD = TI->getMetadata(LLVMContext::MD_loop))
179 NewBI->setMetadata(LLVMContext::MD_loop, LoopMD);
180
181 // Insert the block into the function... right after the block TI lives in.
182 Function &F = *TIBB->getParent();
183 Function::iterator FBBI = TIBB->getIterator();
184 F.insert(++FBBI, NewBB);
185
186 // Branch to the new block, breaking the edge.
187 TI->setSuccessor(SuccNum, NewBB);
188
189 // If there are any PHI nodes in DestBB, we need to update them so that they
190 // merge incoming values from NewBB instead of from TIBB.
191 {
192 unsigned BBIdx = 0;
193 for (BasicBlock::iterator I = DestBB->begin(); isa<PHINode>(I); ++I) {
194 // We no longer enter through TIBB, now we come in through NewBB.
195 // Revector exactly one entry in the PHI node that used to come from
196 // TIBB to come from NewBB.
197 PHINode *PN = cast<PHINode>(I);
198
199 // Reuse the previous value of BBIdx if it lines up. In cases where we
200 // have multiple phi nodes with *lots* of predecessors, this is a speed
201 // win because we don't have to scan the PHI looking for TIBB. This
202 // happens because the BB list of PHI nodes are usually in the same
203 // order.
204 if (PN->getIncomingBlock(BBIdx) != TIBB)
205 BBIdx = PN->getBasicBlockIndex(TIBB);
206 PN->setIncomingBlock(BBIdx, NewBB);
207 }
208 }
209
210 unsigned NumSplitIdenticalEdges = 1;
211
212 // If there are any other edges from TIBB to DestBB, update those to go
213 // through the split block, making those edges non-critical as well (and
214 // reducing the number of phi entries in the DestBB if relevant).
215 if (Options.MergeIdenticalEdges) {
216 for (unsigned i = SuccNum+1, e = TI->getNumSuccessors(); i != e; ++i) {
217 if (TI->getSuccessor(i) != DestBB) continue;
218
219 // Remove an entry for TIBB from DestBB phi nodes.
220 DestBB->removePredecessor(TIBB, Options.KeepOneInputPHIs);
221
222 // We found another edge to DestBB, go to NewBB instead.
223 TI->setSuccessor(i, NewBB);
224
225 // Record the number of split identical edges to DestBB.
226 NumSplitIdenticalEdges++;
227 }
228 }
229
230 // If we have nothing to update, just return.
231 auto *DT = Options.DT;
232 auto *PDT = Options.PDT;
233 auto *MSSAU = Options.MSSAU;
234 if (MSSAU)
235 MSSAU->wireOldPredecessorsToNewImmediatePredecessor(
236 DestBB, NewBB, {TIBB}, Options.MergeIdenticalEdges);
237
238 if (!DT && !PDT && !LI)
239 return NewBB;
240
241 if (DT || PDT) {
242 // Update the DominatorTree.
243 // ---> NewBB -----\
244 // / V
245 // TIBB -------\\------> DestBB
246 //
247 // First, inform the DT about the new path from TIBB to DestBB via NewBB,
248 // then delete the old edge from TIBB to DestBB. By doing this in that order
249 // DestBB stays reachable in the DT the whole time and its subtree doesn't
250 // get disconnected.
252 Updates.push_back({DominatorTree::Insert, TIBB, NewBB});
253 Updates.push_back({DominatorTree::Insert, NewBB, DestBB});
254 if (!llvm::is_contained(successors(TIBB), DestBB))
255 Updates.push_back({DominatorTree::Delete, TIBB, DestBB});
256
257 if (DT)
258 DT->applyUpdates(Updates);
259 if (PDT)
260 PDT->applyUpdates(Updates);
261 }
262
263 // Update LoopInfo if it is around.
264 if (LI) {
265 if (Loop *TIL = LI->getLoopFor(TIBB)) {
266 // If one or the other blocks were not in a loop, the new block is not
267 // either, and thus LI doesn't need to be updated.
268 if (Loop *DestLoop = LI->getLoopFor(DestBB)) {
269 if (TIL == DestLoop) {
270 // Both in the same loop, the NewBB joins loop.
271 DestLoop->addBasicBlockToLoop(NewBB, *LI);
272 } else if (TIL->contains(DestLoop)) {
273 // Edge from an outer loop to an inner loop. Add to the outer loop.
274 TIL->addBasicBlockToLoop(NewBB, *LI);
275 } else if (DestLoop->contains(TIL)) {
276 // Edge from an inner loop to an outer loop. Add to the outer loop.
277 DestLoop->addBasicBlockToLoop(NewBB, *LI);
278 } else {
279 // Edge from two loops with no containment relation. Because these
280 // are natural loops, we know that the destination block must be the
281 // header of its loop (adding a branch into a loop elsewhere would
282 // create an irreducible loop).
283 assert(DestLoop->getHeader() == DestBB &&
284 "Should not create irreducible loops!");
285 if (Loop *P = DestLoop->getParentLoop())
286 P->addBasicBlockToLoop(NewBB, *LI);
287 }
288 }
289
290 // If TIBB is in a loop and DestBB is outside of that loop, we may need
291 // to update LoopSimplify form and LCSSA form.
292 if (!TIL->contains(DestBB)) {
293 assert(!TIL->contains(NewBB) &&
294 "Split point for loop exit is contained in loop!");
295
296 // Update LCSSA form in the newly created exit block.
297 if (Options.PreserveLCSSA) {
298 // If > 1 identical edges to be split, we need to introduce the same
299 // number of the incoming blocks for the new PHINode.
301 SmallVector<BasicBlock *, 4>(NumSplitIdenticalEdges, TIBB), NewBB,
302 DestBB);
303 }
304
305 if (!LoopPreds.empty()) {
306 assert(!DestBB->isEHPad() && "We don't split edges to EH pads!");
308 DestBB, LoopPreds, "split", DT, LI, MSSAU, Options.PreserveLCSSA);
309 if (Options.PreserveLCSSA)
310 createPHIsForSplitLoopExit(LoopPreds, NewExitBB, DestBB);
311 }
312 }
313 }
314 }
315
316 return NewBB;
317}
318
319// Return the unique indirectbr predecessor of a block. This may return null
320// even if such a predecessor exists, if it's not useful for splitting.
321// If a predecessor is found, OtherPreds will contain all other (non-indirectbr)
322// predecessors of BB.
323static BasicBlock *
325 // Verify we have exactly one IBR predecessor.
326 // Conservatively bail out if one of the other predecessors is not a "regular"
327 // terminator (that is, not a switch or a br).
328 BasicBlock *IBB = nullptr;
329 for (BasicBlock *PredBB : predecessors(BB)) {
330 Instruction *PredTerm = PredBB->getTerminator();
331 switch (PredTerm->getOpcode()) {
332 case Instruction::IndirectBr:
333 if (IBB)
334 return nullptr;
335 IBB = PredBB;
336 break;
337 case Instruction::Br:
338 case Instruction::Switch:
339 OtherPreds.push_back(PredBB);
340 continue;
341 default:
342 return nullptr;
343 }
344 }
345
346 return IBB;
347}
348
350 bool IgnoreBlocksWithoutPHI,
352 BlockFrequencyInfo *BFI) {
353 // Check whether the function has any indirectbrs, and collect which blocks
354 // they may jump to. Since most functions don't have indirect branches,
355 // this lowers the common case's overhead to O(Blocks) instead of O(Edges).
357 for (auto &BB : F) {
358 if (isa<IndirectBrInst>(BB.getTerminator()))
359 Targets.insert_range(successors(&BB));
360 }
361
362 if (Targets.empty())
363 return false;
364
365 bool ShouldUpdateAnalysis = BPI && BFI;
366 bool Changed = false;
367 for (BasicBlock *Target : Targets) {
368 if (IgnoreBlocksWithoutPHI && Target->phis().empty())
369 continue;
370
372 BasicBlock *IBRPred = findIBRPredecessor(Target, OtherPreds);
373 // If we did not found an indirectbr, or the indirectbr is the only
374 // incoming edge, this isn't the kind of edge we're looking for.
375 if (!IBRPred || OtherPreds.empty())
376 continue;
377
378 // Don't even think about ehpads/landingpads.
379 auto FirstNonPHIIt = Target->getFirstNonPHIIt();
380 if (FirstNonPHIIt->isEHPad() || Target->isLandingPad())
381 continue;
382
383 // Remember edge probabilities if needed.
384 SmallVector<BranchProbability, 4> EdgeProbabilities;
385 if (ShouldUpdateAnalysis) {
386 EdgeProbabilities.reserve(Target->getTerminator()->getNumSuccessors());
387 for (unsigned I = 0, E = Target->getTerminator()->getNumSuccessors();
388 I < E; ++I)
389 EdgeProbabilities.emplace_back(BPI->getEdgeProbability(Target, I));
390 BPI->eraseBlock(Target);
391 }
392
393 BasicBlock *BodyBlock = Target->splitBasicBlock(FirstNonPHIIt, ".split");
394 if (ShouldUpdateAnalysis) {
395 // Copy the BFI/BPI from Target to BodyBlock.
396 BPI->setEdgeProbability(BodyBlock, EdgeProbabilities);
397 BFI->setBlockFreq(BodyBlock, BFI->getBlockFreq(Target));
398 }
399 // It's possible Target was its own successor through an indirectbr.
400 // In this case, the indirectbr now comes from BodyBlock.
401 if (IBRPred == Target)
402 IBRPred = BodyBlock;
403
404 // At this point Target only has PHIs, and BodyBlock has the rest of the
405 // block's body. Create a copy of Target that will be used by the "direct"
406 // preds.
408 BasicBlock *DirectSucc = CloneBasicBlock(Target, VMap, ".clone", &F);
409 if (!VMap.AtomMap.empty())
410 for (Instruction &I : *DirectSucc)
411 RemapSourceAtom(&I, VMap);
412
413 BlockFrequency BlockFreqForDirectSucc;
414 for (BasicBlock *Pred : OtherPreds) {
415 // If the target is a loop to itself, then the terminator of the split
416 // block (BodyBlock) needs to be updated.
417 BasicBlock *Src = Pred != Target ? Pred : BodyBlock;
418 Src->getTerminator()->replaceUsesOfWith(Target, DirectSucc);
419 if (ShouldUpdateAnalysis)
420 BlockFreqForDirectSucc += BFI->getBlockFreq(Src) *
421 BPI->getEdgeProbability(Src, DirectSucc);
422 }
423 if (ShouldUpdateAnalysis) {
424 BFI->setBlockFreq(DirectSucc, BlockFreqForDirectSucc);
425 BlockFrequency NewBlockFreqForTarget =
426 BFI->getBlockFreq(Target) - BlockFreqForDirectSucc;
427 BFI->setBlockFreq(Target, NewBlockFreqForTarget);
428 }
429
430 // Ok, now fix up the PHIs. We know the two blocks only have PHIs, and that
431 // they are clones, so the number of PHIs are the same.
432 // (a) Remove the edge coming from IBRPred from the "Direct" PHI
433 // (b) Leave that as the only edge in the "Indirect" PHI.
434 // (c) Merge the two in the body block.
435 BasicBlock::iterator Indirect = Target->begin(),
436 End = Target->getFirstNonPHIIt();
437 BasicBlock::iterator Direct = DirectSucc->begin();
438 BasicBlock::iterator MergeInsert = BodyBlock->getFirstInsertionPt();
439
440 assert(&*End == Target->getTerminator() &&
441 "Block was expected to only contain PHIs");
442
443 while (Indirect != End) {
444 PHINode *DirPHI = cast<PHINode>(Direct);
445 PHINode *IndPHI = cast<PHINode>(Indirect);
446 BasicBlock::iterator InsertPt = Indirect;
447
448 // Now, clean up - the direct block shouldn't get the indirect value,
449 // and vice versa.
450 DirPHI->removeIncomingValue(IBRPred);
451 Direct++;
452
453 // Advance the pointer here, to avoid invalidation issues when the old
454 // PHI is erased.
455 Indirect++;
456
457 PHINode *NewIndPHI = PHINode::Create(IndPHI->getType(), 1, "ind", InsertPt);
458 NewIndPHI->addIncoming(IndPHI->getIncomingValueForBlock(IBRPred),
459 IBRPred);
460 NewIndPHI->setDebugLoc(IndPHI->getDebugLoc());
461
462 // Create a PHI in the body block, to merge the direct and indirect
463 // predecessors.
464 PHINode *MergePHI = PHINode::Create(IndPHI->getType(), 2, "merge");
465 MergePHI->insertBefore(MergeInsert);
466 MergePHI->addIncoming(NewIndPHI, Target);
467 MergePHI->addIncoming(DirPHI, DirectSucc);
468 MergePHI->applyMergedLocation(DirPHI->getDebugLoc(),
469 IndPHI->getDebugLoc());
470
471 IndPHI->replaceAllUsesWith(MergePHI);
472 IndPHI->eraseFromParent();
473 }
474
475 Changed = true;
476 }
477
478 return Changed;
479}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static BasicBlock * findIBRPredecessor(BasicBlock *BB, SmallVectorImpl< BasicBlock * > &OtherPreds)
static bool runOnFunction(Function &F, bool PostInlining)
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
static LVOptions Options
Definition LVOptions.cpp:25
#define F(x, y, z)
Definition MD5.cpp:55
#define I(x, y, z)
Definition MD5.cpp:58
#define P(N)
static cl::opt< bool > SplitAllCriticalEdges("phi-elim-split-all-critical-edges", cl::init(false), cl::Hidden, cl::desc("Split all critical edges during " "PHI elimination"))
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition PassSupport.h:56
This file implements a set that has insertion order iteration characteristics.
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)
Definition Statistic.h:171
PassT::Result * getCachedResult(IRUnitT &IR) const
Get the cached result of an analysis pass for a given IR unit.
AnalysisUsage & addPreservedID(const void *ID)
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
LLVM Basic Block Representation.
Definition BasicBlock.h:62
iterator begin()
Instruction iterator methods.
Definition BasicBlock.h:459
LLVM_ABI const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
const Function * getParent() const
Return the enclosing method, or null if none.
Definition BasicBlock.h:213
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
Definition BasicBlock.h:206
InstListType::iterator iterator
Instruction iterators...
Definition BasicBlock.h:170
LLVM_ABI InstListType::const_iterator getFirstNonPHIOrDbgOrLifetime(bool SkipPseudoOp=true) const
Returns a pointer to the first instruction in this block that is not a PHINode, a debug intrinsic,...
bool isEHPad() const
Return true if this basic block is an exception handling block.
Definition BasicBlock.h:707
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.h:233
LLVM_ABI void removePredecessor(BasicBlock *Pred, bool KeepOneInputPHIs=false)
Update PHI nodes in this BasicBlock before removal of predecessor Pred.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
Conditional or Unconditional Branch instruction.
static BranchInst * Create(BasicBlock *IfTrue, InsertPosition InsertBefore=nullptr)
Analysis providing branch probability information.
LLVM_ABI void eraseBlock(const BasicBlock *BB)
Forget analysis results for the given basic block.
LLVM_ABI void setEdgeProbability(const BasicBlock *Src, const SmallVectorImpl< BranchProbability > &Probs)
Set the raw probabilities for all edges from the given block.
LLVM_ABI BranchProbability getEdgeProbability(const BasicBlock *Src, unsigned IndexInSuccessors) const
Get an edge's probability, relative to other out-edges of the Src.
Analysis pass which computes a DominatorTree.
Definition Dominators.h:284
FunctionPass class - This class is used to implement most global optimizations.
Definition Pass.h:314
BasicBlockListType::iterator iterator
Definition Function.h:69
LLVM_ABI unsigned getNumSuccessors() const LLVM_READONLY
Return the number of successors that this instruction has.
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
LLVM_ABI void insertBefore(InstListType::iterator InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified position.
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
LLVM_ABI BasicBlock * getSuccessor(unsigned Idx) const LLVM_READONLY
Return the specified successor. This instruction must be a terminator.
LLVM_ABI void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
LLVM_ABI void setSuccessor(unsigned Idx, BasicBlock *BB)
Update the specified successor to point at the provided block.
LLVM_ABI void applyMergedLocation(DebugLoc LocA, DebugLoc LocB)
Merge 2 debug locations and apply it to the Instruction.
Analysis pass that exposes the LoopInfo for a function.
Definition LoopInfo.h:569
Represents a single loop in the control flow graph.
Definition LoopInfo.h:40
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
void setIncomingBlock(unsigned i, BasicBlock *BB)
LLVM_ABI Value * removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty=true)
Remove an incoming value.
Value * getIncomingValueForBlock(const BasicBlock *BB) const
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
int getBasicBlockIndex(const BasicBlock *BB) const
Return the first index of the specified basic block in the value list for this PHI.
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
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.
Definition Analysis.h:112
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
PreservedAnalyses & preserve()
Mark an analysis as preserved.
Definition Analysis.h:132
void insert_range(Range &&R)
Definition SetVector.h:175
bool empty() const
Determine if the SetVector is empty or not.
Definition SetVector.h:99
A SetVector that performs no allocations if smaller than a certain size.
Definition SetVector.h:338
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
void reserve(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Target - Wrapper for Target specific information.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
LLVM_ABI std::string str() const
Return the twine contents as a std::string.
Definition Twine.cpp:17
LLVM_ABI bool replaceUsesOfWith(Value *From, Value *To)
Replace uses of one Value with another.
Definition User.cpp:24
DMAtomT AtomMap
Map {(InlinedAt, old atom number) -> new atom number}.
Definition ValueMap.h:123
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:256
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition Value.cpp:546
LLVM_ABI LLVMContext & getContext() const
All values hold a context through their type.
Definition Value.cpp:1099
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
Definition Value.cpp:322
const ParentTy * getParent() const
Definition ilist_node.h:34
self_iterator getIterator()
Definition ilist_node.h:123
Changed
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI BasicBlock * CloneBasicBlock(const BasicBlock *BB, ValueToValueMapTy &VMap, const Twine &NameSuffix="", Function *F=nullptr, ClonedCodeInfo *CodeInfo=nullptr, bool MapAtoms=true)
Return a copy of the specified basic block, but without embedding the block into a particular functio...
auto successors(const MachineBasicBlock *BB)
LLVM_ABI FunctionPass * createBreakCriticalEdgesPass()
LLVM_ABI char & LoopSimplifyID
LLVM_ABI BasicBlock * SplitKnownCriticalEdge(Instruction *TI, unsigned SuccNum, const CriticalEdgeSplittingOptions &Options=CriticalEdgeSplittingOptions(), const Twine &BBName="")
If it is known that an edge is critical, SplitKnownCriticalEdge can be called directly,...
LLVM_ABI bool SplitIndirectBrCriticalEdges(Function &F, bool IgnoreBlocksWithoutPHI, BranchProbabilityInfo *BPI=nullptr, BlockFrequencyInfo *BFI=nullptr)
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1732
LLVM_ABI char & BreakCriticalEdgesID
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
LLVM_ABI BasicBlock * SplitBlockPredecessors(BasicBlock *BB, ArrayRef< BasicBlock * > Preds, const char *Suffix, DominatorTree *DT, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, bool PreserveLCSSA=false)
This method introduces at least one new basic block into the function and moves some of the predecess...
LLVM_ABI void createPHIsForSplitLoopExit(ArrayRef< BasicBlock * > Preds, BasicBlock *SplitBB, BasicBlock *DestBB)
When a loop exit edge is split, LCSSA form may require new PHIs in the new exit block.
LLVM_ABI void initializeBreakCriticalEdgesPass(PassRegistry &)
LLVM_ABI BasicBlock * SplitCriticalEdge(Instruction *TI, unsigned SuccNum, const CriticalEdgeSplittingOptions &Options=CriticalEdgeSplittingOptions(), const Twine &BBName="")
If this edge is a critical edge, insert a new node to split the critical edge.
LLVM_ABI bool isCriticalEdge(const Instruction *TI, unsigned SuccNum, bool AllowIdenticalEdges=false)
Return true if the specified edge is a critical edge.
Definition CFG.cpp:96
ValueMap< const Value *, WeakTrackingVH > ValueToValueMapTy
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
auto predecessors(const MachineBasicBlock *BB)
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition STLExtras.h:1897
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
LLVM_ABI void RemapSourceAtom(Instruction *I, ValueToValueMapTy &VM)
Remap source location atom.
#define N
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Option class for critical edge splitting.