LLVM: lib/Transforms/Scalar/LoopSimplifyCFG.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
33#include
34using namespace llvm;
35
36#define DEBUG_TYPE "loop-simplifycfg"
37
40
42 "Number of terminators folded to unconditional branches");
44 "Number of loop blocks deleted");
46 "Number of loop exiting edges deleted");
47
48
49
50
54 if (BI->isUnconditional())
55 return nullptr;
56 if (BI->getSuccessor(0) == BI->getSuccessor(1))
57 return BI->getSuccessor(0);
60 return nullptr;
61 return Cond->isZero() ? BI->getSuccessor(1) : BI->getSuccessor(0);
62 }
63
66 if (!CI)
67 return nullptr;
68 for (auto Case : SI->cases())
69 if (Case.getCaseValue() == CI)
70 return Case.getCaseSuccessor();
71 return SI->getDefaultDest();
72 }
73
74 return nullptr;
75}
76
77
79 Loop *LastLoop = nullptr) {
80 assert((!LastLoop || LastLoop->contains(FirstLoop->getHeader())) &&
81 "First loop is supposed to be inside of last loop!");
82 assert(FirstLoop->contains(BB) && "Must be a loop block!");
83 for (Loop *Current = FirstLoop; Current != LastLoop;
85 Current->removeBlockFromLoop(BB);
86}
87
88
89
92 Loop *Innermost = nullptr;
95 while (BBL && !BBL->contains(L.getHeader()))
97 if (BBL == &L)
99 if (!BBL)
100 continue;
102 Innermost = BBL;
103 }
104 return Innermost;
105}
106
107namespace {
108
109
110class ConstantTerminatorFoldingImpl {
111private:
112 Loop &L;
113 LoopInfo &LI;
114 DominatorTree &DT;
115 ScalarEvolution &SE;
116 MemorySSAUpdater *MSSAU;
117 LoopBlocksDFS DFS;
118 DomTreeUpdater DTU;
120
121
122 bool HasIrreducibleCFG = false;
123
124
125
126
127
128
129
130
131 bool DeleteCurrentLoop = false;
132
133 bool HasIndirectEntry = false;
134
135
136
137 SmallPtrSet<BasicBlock *, 8> LiveLoopBlocks;
138
139
140 SmallVector<BasicBlock *, 8> DeadLoopBlocks;
141
142
143 SmallPtrSet<BasicBlock *, 8> LiveExitBlocks;
144
145
146 SmallVector<BasicBlock *, 8> DeadExitBlocks;
147
148 SmallPtrSet<BasicBlock *, 8> BlocksInLoopAfterFolding;
149
150
151
152 SmallVector<BasicBlock *, 8> FoldCandidates;
153
154 void dump() const {
155 dbgs() << "Constant terminator folding for loop " << L << "\n";
156 dbgs() << "After terminator constant-folding, the loop will";
157 if (!DeleteCurrentLoop)
158 dbgs() << " not";
159 dbgs() << " be destroyed\n";
160 auto PrintOutVector = [&](const char *Message,
161 const SmallVectorImpl<BasicBlock *> &S) {
162 dbgs() << Message << "\n";
163 for (const BasicBlock *BB : S)
164 dbgs() << "\t" << BB->getName() << "\n";
165 };
166 auto PrintOutSet = [&](const char *Message,
167 const SmallPtrSetImpl<BasicBlock *> &S) {
168 dbgs() << Message << "\n";
169 for (const BasicBlock *BB : S)
170 dbgs() << "\t" << BB->getName() << "\n";
171 };
172 PrintOutVector("Blocks in which we can constant-fold terminator:",
173 FoldCandidates);
174 PrintOutSet("Live blocks from the original loop:", LiveLoopBlocks);
175 PrintOutVector("Dead blocks from the original loop:", DeadLoopBlocks);
176 PrintOutSet("Live exit blocks:", LiveExitBlocks);
177 PrintOutVector("Dead exit blocks:", DeadExitBlocks);
178 if (!DeleteCurrentLoop)
179 PrintOutSet("The following blocks will still be part of the loop:",
180 BlocksInLoopAfterFolding);
181 }
182
183
184 bool hasIrreducibleCFG(LoopBlocksDFS &DFS) {
185 assert(DFS.isComplete() && "DFS is expected to be finished");
186
187 DenseMap<const BasicBlock *, unsigned> RPO;
188 unsigned Current = 0;
189 for (auto I = DFS.beginRPO(), E = DFS.endRPO(); I != E; ++I)
190 RPO[*I] = Current++;
191
192 for (auto I = DFS.beginRPO(), E = DFS.endRPO(); I != E; ++I) {
195 if (L.contains(Succ) && !LI.isLoopHeader(Succ) && RPO[BB] > RPO[Succ])
196
197
198
199 return true;
200 }
201 return false;
202 }
203
204
205
206 void analyze() {
207 DFS.perform(&LI);
208 assert(DFS.isComplete() && "DFS is expected to be finished");
209
210
211
212
213
214
215
216
217 if (hasIrreducibleCFG(DFS)) {
218 HasIrreducibleCFG = true;
219 return;
220 }
221
222
223
224
225 if (!L.getLoopPreheader()) {
227 [&](BasicBlock *Pred) {
228 return isa(Pred->getTerminator());
229 }) &&
230 "Loop should have preheader if it is not entered indirectly");
231 HasIndirectEntry = true;
232 return;
233 }
234
235
236 LiveLoopBlocks.insert(L.getHeader());
237 for (auto I = DFS.beginRPO(), E = DFS.endRPO(); I != E; ++I) {
239
240
241 if (!LiveLoopBlocks.count(BB)) {
242 DeadLoopBlocks.push_back(BB);
243 continue;
244 }
245
247
248
249
250
251
252 bool TakeFoldCandidate = TheOnlySucc && LI.getLoopFor(BB) == &L;
253 if (TakeFoldCandidate)
254 FoldCandidates.push_back(BB);
255
256
257 for (BasicBlock *Succ : successors(BB))
258 if (!TakeFoldCandidate || TheOnlySucc == Succ) {
259 if (L.contains(Succ))
260 LiveLoopBlocks.insert(Succ);
261 else
262 LiveExitBlocks.insert(Succ);
263 }
264 }
265
266
267
268 assert(L.getNumBlocks() == LiveLoopBlocks.size() + DeadLoopBlocks.size() &&
269 "Malformed block sets?");
270
271
272
273
274 SmallVector<BasicBlock *, 8> ExitBlocks;
275 L.getExitBlocks(ExitBlocks);
276 SmallPtrSet<BasicBlock *, 8> UniqueDeadExits;
277 for (auto *ExitBlock : ExitBlocks)
278 if (!LiveExitBlocks.count(ExitBlock) &&
279 UniqueDeadExits.insert(ExitBlock).second &&
281 [this](BasicBlock *Pred) { return L.contains(Pred); }))
282 DeadExitBlocks.push_back(ExitBlock);
283
284
285
287 if (!LiveLoopBlocks.count(From))
288 return false;
290 return !TheOnlySucc || TheOnlySucc == To || LI.getLoopFor(From) != &L;
291 };
292
293
294 DeleteCurrentLoop = !IsEdgeLive(L.getLoopLatch(), L.getHeader());
295
296
297
298 if (DeleteCurrentLoop)
299 return;
300
301
302
303 BlocksInLoopAfterFolding.insert(L.getLoopLatch());
304
305
306
307
308 auto BlockIsInLoop = [&](BasicBlock *BB) {
310 return BlocksInLoopAfterFolding.count(Succ) && IsEdgeLive(BB, Succ);
311 });
312 };
313 for (auto I = DFS.beginPostorder(), E = DFS.endPostorder(); I != E; ++I) {
315 if (BlockIsInLoop(BB))
316 BlocksInLoopAfterFolding.insert(BB);
317 }
318
319 assert(BlocksInLoopAfterFolding.count(L.getHeader()) &&
320 "Header not in loop?");
321 assert(BlocksInLoopAfterFolding.size() <= LiveLoopBlocks.size() &&
322 "All blocks that stay in loop should be live!");
323 }
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360 void handleDeadExits() {
361
362 if (DeadExitBlocks.empty())
363 return;
364
365
366
367 BasicBlock *Preheader = L.getLoopPreheader();
369 Preheader, Preheader->getTerminator(), &DT, &LI, MSSAU);
370
372 SwitchInst *DummySwitch =
373 Builder.CreateSwitch(Builder.getInt32(0), NewPreheader);
375
376 unsigned DummyIdx = 1;
377 for (BasicBlock *BB : DeadExitBlocks) {
378
379
380 SmallVector<Instruction *, 4> DeadInstructions(
382
384 DeadInstructions.emplace_back(LandingPad);
385
386 for (Instruction *I : DeadInstructions) {
387 SE.forgetValue(I);
389 I->eraseFromParent();
390 }
391
392 assert(DummyIdx != 0 && "Too many dead exits!");
393 DummySwitch->addCase(Builder.getInt32(DummyIdx++), BB);
394 DTUpdates.push_back({DominatorTree::Insert, Preheader, BB});
395 ++NumLoopExitsDeleted;
396 }
397
398
399
400
401
402 if (DummySwitch->getParent()->getParent()->hasProfileData()) {
403 SmallVector<uint32_t> DummyBranchWeights(1 + DummySwitch->getNumCases());
404
405 DummyBranchWeights[0] = 1;
406 setBranchWeights(*DummySwitch, DummyBranchWeights, false);
407 }
408
409 assert(L.getLoopPreheader() == NewPreheader && "Malformed CFG?");
410 if (Loop *OuterLoop = LI.getLoopFor(Preheader)) {
411
412
413
414
416
417
418
419 if (StillReachable != OuterLoop) {
420 LI.changeLoopFor(NewPreheader, StillReachable);
422 for (auto *BB : L.blocks())
424 OuterLoop->removeChildLoop(&L);
425 if (StillReachable)
427 else
428 LI.addTopLevelLoop(&L);
429
430
431
432
433 Loop *FixLCSSALoop = OuterLoop;
434 while (FixLCSSALoop->getParentLoop() != StillReachable)
436 assert(FixLCSSALoop && "Should be a loop!");
437
438 if (MSSAU)
439 MSSAU->applyUpdates(DTUpdates, DT, true);
440 else
441 DTU.applyUpdates(DTUpdates);
442 DTUpdates.clear();
444 SE.forgetBlockAndLoopDispositions();
445 }
446 }
447
448 if (MSSAU) {
449
450 MSSAU->applyUpdates(DTUpdates, DT, true);
451 DTUpdates.clear();
453 MSSAU->getMemorySSA()->verifyMemorySSA();
454 }
455 }
456
457
458
459 void deleteDeadLoopBlocks() {
460 if (MSSAU) {
461 SmallSetVector<BasicBlock *, 8> DeadLoopBlocksSet(DeadLoopBlocks.begin(),
462 DeadLoopBlocks.end());
463 MSSAU->removeBlocks(DeadLoopBlocksSet);
464 }
465
466
467
468
469
470
471
472 for (auto *BB : DeadLoopBlocks)
473 if (LI.isLoopHeader(BB)) {
474 assert(LI.getLoopFor(BB) != &L && "Attempt to remove current loop!");
475 Loop *DL = LI.getLoopFor(BB);
476 if (->isOutermost()) {
477 for (auto *PL = DL->getParentLoop(); PL; PL = PL->getParentLoop())
478 for (auto *BB : DL->getBlocks())
479 PL->removeBlockFromLoop(BB);
480 DL->getParentLoop()->removeChildLoop(DL);
481 LI.addTopLevelLoop(DL);
482 }
484 }
485
486 for (auto *BB : DeadLoopBlocks) {
487 assert(BB != L.getHeader() &&
488 "Header of the current loop cannot be dead!");
490 << "\n");
491 LI.removeBlock(BB);
492 }
493
494 detachDeadBlocks(DeadLoopBlocks, &DTUpdates, true);
495 DTU.applyUpdates(DTUpdates);
496 DTUpdates.clear();
497 for (auto *BB : DeadLoopBlocks)
498 DTU.deleteBB(BB);
499
500 NumLoopBlocksDeleted += DeadLoopBlocks.size();
501 }
502
503
504
505 void foldTerminators() {
506 for (BasicBlock *BB : FoldCandidates) {
507 assert(LI.getLoopFor(BB) == &L && "Should be a loop block!");
509 assert(TheOnlySucc && "Should have one live successor!");
510
512 << " with an unconditional branch to the block "
513 << TheOnlySucc->getName() << "\n");
514
515 SmallPtrSet<BasicBlock *, 2> DeadSuccessors;
516
517 unsigned TheOnlySuccDuplicates = 0;
519 if (Succ != TheOnlySucc) {
520 DeadSuccessors.insert(Succ);
521
522
523 bool PreserveLCSSAPhi = !L.contains(Succ);
525 if (MSSAU)
526 MSSAU->removeEdge(BB, Succ);
527 } else
528 ++TheOnlySuccDuplicates;
529
530 assert(TheOnlySuccDuplicates > 0 && "Should be!");
531
532
533
534 bool PreserveLCSSAPhi = !L.contains(TheOnlySucc);
535 for (unsigned Dup = 1; Dup < TheOnlySuccDuplicates; ++Dup)
537 if (MSSAU && TheOnlySuccDuplicates > 1)
538 MSSAU->removeDuplicatePhiEdgesBetween(BB, TheOnlySucc);
539
542 Builder.SetInsertPoint(Term);
543 Builder.CreateBr(TheOnlySucc);
544 Term->eraseFromParent();
545
546 for (auto *DeadSucc : DeadSuccessors)
547 DTUpdates.push_back({DominatorTree::Delete, BB, DeadSucc});
548
549 ++NumTerminatorsFolded;
550 }
551 }
552
553public:
554 ConstantTerminatorFoldingImpl(Loop &L, LoopInfo &LI, DominatorTree &DT,
555 ScalarEvolution &SE,
556 MemorySSAUpdater *MSSAU)
557 : L(L), LI(LI), DT(DT), SE(SE), MSSAU(MSSAU), DFS(&L),
558 DTU(DT, DomTreeUpdater::UpdateStrategy::Eager) {}
559 bool run() {
560 assert(L.getLoopLatch() && "Should be single latch!");
561
562
563
564 analyze();
566 (void)Header;
567
568 LLVM_DEBUG(dbgs() << "In function " << Header->getParent()->getName()
569 << ": ");
570
571 if (HasIrreducibleCFG) {
572 LLVM_DEBUG(dbgs() << "Loops with irreducible CFG are not supported!\n");
573 return false;
574 }
575
576 if (HasIndirectEntry) {
577 LLVM_DEBUG(dbgs() << "Loops which can be entered indirectly are not"
578 " supported!\n");
579 return false;
580 }
581
582
583 if (FoldCandidates.empty()) {
585 dbgs() << "No constant terminator folding candidates found in loop "
586 << Header->getName() << "\n");
587 return false;
588 }
589
590
591 if (DeleteCurrentLoop) {
594 << "Give up constant terminator folding in loop " << Header->getName()
595 << ": we don't currently support deletion of the current loop.\n");
596 return false;
597 }
598
599
600
601 if (BlocksInLoopAfterFolding.size() + DeadLoopBlocks.size() !=
602 L.getNumBlocks()) {
604 dbgs() << "Give up constant terminator folding in loop "
605 << Header->getName() << ": we don't currently"
606 " support blocks that are not dead, but will stop "
607 "being a part of the loop after constant-folding.\n");
608 return false;
609 }
610
611
612
613
614 if (!DeadExitBlocks.empty() && !L.isLCSSAForm(DT, false)) {
615 assert(L.isLCSSAForm(DT, true) &&
616 "LCSSA broken not by tokens?");
617 LLVM_DEBUG(dbgs() << "Give up constant terminator folding in loop "
618 << Header->getName()
619 << ": tokens uses potentially break LCSSA form.\n");
620 return false;
621 }
622
623 SE.forgetTopmostLoop(&L);
624
626
627 LLVM_DEBUG(dbgs() << "Constant-folding " << FoldCandidates.size()
628 << " terminators in loop " << Header->getName() << "\n");
629
630 if (!DeadLoopBlocks.empty())
631 SE.forgetBlockAndLoopDispositions();
632
633
634 handleDeadExits();
635 foldTerminators();
636
637 if (!DeadLoopBlocks.empty()) {
638 LLVM_DEBUG(dbgs() << "Deleting " << DeadLoopBlocks.size()
639 << " dead blocks in loop " << Header->getName() << "\n");
640 deleteDeadLoopBlocks();
641 } else {
642
643 DTU.applyUpdates(DTUpdates);
644 DTUpdates.clear();
645 }
646
648 MSSAU->getMemorySSA()->verifyMemorySSA();
649
650#ifndef NDEBUG
651
652#if defined(EXPENSIVE_CHECKS)
653 assert(DT.verify(DominatorTree::VerificationLevel::Full) &&
654 "DT broken after transform!");
655#else
656 assert(DT.verify(DominatorTree::VerificationLevel::Fast) &&
657 "DT broken after transform!");
658#endif
659 assert(DT.isReachableFromEntry(Header));
660 LI.verify(DT);
661#endif
662
663 return true;
664 }
665
666 bool foldingBreaksCurrentLoop() const {
667 return DeleteCurrentLoop;
668 }
669};
670}
671
672
673
677 bool &IsLoopDeleted) {
679 return false;
680
681
682
683 if (!L.getLoopLatch())
684 return false;
685
686 ConstantTerminatorFoldingImpl BranchFolder(L, LI, DT, SE, MSSAU);
690}
691
696 DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Eager);
697
698
700
701 for (auto &Block : Blocks) {
702
703
705 if (!Succ)
706 continue;
707
709 if (!Pred || !Pred->getSingleSuccessor() || LI.getLoopFor(Pred) != &L)
710 continue;
711
712
714
717
719 }
720
723
725}
726
729 bool &IsLoopDeleted) {
731
732
734
735 if (IsLoopDeleted)
736 return true;
737
738
740
743
745}
746
750 std::optional MSSAU;
753 bool DeleteCurrentLoop = false;
755 DeleteCurrentLoop))
757
758 if (DeleteCurrentLoop)
760
764 return PA;
765}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This header provides classes for managing a pipeline of passes over loops in LLVM IR.
static BasicBlock * getOnlyLiveSuccessor(BasicBlock *BB)
If BB is a switch or a conditional branch, but only one of its successors can be reached from this bl...
Definition LoopSimplifyCFG.cpp:51
static bool constantFoldTerminators(Loop &L, DominatorTree &DT, LoopInfo &LI, ScalarEvolution &SE, MemorySSAUpdater *MSSAU, bool &IsLoopDeleted)
Turn branches and switches with known constant conditions into unconditional branches.
Definition LoopSimplifyCFG.cpp:674
static Loop * getInnermostLoopFor(SmallPtrSetImpl< BasicBlock * > &BBs, Loop &L, LoopInfo &LI)
Find innermost loop that contains at least one block from BBs and contains the header of loop L.
Definition LoopSimplifyCFG.cpp:90
static bool mergeBlocksIntoPredecessors(Loop &L, DominatorTree &DT, LoopInfo &LI, MemorySSAUpdater *MSSAU, ScalarEvolution &SE)
Definition LoopSimplifyCFG.cpp:692
static bool simplifyLoopCFG(Loop &L, DominatorTree &DT, LoopInfo &LI, ScalarEvolution &SE, MemorySSAUpdater *MSSAU, bool &IsLoopDeleted)
Definition LoopSimplifyCFG.cpp:727
static cl::opt< bool > EnableTermFolding("enable-loop-simplifycfg-term-folding", cl::init(true))
static void removeBlockFromLoops(BasicBlock *BB, Loop *FirstLoop, Loop *LastLoop=nullptr)
Removes BB from all loops from [FirstLoop, LastLoop) in parent chain.
Definition LoopSimplifyCFG.cpp:78
This file exposes an interface to building/using memory SSA to walk memory instructions using a use/d...
This file contains the declarations for profiling metadata utility functions.
const SmallVectorImpl< MachineOperand > & Cond
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)
LLVM Basic Block Representation.
iterator_range< const_phi_iterator > phis() const
Returns a range that iterates over the phis in the basic block.
LLVM_ABI InstListType::const_iterator getFirstNonPHIIt() const
Returns an iterator to the first instruction in this block that is not a PHINode instruction.
LLVM_ABI const BasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor block.
LLVM_ABI LLVMContext & getContext() const
Get the context in which this basic block lives.
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...
LLVM_ABI void removePredecessor(BasicBlock *Pred, bool KeepOneInputPHIs=false)
Update PHI nodes in this BasicBlock before removal of predecessor Pred.
Conditional or Unconditional Branch instruction.
This is the shared class of boolean and integer constants.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
This class provides an interface for updating the loop pass manager based on mutations to the loop ne...
void markLoopAsDeleted(Loop &L, llvm::StringRef Name)
Loop passes should use this method to indicate they have deleted a loop from the nest.
bool contains(const LoopT *L) const
Return true if the specified loop is contained within in this loop.
BlockT * getHeader() const
unsigned getLoopDepth() const
Return the nesting level of this loop.
void addChildLoop(LoopT *NewChild)
Add the specified loop to be a child of this loop.
LoopT * getParentLoop() const
Return the parent loop if it exists or nullptr for top level loops.
LoopT * getLoopFor(const BlockT *BB) const
Return the inner most loop that BB lives in.
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM, LoopStandardAnalysisResults &AR, LPMUpdater &U)
Definition LoopSimplifyCFG.cpp:747
Represents a single loop in the control flow graph.
LLVM_ABI instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
An analysis that produces MemorySSA for a function.
MemorySSA * getMemorySSA() const
Get handle on MemorySSA.
LLVM_ABI void verifyMemorySSA(VerificationLevel=VerificationLevel::Fast) const
Verify that MemorySSA is self consistent (IE definitions dominate all uses, uses appear in the right ...
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
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.
The main scalar evolution driver.
LLVM_ABI void forgetTopmostLoop(const Loop *L)
LLVM_ABI void forgetBlockAndLoopDispositions(Value *V=nullptr)
Called when the client has changed the disposition of values in a loop or block.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
LLVM_ABI void addCase(ConstantInt *OnVal, BasicBlock *Dest)
Add an entry to the switch instruction.
unsigned getNumCases() const
Return the number of 'cases' in this switch instruction, excluding the default case.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
const ParentTy * getParent() const
@ BasicBlock
Various leaf nodes.
initializer< Ty > init(const Ty &Val)
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
friend class Instruction
Iterator for Instructions in a `BasicBlock.
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI void detachDeadBlocks(ArrayRef< BasicBlock * > BBs, SmallVectorImpl< DominatorTree::UpdateType > *Updates, bool KeepOneInputPHIs=false)
Replace contents of every block in BBs with single unreachable instruction.
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
auto successors(const MachineBasicBlock *BB)
LLVM_ABI bool formLCSSARecursively(Loop &L, const DominatorTree &DT, const LoopInfo *LI, ScalarEvolution *SE)
Put a loop nest into LCSSA form.
auto cast_or_null(const Y &Val)
LLVM_ABI void setBranchWeights(Instruction &I, ArrayRef< uint32_t > Weights, bool IsExpected, bool ElideAllZero=false)
Create a new branch_weights metadata node and add or overwrite a prof metadata reference to instructi...
AnalysisManager< Loop, LoopStandardAnalysisResults & > LoopAnalysisManager
The loop analysis manager.
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.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
IRBuilder(LLVMContext &, FolderTy, InserterTy, MDNode *, ArrayRef< OperandBundleDef >) -> IRBuilder< FolderTy, InserterTy >
LLVM_ABI bool VerifyMemorySSA
Enables verification of MemorySSA.
LLVM_ABI bool MergeBlockIntoPredecessor(BasicBlock *BB, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, MemoryDependenceResults *MemDep=nullptr, bool PredecessorWithTwoSuccessors=false, DominatorTree *DT=nullptr)
Attempts to merge a block into its predecessor, if possible.
LLVM_ABI BasicBlock * SplitBlock(BasicBlock *Old, BasicBlock::iterator SplitPt, DominatorTree *DT, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, const Twine &BBName="", bool Before=false)
Split the specified block at the specified instruction.
LLVM_ABI PreservedAnalyses getLoopPassPreservedAnalyses()
Returns the minimum set of Analyses that all loop passes must preserve.
auto predecessors(const MachineBasicBlock *BB)
iterator_range< pointer_iterator< WrappedIteratorT > > make_pointer_range(RangeT &&Range)
The adaptor from a function pass to a loop pass computes these analyses and makes them available to t...