LLVM 23.0.0git
FixIrreducible.cpp
Go to the documentation of this file.
1//===- FixIrreducible.cpp - Convert irreducible control-flow into loops ---===//
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// INPUT CFG: The blocks H and B form an irreducible cycle with two headers.
10//
11// Entry
12// / \
13// v v
14// H ----> B
15// ^ /|
16// `----' |
17// v
18// Exit
19//
20// OUTPUT CFG: Converted to a natural loop with a new header N.
21//
22// Entry
23// |
24// v
25// N <---.
26// / \ \
27// / \ |
28// v v /
29// H --> B --'
30// |
31// v
32// Exit
33//
34// To convert an irreducible cycle C to a natural loop L:
35//
36// 1. Add a new node N to C.
37// 2. Redirect all external incoming edges through N.
38// 3. Redirect all edges incident on header H through N.
39//
40// This is sufficient to ensure that:
41//
42// a. Every closed path in C also exists in L, with the modification that any
43// path passing through H now passes through N before reaching H.
44// b. Every external path incident on any entry of C is now incident on N and
45// then redirected to the entry.
46//
47// Thus, L is a strongly connected component dominated by N, and hence L is a
48// natural loop with header N.
49//
50// When an irreducible cycle C with header H is transformed into a loop, the
51// following invariants hold:
52//
53// 1. No new subcycles are "discovered" in the set (C-H). The only internal
54// edges that are redirected by the transform are incident on H. Any subcycle
55// S in (C-H), already existed prior to this transform, and is already in the
56// list of children for this cycle C.
57//
58// 2. Subcycles of C are not modified by the transform. For some subcycle S of
59// C, edges incident on the entries of S are either internal to C, or they
60// are now redirected through N, which is outside of S. So the list of
61// entries to S does not change. Since the transform only adds a block
62// outside S, and redirects edges that are not internal to S, the list of
63// blocks in S does not change.
64//
65// 3. Similarly, any natural loop L included in C is not affected, with one
66// exception: L is "destroyed" by the transform iff its header is H. The
67// backedges of such a loop are now redirected to N instead, and hence the
68// body of this loop gets merged into the new loop with header N.
69//
70// The actual transformation is handled by the ControlFlowHub, which redirects
71// specified control flow edges through a set of guard blocks. This also moves
72// every PHINode in an outgoing block to the hub. Since the hub dominates all
73// the outgoing blocks, each such PHINode continues to dominate its uses. Since
74// every header in an SCC has at least two predecessors, every value used in the
75// header (or later) but defined in a predecessor (or earlier) is represented by
76// a PHINode in a header. Hence the above handling of PHINodes is sufficient and
77// no further processing is required to restore SSA.
78//
79// Limitation: The pass cannot handle switch statements and indirect
80// branches. Both must be lowered to plain branches first.
81//
82// CallBr support: CallBr is handled as a more general branch instruction which
83// can have multiple successors. The pass redirects the edges to intermediate
84// target blocks that unconditionally branch to the original callbr target
85// blocks. This allows the control flow hub to know to which of the original
86// target blocks to jump to.
87// Example input CFG:
88// Entry (callbr)
89// / \
90// v v
91// H ----> B
92// ^ /|
93// `----' |
94// v
95// Exit
96//
97// becomes:
98// Entry (callbr)
99// / \
100// v v
101// target.H target.B
102// | |
103// v v
104// H ----> B
105// ^ /|
106// `----' |
107// v
108// Exit
109//
110// Note
111// OUTPUT CFG: Converted to a natural loop with a new header N.
112//
113// Entry (callbr)
114// / \
115// v v
116// target.H target.B
117// \ /
118// \ /
119// v v
120// N <---.
121// / \ \
122// / \ |
123// v v /
124// H --> B --'
125// |
126// v
127// Exit
128//
129//===----------------------------------------------------------------------===//
130
136#include "llvm/Pass.h"
141
142#define DEBUG_TYPE "fix-irreducible"
143
144using namespace llvm;
145
146namespace {
147struct FixIrreducible : public FunctionPass {
148 static char ID;
149 FixIrreducible() : FunctionPass(ID) {
151 }
152
153 void getAnalysisUsage(AnalysisUsage &AU) const override {
159 }
160
161 bool runOnFunction(Function &F) override;
162};
163} // namespace
164
165char FixIrreducible::ID = 0;
166
167FunctionPass *llvm::createFixIrreduciblePass() { return new FixIrreducible(); }
168
169INITIALIZE_PASS_BEGIN(FixIrreducible, "fix-irreducible",
170 "Convert irreducible control-flow into natural loops",
171 false /* Only looks at CFG */, false /* Analysis Pass */)
174INITIALIZE_PASS_END(FixIrreducible, "fix-irreducible",
175 "Convert irreducible control-flow into natural loops",
176 false /* Only looks at CFG */, false /* Analysis Pass */)
177
178// When a new loop is created, existing children of the parent loop may now be
179// fully inside the new loop. Reconnect these as children of the new loop.
180static void reconnectChildLoops(LoopInfo &LI, Loop *ParentLoop, Loop *NewLoop,
181 BasicBlock *OldHeader) {
182 auto &CandidateLoops = ParentLoop ? ParentLoop->getSubLoopsVector()
183 : LI.getTopLevelLoopsVector();
184 // Any candidate is a child iff its header is owned by the new loop. Move all
185 // the children to a new vector.
186 auto FirstChild = llvm::partition(CandidateLoops, [&](Loop *L) {
187 return NewLoop == L || !NewLoop->contains(L->getHeader());
188 });
189 SmallVector<Loop *, 8> ChildLoops(FirstChild, CandidateLoops.end());
190 CandidateLoops.erase(FirstChild, CandidateLoops.end());
191
192 for (Loop *Child : ChildLoops) {
193 LLVM_DEBUG(dbgs() << "child loop: " << Child->getHeader()->getName()
194 << "\n");
195 // A child loop whose header was the old cycle header gets destroyed since
196 // its backedges are removed.
197 if (Child->getHeader() == OldHeader) {
198 for (auto *BB : Child->blocks()) {
199 if (LI.getLoopFor(BB) != Child)
200 continue;
201 LI.changeLoopFor(BB, NewLoop);
202 LLVM_DEBUG(dbgs() << "moved block from child: " << BB->getName()
203 << "\n");
204 }
205 std::vector<Loop *> GrandChildLoops;
206 std::swap(GrandChildLoops, Child->getSubLoopsVector());
207 for (auto *GrandChildLoop : GrandChildLoops) {
208 GrandChildLoop->setParentLoop(nullptr);
209 NewLoop->addChildLoop(GrandChildLoop);
210 }
211 LI.destroy(Child);
212 LLVM_DEBUG(dbgs() << "subsumed child loop (common header)\n");
213 continue;
214 }
215
216 Child->setParentLoop(nullptr);
217 NewLoop->addChildLoop(Child);
218 LLVM_DEBUG(dbgs() << "added child loop to new loop\n");
219 }
220}
221
222static void updateLoopInfo(LoopInfo &LI, Cycle &C,
223 ArrayRef<BasicBlock *> GuardBlocks) {
224 // The parent loop is a natural loop L mapped to the cycle header H as long as
225 // H is not also the header of L. In the latter case, L is destroyed and we
226 // seek its parent instead.
227 BasicBlock *CycleHeader = C.getHeader();
228 Loop *ParentLoop = LI.getLoopFor(CycleHeader);
229 if (ParentLoop && ParentLoop->getHeader() == CycleHeader)
230 ParentLoop = ParentLoop->getParentLoop();
231
232 // Create a new loop from the now-transformed cycle
233 auto *NewLoop = LI.AllocateLoop();
234 if (ParentLoop) {
235 ParentLoop->addChildLoop(NewLoop);
236 } else {
237 LI.addTopLevelLoop(NewLoop);
238 }
239
240 // Add the guard blocks to the new loop. The first guard block is
241 // the head of all the backedges, and it is the first to be inserted
242 // in the loop. This ensures that it is recognized as the
243 // header. Since the new loop is already in LoopInfo, the new blocks
244 // are also propagated up the chain of parent loops.
245 for (auto *G : GuardBlocks) {
246 LLVM_DEBUG(dbgs() << "added guard block to loop: " << G->getName() << "\n");
247 NewLoop->addBasicBlockToLoop(G, LI);
248 }
249
250 for (auto *BB : C.blocks()) {
251 NewLoop->addBlockEntry(BB);
252 if (LI.getLoopFor(BB) == ParentLoop) {
253 LLVM_DEBUG(dbgs() << "moved block from parent: " << BB->getName()
254 << "\n");
255 LI.changeLoopFor(BB, NewLoop);
256 } else {
257 LLVM_DEBUG(dbgs() << "added block from child: " << BB->getName() << "\n");
258 }
259 }
260 LLVM_DEBUG(dbgs() << "header for new loop: "
261 << NewLoop->getHeader()->getName() << "\n");
262
263 reconnectChildLoops(LI, ParentLoop, NewLoop, C.getHeader());
264
265 LLVM_DEBUG(dbgs() << "Verify new loop.\n"; NewLoop->print(dbgs()));
266 NewLoop->verifyLoop();
267 if (ParentLoop) {
268 LLVM_DEBUG(dbgs() << "Verify parent loop.\n"; ParentLoop->print(dbgs()));
269 ParentLoop->verifyLoop();
270 }
271}
272
273// Given a set of blocks and headers in an irreducible SCC, convert it into a
274// natural loop. Also insert this new loop at its appropriate place in the
275// hierarchy of loops.
277 LoopInfo *LI) {
278 if (C.isReducible())
279 return false;
280 LLVM_DEBUG(dbgs() << "Processing cycle:\n" << CI.print(&C) << "\n";);
281
282 DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Eager);
283 ControlFlowHub CHub;
284 SetVector<BasicBlock *> Predecessors;
285
286 // Redirect internal edges incident on the header.
287 BasicBlock *Header = C.getHeader();
288 for (BasicBlock *P : predecessors(Header)) {
289 if (C.contains(P))
290 Predecessors.insert(P);
291 }
292
293 for (BasicBlock *P : Predecessors) {
294 if (isa<UncondBrInst>(P->getTerminator())) {
295 assert(P->getTerminator()->getSuccessor(0) == Header);
296 CHub.addBranch(P, Header);
297
298 LLVM_DEBUG(dbgs() << "Added internal branch: " << printBasicBlock(P)
299 << " -> " << printBasicBlock(Header) << '\n');
300 } else if (CondBrInst *Branch = dyn_cast<CondBrInst>(P->getTerminator())) {
301 BasicBlock *Succ0 = Branch->getSuccessor(0) == Header ? Header : nullptr;
302 BasicBlock *Succ1 = Branch->getSuccessor(1) == Header ? Header : nullptr;
303 assert(Succ0 || Succ1);
304 CHub.addBranch(P, Succ0, Succ1);
305
306 LLVM_DEBUG(dbgs() << "Added internal branch: " << printBasicBlock(P)
307 << " -> " << printBasicBlock(Succ0)
308 << (Succ0 && Succ1 ? " " : "") << printBasicBlock(Succ1)
309 << '\n');
310 } else if (CallBrInst *CallBr = dyn_cast<CallBrInst>(P->getTerminator())) {
311 for (unsigned I = 0; I < CallBr->getNumSuccessors(); ++I) {
312 BasicBlock *Succ = CallBr->getSuccessor(I);
313 if (Succ != Header)
314 continue;
315 BasicBlock *NewSucc = SplitCallBrEdge(P, Succ, I, &DTU, &CI, LI);
316 CHub.addBranch(NewSucc, Succ);
317 LLVM_DEBUG(dbgs() << "Added internal branch: "
318 << printBasicBlock(NewSucc) << " -> "
319 << printBasicBlock(Succ) << '\n');
320 }
321 } else {
322 reportFatalUsageError("unsupported block terminator: fix-irreducible "
323 "only supports br and callbr instructions");
324 }
325 }
326
327 // Redirect external incoming edges. This includes the edges on the header.
328 Predecessors.clear();
329 for (BasicBlock *E : C.entries()) {
330 for (BasicBlock *P : predecessors(E)) {
331 if (!C.contains(P))
332 Predecessors.insert(P);
333 }
334 }
335
336 for (BasicBlock *P : Predecessors) {
337 if (UncondBrInst *Branch = dyn_cast<UncondBrInst>(P->getTerminator())) {
338 BasicBlock *Succ0 = Branch->getSuccessor();
339 Succ0 = C.contains(Succ0) ? Succ0 : nullptr;
340 CHub.addBranch(P, Succ0);
341
342 LLVM_DEBUG(dbgs() << "Added external branch: " << printBasicBlock(P)
343 << " -> " << printBasicBlock(Succ0) << '\n');
344 } else if (CondBrInst *Branch = dyn_cast<CondBrInst>(P->getTerminator())) {
345 BasicBlock *Succ0 = Branch->getSuccessor(0);
346 Succ0 = C.contains(Succ0) ? Succ0 : nullptr;
347 BasicBlock *Succ1 = Branch->getSuccessor(1);
348 Succ1 = C.contains(Succ1) ? Succ1 : nullptr;
349 CHub.addBranch(P, Succ0, Succ1);
350
351 LLVM_DEBUG(dbgs() << "Added external branch: " << printBasicBlock(P)
352 << " -> " << printBasicBlock(Succ0)
353 << (Succ0 && Succ1 ? " " : "") << printBasicBlock(Succ1)
354 << '\n');
355 } else if (CallBrInst *CallBr = dyn_cast<CallBrInst>(P->getTerminator())) {
356 for (unsigned I = 0; I < CallBr->getNumSuccessors(); ++I) {
357 BasicBlock *Succ = CallBr->getSuccessor(I);
358 if (!C.contains(Succ))
359 continue;
360 BasicBlock *NewSucc = SplitCallBrEdge(P, Succ, I, &DTU, &CI, LI);
361 CHub.addBranch(NewSucc, Succ);
362 LLVM_DEBUG(dbgs() << "Added external branch: "
363 << printBasicBlock(NewSucc) << " -> "
364 << printBasicBlock(Succ) << '\n');
365 }
366 } else {
367 reportFatalUsageError("unsupported block terminator: fix-irreducible "
368 "only supports br and callbr instructions");
369 }
370 }
371
372 // Redirect all the backedges through a "hub" consisting of a series
373 // of guard blocks that manage the flow of control from the
374 // predecessors to the headers.
375 SmallVector<BasicBlock *> GuardBlocks;
376
377 // Minor optimization: The cycle entries are discovered in an order that is
378 // the opposite of the order in which these blocks appear as branch targets.
379 // This results in a lot of condition inversions in the control flow out of
380 // the new ControlFlowHub, which can be mitigated if the orders match. So we
381 // reverse the entries when adding them to the hub.
383 Entries.insert(C.entry_rbegin(), C.entry_rend());
384
385 CHub.finalize(&DTU, GuardBlocks, "irr");
386#if defined(EXPENSIVE_CHECKS)
387 assert(DT.verify(DominatorTree::VerificationLevel::Full));
388#else
389 assert(DT.verify(DominatorTree::VerificationLevel::Fast));
390#endif
391
392 // If we are updating LoopInfo, do that now before modifying the cycle. This
393 // ensures that the first guard block is the header of a new natural loop.
394 if (LI)
395 updateLoopInfo(*LI, C, GuardBlocks);
396
397 for (auto *G : GuardBlocks) {
398 LLVM_DEBUG(dbgs() << "added guard block to cycle: " << G->getName()
399 << "\n");
400 CI.addBlockToCycle(G, &C);
401 }
402 C.setSingleEntry(GuardBlocks[0]);
403
404 C.verifyCycle();
405 if (Cycle *Parent = C.getParentCycle())
406 Parent->verifyCycle();
407
408 LLVM_DEBUG(dbgs() << "Finished one cycle:\n"; CI.print(dbgs()););
409 return true;
410}
411
413 LoopInfo *LI) {
414 LLVM_DEBUG(dbgs() << "===== Fix irreducible control-flow in function: "
415 << F.getName() << "\n");
416
417 bool Changed = false;
418 for (Cycle *TopCycle : CI.toplevel_cycles()) {
419 for (Cycle *C : depth_first(TopCycle)) {
420 Changed |= fixIrreducible(*C, CI, DT, LI);
421 }
422 }
423
424 if (!Changed)
425 return false;
426
427#if defined(EXPENSIVE_CHECKS)
428 CI.verify();
429 if (LI) {
430 LI->verify(DT);
431 }
432#endif // EXPENSIVE_CHECKS
433
434 return true;
435}
436
437bool FixIrreducible::runOnFunction(Function &F) {
438 auto *LIWP = getAnalysisIfAvailable<LoopInfoWrapperPass>();
439 LoopInfo *LI = LIWP ? &LIWP->getLoopInfo() : nullptr;
440 auto &CI = getAnalysis<CycleInfoWrapperPass>().getResult();
441 auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
442 return FixIrreducibleImpl(F, CI, DT, LI);
443}
444
447 auto *LI = AM.getCachedResult<LoopAnalysis>(F);
448 auto &CI = AM.getResult<CycleAnalysis>(F);
449 auto &DT = AM.getResult<DominatorTreeAnalysis>(F);
450
451 if (!FixIrreducibleImpl(F, CI, DT, LI))
452 return PreservedAnalyses::all();
453
458 return PA;
459}
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file declares an analysis pass that computes CycleInfo for LLVM IR, specialized from GenericCycl...
static bool runOnFunction(Function &F, bool PostInlining)
fix Convert irreducible control flow into natural static false void reconnectChildLoops(LoopInfo &LI, Loop *ParentLoop, Loop *NewLoop, BasicBlock *OldHeader)
static void updateLoopInfo(LoopInfo &LI, Cycle &C, ArrayRef< BasicBlock * > GuardBlocks)
static bool FixIrreducibleImpl(Function &F, CycleInfo &CI, DominatorTree &DT, LoopInfo *LI)
static bool fixIrreducible(Cycle &C, CycleInfo &CI, DominatorTree &DT, LoopInfo *LI)
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
#define G(x, y, z)
Definition MD5.cpp:55
#define P(N)
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition PassSupport.h:42
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition PassSupport.h:44
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition PassSupport.h:39
#define LLVM_DEBUG(...)
Definition Debug.h:119
PassT::Result * getCachedResult(IRUnitT &IR) const
Get the cached result of an analysis pass for a given IR unit.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
LLVM Basic Block Representation.
Definition BasicBlock.h:62
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
Conditional Branch instruction.
Analysis pass which computes a CycleInfo.
Legacy analysis pass which computes a CycleInfo.
Analysis pass which computes a DominatorTree.
Definition Dominators.h:270
bool verify(VerificationLevel VL=VerificationLevel::Full) const
verify - checks if the tree is correct.
Legacy analysis pass which computes a DominatorTree.
Definition Dominators.h:306
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition Dominators.h:151
FunctionPass class - This class is used to implement most global optimizations.
Definition Pass.h:314
void verify() const
Verify that the entire cycle tree well-formed.
void addBlockToCycle(BlockT *Block, CycleT *Cycle)
Assumes that Cycle is the innermost cycle containing Block.
iterator_range< const_toplevel_iterator > toplevel_cycles() const
void print(raw_ostream &Out) const
Print the cycle info.
Analysis pass that exposes the LoopInfo for a function.
Definition LoopInfo.h:587
void verifyLoop() const
Verify loop structure.
BlockT * getHeader() const
void print(raw_ostream &OS, bool Verbose=false, bool PrintNested=true, unsigned Depth=0) const
Print loop with all the BBs inside it.
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.
void verify(const DominatorTreeBase< BlockT, false > &DomTree) const
void addTopLevelLoop(LoopT *New)
This adds the specified loop to the collection of top-level loops.
LoopT * AllocateLoop(ArgsTy &&...Args)
LoopT * getLoopFor(const BlockT *BB) const
Return the inner most loop that BB lives in.
void changeLoopFor(const BlockT *BB, LoopT *L)
Change the top-level loop that contains BB to the specified loop.
The legacy pass manager's analysis pass to compute loop information.
Definition LoopInfo.h:612
Represents a single loop in the control flow graph.
Definition LoopInfo.h:40
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
A vector that has set insertion semantics.
Definition SetVector.h:57
void clear()
Completely clear the SetVector.
Definition SetVector.h:267
bool insert(const value_type &X)
Insert a new element into the SetVector.
Definition SetVector.h:151
iterator erase(const_iterator CI)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Unconditional Branch instruction.
Changed
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
LLVM_ABI BasicBlock * SplitCallBrEdge(BasicBlock *CallBrBlock, BasicBlock *Succ, unsigned SuccIdx, DomTreeUpdater *DTU=nullptr, CycleInfo *CI=nullptr, LoopInfo *LI=nullptr, bool *UpdatedLI=nullptr)
Create a new intermediate target block for a callbr edge.
CycleInfo::CycleT Cycle
Definition CycleInfo.h:26
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
LLVM_ABI FunctionPass * createFixIrreduciblePass()
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
auto partition(R &&Range, UnaryPredicate P)
Provide wrappers to std::partition which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:2033
LLVM_ABI Printable printBasicBlock(const BasicBlock *BB)
Print BasicBlock BB as an operand or print "<nullptr>" if BB is a nullptr.
auto predecessors(const MachineBasicBlock *BB)
iterator_range< df_iterator< T > > depth_first(const T &G)
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
LLVM_ABI void initializeFixIrreduciblePass(PassRegistry &)
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
Definition Error.cpp:177
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition BitVector.h:862
Given a set of branch descriptors [BB, Succ0, Succ1], create a "hub" such that the control flow from ...
void addBranch(BasicBlock *BB, BasicBlock *Succ0, BasicBlock *Succ1=nullptr)
LLVM_ABI std::pair< BasicBlock *, bool > finalize(DomTreeUpdater *DTU, SmallVectorImpl< BasicBlock * > &GuardBlocks, const StringRef Prefix, std::optional< unsigned > MaxControlFlowBooleans=std::nullopt)
Return the unified loop exit block and a flag indicating if the CFG was changed at all.
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)