LLVM 24.0.0git
MustExecute.h
Go to the documentation of this file.
1//===- MustExecute.h - Is an instruction known to execute--------*- C++ -*-===//
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/// \file
9/// Contains a collection of routines for determining if a given instruction is
10/// guaranteed to execute if a given point in control flow is reached. The most
11/// common example is an instruction within a loop being provably executed if we
12/// branch to the header of it's containing loop.
13///
14/// There are two interfaces available to determine if an instruction is
15/// executed once a given point in the control flow is reached:
16/// 1) A loop-centric one derived from LoopSafetyInfo.
17/// 2) A "must be executed context"-based one implemented in the
18/// MustBeExecutedContextExplorer.
19/// Please refer to the class comments for more information.
20///
21//===----------------------------------------------------------------------===//
22
23#ifndef LLVM_ANALYSIS_MUSTEXECUTE_H
24#define LLVM_ANALYSIS_MUSTEXECUTE_H
25
26#include "llvm/ADT/DenseMap.h"
27#include "llvm/ADT/DenseSet.h"
30#include "llvm/IR/PassManager.h"
32
33namespace llvm {
34
35namespace {
36template <typename T> using GetterTy = std::function<T *(const Function &F)>;
37}
38
39class BasicBlock;
40class DominatorTree;
41class Loop;
42class LoopInfo;
44class raw_ostream;
45
46/// Captures loop safety information.
47/// It keep information for loop blocks may throw exception or otherwise
48/// exit abnormally on any iteration of the loop which might actually execute
49/// at runtime. The primary way to consume this information is via
50/// isGuaranteedToExecute below, but some callers bailout or fallback to
51/// alternate reasoning if a loop contains any implicit control flow.
52/// NOTE: LoopSafetyInfo contains cached information regarding loops and their
53/// particular blocks. This information is only dropped on invocation of
54/// computeLoopSafetyInfo. If the loop or any of its block is deleted, or if
55/// any thrower instructions have been added or removed from them, or if the
56/// control flow has changed, or in case of other meaningful modifications, the
57/// LoopSafetyInfo needs to be recomputed. If a meaningful modifications to the
58/// loop were made and the info wasn't recomputed properly, the behavior of all
59/// methods except for computeLoopSafetyInfo is undefined.
61 // Used to update funclet bundle operands.
63
64 // Cache whether (the start of) this block is guaranteed to execute if the
65 // loop is entered.
66 mutable DenseMap<const BasicBlock *, bool> GuaranteedToExecute;
67
68protected:
69 /// Computes block colors.
70 LLVM_ABI void computeBlockColors(const Loop *CurLoop);
71
72public:
73 /// Returns block colors map that is used to update funclet operand bundles.
75
76 /// Copy colors of block \p Old into the block \p New.
78
79 /// Returns true iff the block \p BB potentially may throw exception. It can
80 /// be false-positive in cases when we want to avoid complex analysis.
81 virtual bool blockMayThrow(const BasicBlock *BB) const = 0;
82
83 /// Returns true iff any block of the loop for which this info is contains an
84 /// instruction that may throw or otherwise exit abnormally.
85 virtual bool anyBlockMayThrow() const = 0;
86
87 /// Return true if we must reach the block \p BB under assumption that the
88 /// loop \p CurLoop is entered.
89 LLVM_ABI bool allLoopPathsLeadToBlock(const Loop *CurLoop,
90 const BasicBlock *BB,
91 const DominatorTree *DT) const;
92
93 LLVM_ABI bool allLoopPathsLeadToBlockImpl(const Loop *CurLoop,
94 const BasicBlock *BB,
95 const DominatorTree *DT) const;
96
97 /// Computes safety information for a loop checks loop body & header for
98 /// the possibility of may throw exception, it takes LoopSafetyInfo and loop
99 /// as argument. Updates safety information in LoopSafetyInfo argument.
100 /// Note: This is defined to clear and reinitialize an already initialized
101 /// LoopSafetyInfo. Some callers rely on this fact.
102 virtual void computeLoopSafetyInfo(const Loop *CurLoop) = 0;
103
104 /// Returns true if the instruction in a loop is guaranteed to execute at
105 /// least once (under the assumption that the loop is entered).
106 virtual bool isGuaranteedToExecute(const Instruction &Inst,
107 const DominatorTree *DT,
108 const Loop *CurLoop) const = 0;
109
110 LoopSafetyInfo() = default;
111
112 virtual ~LoopSafetyInfo() = default;
113};
114
115
116/// Simple and conservative implementation of LoopSafetyInfo that can give
117/// false-positive answers to its queries in order to avoid complicated
118/// analysis.
120 bool MayThrow = false; // The current loop contains an instruction which
121 // may throw.
122 bool HeaderMayThrow = false; // Same as previous, but specific to loop header
123
124public:
125 bool blockMayThrow(const BasicBlock *BB) const override;
126
127 bool anyBlockMayThrow() const override;
128
129 void computeLoopSafetyInfo(const Loop *CurLoop) override;
130
131 bool isGuaranteedToExecute(const Instruction &Inst,
132 const DominatorTree *DT,
133 const Loop *CurLoop) const override;
134};
135
136/// This implementation of LoopSafetyInfo use ImplicitControlFlowTracking to
137/// give precise answers on "may throw" queries. This implementation uses cache
138/// that should be invalidated by calling the methods insertInstructionTo and
139/// removeInstruction whenever we modify a basic block's contents by adding or
140/// removing instructions.
142 bool MayThrow = false; // The current loop contains an instruction which
143 // may throw.
144 // Contains information about implicit control flow in this loop's blocks.
145 mutable ImplicitControlFlowTracking ICF;
146 // Contains information about instruction that may possibly write memory.
147 mutable MemoryWriteTracking MW;
148
149public:
150 bool blockMayThrow(const BasicBlock *BB) const override;
151
152 bool anyBlockMayThrow() const override;
153
154 void computeLoopSafetyInfo(const Loop *CurLoop) override;
155
156 bool isGuaranteedToExecute(const Instruction &Inst,
157 const DominatorTree *DT,
158 const Loop *CurLoop) const override;
159
160 /// Returns true if we could not execute a memory-modifying instruction before
161 /// we enter \p BB under assumption that \p CurLoop is entered.
162 bool doesNotWriteMemoryBefore(const BasicBlock *BB, const Loop *CurLoop)
163 const;
164
165 /// Returns true if we could not execute a memory-modifying instruction before
166 /// we execute \p I under assumption that \p CurLoop is entered.
167 bool doesNotWriteMemoryBefore(const Instruction &I, const Loop *CurLoop)
168 const;
169
170 /// Inform the safety info that we are planning to insert a new instruction
171 /// \p Inst into the basic block \p BB. It will make all cache updates to keep
172 /// it correct after this insertion.
173 void insertInstructionTo(const Instruction *Inst, const BasicBlock *BB);
174
175 /// Inform safety info that we are planning to remove the instruction \p Inst
176 /// from its block. It will make all cache updates to keep it correct after
177 /// this removal.
178 void removeInstruction(const Instruction *Inst);
179};
180
182 const LoopInfo *LI);
183
185
186/// Enum that allows us to spell out the direction.
190};
191
192/// Must be executed iterators visit stretches of instructions that are
193/// guaranteed to be executed together, potentially with other instruction
194/// executed in-between.
195///
196/// Given the following code, and assuming all statements are single
197/// instructions which transfer execution to the successor (see
198/// isGuaranteedToTransferExecutionToSuccessor), there are two possible
199/// outcomes. If we start the iterator at A, B, or E, we will visit only A, B,
200/// and E. If we start at C or D, we will visit all instructions A-E.
201///
202/// \code
203/// A;
204/// B;
205/// if (...) {
206/// C;
207/// D;
208/// }
209/// E;
210/// \endcode
211///
212///
213/// Below is the example extneded with instructions F and G. Now we assume F
214/// might not transfer execution to it's successor G. As a result we get the
215/// following visit sets:
216///
217/// Start Instruction | Visit Set
218/// A | A, B, E, F
219/// B | A, B, E, F
220/// C | A, B, C, D, E, F
221/// D | A, B, C, D, E, F
222/// E | A, B, E, F
223/// F | A, B, E, F
224/// G | A, B, E, F, G
225///
226///
227/// \code
228/// A;
229/// B;
230/// if (...) {
231/// C;
232/// D;
233/// }
234/// E;
235/// F; // Might not transfer execution to its successor G.
236/// G;
237/// \endcode
238///
239///
240/// A more complex example involving conditionals, loops, break, and continue
241/// is shown below. We again assume all instructions will transmit control to
242/// the successor and we assume we can prove the inner loop to be finite. We
243/// omit non-trivial branch conditions as the exploration is oblivious to them.
244/// Constant branches are assumed to be unconditional in the CFG. The resulting
245/// visist sets are shown in the table below.
246///
247/// \code
248/// A;
249/// while (true) {
250/// B;
251/// if (...)
252/// C;
253/// if (...)
254/// continue;
255/// D;
256/// if (...)
257/// break;
258/// do {
259/// if (...)
260/// continue;
261/// E;
262/// } while (...);
263/// F;
264/// }
265/// G;
266/// \endcode
267///
268/// Start Instruction | Visit Set
269/// A | A, B
270/// B | A, B
271/// C | A, B, C
272/// D | A, B, D
273/// E | A, B, D, E, F
274/// F | A, B, D, F
275/// G | A, B, D, G
276///
277///
278/// Note that the examples show optimal visist sets but not necessarily the ones
279/// derived by the explorer depending on the available CFG analyses (see
280/// MustBeExecutedContextExplorer). Also note that we, depending on the options,
281/// the visit set can contain instructions from other functions.
283 /// Type declarations that make his class an input iterator.
284 ///{
285 typedef const Instruction *value_type;
286 typedef std::ptrdiff_t difference_type;
287 typedef const Instruction **pointer;
288 typedef const Instruction *&reference;
289 typedef std::input_iterator_tag iterator_category;
290 ///}
291
293
295
297 : Visited(std::move(Other.Visited)), Explorer(Other.Explorer),
298 CurInst(Other.CurInst), Head(Other.Head), Tail(Other.Tail) {}
299
301 if (this != &Other) {
302 std::swap(Visited, Other.Visited);
303 std::swap(CurInst, Other.CurInst);
304 std::swap(Head, Other.Head);
305 std::swap(Tail, Other.Tail);
306 }
307 return *this;
308 }
309
311
312 /// Pre- and post-increment operators.
313 ///{
315 CurInst = advance();
316 return *this;
317 }
318
320 MustBeExecutedIterator tmp(*this);
321 operator++();
322 return tmp;
323 }
324 ///}
325
326 /// Equality and inequality operators. Note that we ignore the history here.
327 ///{
329 return CurInst == Other.CurInst && Head == Other.Head && Tail == Other.Tail;
330 }
331
333 return !(*this == Other);
334 }
335 ///}
336
337 /// Return the underlying instruction.
338 const Instruction *&operator*() { return CurInst; }
339 const Instruction *getCurrentInst() const { return CurInst; }
340
341 /// Return true if \p I was encountered by this iterator already.
342 bool count(const Instruction *I) const {
343 return Visited.count({I, ExplorationDirection::FORWARD}) ||
344 Visited.count({I, ExplorationDirection::BACKWARD});
345 }
346
347private:
348 using VisitedSetTy =
350
351 /// Private constructors.
353
354 /// Reset the iterator to its initial state pointing at \p I.
355 void reset(const Instruction *I);
356
357 /// Reset the iterator to point at \p I, keep cached state.
358 void resetInstruction(const Instruction *I);
359
360 /// Try to advance one of the underlying positions (Head or Tail).
361 ///
362 /// \return The next instruction in the must be executed context, or nullptr
363 /// if none was found.
364 LLVM_ABI const Instruction *advance();
365
366 /// A set to track the visited instructions in order to deal with endless
367 /// loops and recursion.
368 VisitedSetTy Visited;
369
370 /// A reference to the explorer that created this iterator.
371 ExplorerTy &Explorer;
372
373 /// The instruction we are currently exposing to the user. There is always an
374 /// instruction that we know is executed with the given program point,
375 /// initially the program point itself.
376 const Instruction *CurInst;
377
378 /// Two positions that mark the program points where this iterator will look
379 /// for the next instruction. Note that the current instruction is either the
380 /// one pointed to by Head, Tail, or both.
381 const Instruction *Head, *Tail;
382
384};
385
386/// A "must be executed context" for a given program point PP is the set of
387/// instructions, potentially before and after PP, that are executed always when
388/// PP is reached. The MustBeExecutedContextExplorer an interface to explore
389/// "must be executed contexts" in a module through the use of
390/// MustBeExecutedIterator.
391///
392/// The explorer exposes "must be executed iterators" that traverse the must be
393/// executed context. There is little information sharing between iterators as
394/// the expected use case involves few iterators for "far apart" instructions.
395/// If that changes, we should consider caching more intermediate results.
397
398 /// In the description of the parameters we use PP to denote a program point
399 /// for which the must be executed context is explored, or put differently,
400 /// for which the MustBeExecutedIterator is created.
401 ///
402 /// \param ExploreInterBlock Flag to indicate if instructions in blocks
403 /// other than the parent of PP should be
404 /// explored.
405 /// \param ExploreCFGForward Flag to indicate if instructions located after
406 /// PP in the CFG, e.g., post-dominating PP,
407 /// should be explored.
408 /// \param ExploreCFGBackward Flag to indicate if instructions located
409 /// before PP in the CFG, e.g., dominating PP,
410 /// should be explored.
413 GetterTy<const LoopInfo> LIGetter =
414 [](const Function &) { return nullptr; },
415 GetterTy<const DominatorTree> DTGetter =
416 [](const Function &) { return nullptr; },
417 GetterTy<const PostDominatorTree> PDTGetter =
418 [](const Function &) { return nullptr; })
421 ExploreCFGBackward(ExploreCFGBackward), LIGetter(LIGetter),
422 DTGetter(DTGetter), PDTGetter(PDTGetter), EndIterator(*this, nullptr) {}
423
424 /// Iterator-based interface. \see MustBeExecutedIterator.
425 ///{
428
429 /// Return an iterator to explore the context around \p PP.
431 auto &It = InstructionIteratorMap[PP];
432 if (!It)
433 It.reset(new iterator(*this, PP));
434 return *It;
435 }
436
437 /// Return an iterator to explore the cached context around \p PP.
438 const_iterator &begin(const Instruction *PP) const {
439 return *InstructionIteratorMap.find(PP)->second;
440 }
441
442 /// Return an universal end iterator.
443 ///{
444 iterator &end() { return EndIterator; }
445 iterator &end(const Instruction *) { return EndIterator; }
446
447 const_iterator &end() const { return EndIterator; }
448 const_iterator &end(const Instruction *) const { return EndIterator; }
449 ///}
450
451 /// Return an iterator range to explore the context around \p PP.
455
456 /// Return an iterator range to explore the cached context around \p PP.
458 return llvm::make_range(begin(PP), end(PP));
459 }
460 ///}
461
462 /// Check \p Pred on all instructions in the context.
463 ///
464 /// This method will evaluate \p Pred and return
465 /// true if \p Pred holds in every instruction.
467 function_ref<bool(const Instruction *)> Pred) {
468 for (auto EIt = begin(PP), EEnd = end(PP); EIt != EEnd; ++EIt)
469 if (!Pred(*EIt))
470 return false;
471 return true;
472 }
473
474 /// Helper to look for \p I in the context of \p PP.
475 ///
476 /// The context is expanded until \p I was found or no more expansion is
477 /// possible.
478 ///
479 /// \returns True, iff \p I was found.
480 bool findInContextOf(const Instruction *I, const Instruction *PP) {
481 auto EIt = begin(PP), EEnd = end(PP);
482 return findInContextOf(I, EIt, EEnd);
483 }
484
485 /// Helper to look for \p I in the context defined by \p EIt and \p EEnd.
486 ///
487 /// The context is expanded until \p I was found or no more expansion is
488 /// possible.
489 ///
490 /// \returns True, iff \p I was found.
491 bool findInContextOf(const Instruction *I, iterator &EIt, iterator &EEnd) {
492 bool Found = EIt.count(I);
493 while (!Found && EIt != EEnd)
494 Found = (++EIt).getCurrentInst() == I;
495 return Found;
496 }
497
498 /// Return the next instruction that is guaranteed to be executed after \p PP.
499 ///
500 /// \param It The iterator that is used to traverse the must be
501 /// executed context.
502 /// \param PP The program point for which the next instruction
503 /// that is guaranteed to execute is determined.
504 LLVM_ABI const Instruction *
506 const Instruction *PP);
507 /// Return the previous instr. that is guaranteed to be executed before \p PP.
508 ///
509 /// \param It The iterator that is used to traverse the must be
510 /// executed context.
511 /// \param PP The program point for which the previous instr.
512 /// that is guaranteed to execute is determined.
513 LLVM_ABI const Instruction *
515 const Instruction *PP);
516
517 /// Find the next join point from \p InitBB in forward direction.
519
520 /// Find the next join point from \p InitBB in backward direction.
522
523 /// Parameter that limit the performed exploration. See the constructor for
524 /// their meaning.
525 ///{
529 ///}
530
531private:
532 /// Getters for common CFG analyses: LoopInfo, DominatorTree, and
533 /// PostDominatorTree.
534 ///{
535 GetterTy<const LoopInfo> LIGetter;
536 GetterTy<const DominatorTree> DTGetter;
537 GetterTy<const PostDominatorTree> PDTGetter;
538 ///}
539
540 /// Map to cache isGuaranteedToTransferExecutionToSuccessor results.
542
543 /// Map to cache containsIrreducibleCFG results.
545
546 /// Map from instructions to associated must be executed iterators.
548 InstructionIteratorMap;
549
550 /// A unique end iterator.
551 MustBeExecutedIterator EndIterator;
552};
553
555 : public RequiredPassInfoMixin<MustExecutePrinterPass> {
556 raw_ostream &OS;
557
558public:
561};
562
564 : public RequiredPassInfoMixin<MustBeExecutedContextPrinterPass> {
565 raw_ostream &OS;
566
567public:
570};
571
572} // namespace llvm
573
574#endif
#define LLVM_ABI
Definition Compiler.h:215
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
This header defines various interfaces for pass management in LLVM.
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
#define T
LLVM Basic Block Representation.
Definition BasicBlock.h:62
Implements a dense probed hash-table based set.
Definition DenseSet.h:281
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition Dominators.h:122
This implementation of LoopSafetyInfo use ImplicitControlFlowTracking to give precise answers on "may...
bool blockMayThrow(const BasicBlock *BB) const override
Returns true iff the block BB potentially may throw exception.
bool doesNotWriteMemoryBefore(const BasicBlock *BB, const Loop *CurLoop) const
Returns true if we could not execute a memory-modifying instruction before we enter BB under assumpti...
void removeInstruction(const Instruction *Inst)
Inform safety info that we are planning to remove the instruction Inst from its block.
bool isGuaranteedToExecute(const Instruction &Inst, const DominatorTree *DT, const Loop *CurLoop) const override
Returns true if the instruction in a loop is guaranteed to execute at least once (under the assumptio...
bool anyBlockMayThrow() const override
Returns true iff any block of the loop for which this info is contains an instruction that may throw ...
void computeLoopSafetyInfo(const Loop *CurLoop) override
Computes safety information for a loop checks loop body & header for the possibility of may throw exc...
void insertInstructionTo(const Instruction *Inst, const BasicBlock *BB)
Inform the safety info that we are planning to insert a new instruction Inst into the basic block BB.
This class allows to keep track on instructions with implicit control flow.
LLVM_ABI bool allLoopPathsLeadToBlock(const Loop *CurLoop, const BasicBlock *BB, const DominatorTree *DT) const
Return true if we must reach the block BB under assumption that the loop CurLoop is entered.
LLVM_ABI void copyColors(BasicBlock *New, BasicBlock *Old)
Copy colors of block Old into the block New.
LLVM_ABI void computeBlockColors(const Loop *CurLoop)
Computes block colors.
LLVM_ABI const DenseMap< BasicBlock *, ColorVector > & getBlockColors() const
Returns block colors map that is used to update funclet operand bundles.
virtual ~LoopSafetyInfo()=default
virtual void computeLoopSafetyInfo(const Loop *CurLoop)=0
Computes safety information for a loop checks loop body & header for the possibility of may throw exc...
LoopSafetyInfo()=default
virtual bool anyBlockMayThrow() const =0
Returns true iff any block of the loop for which this info is contains an instruction that may throw ...
LLVM_ABI bool allLoopPathsLeadToBlockImpl(const Loop *CurLoop, const BasicBlock *BB, const DominatorTree *DT) const
virtual bool blockMayThrow(const BasicBlock *BB) const =0
Returns true iff the block BB potentially may throw exception.
virtual bool isGuaranteedToExecute(const Instruction &Inst, const DominatorTree *DT, const Loop *CurLoop) const =0
Returns true if the instruction in a loop is guaranteed to execute at least once (under the assumptio...
Represents a single loop in the control flow graph.
Definition LoopInfo.h:40
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
MustBeExecutedContextPrinterPass(raw_ostream &OS)
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
MustExecutePrinterPass(raw_ostream &OS)
PostDominatorTree Class - Concrete subclass of DominatorTree that is used to compute the post-dominat...
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
Simple and conservative implementation of LoopSafetyInfo that can give false-positive answers to its ...
bool isGuaranteedToExecute(const Instruction &Inst, const DominatorTree *DT, const Loop *CurLoop) const override
Returns true if the instruction in a loop is guaranteed to execute at least once.
void computeLoopSafetyInfo(const Loop *CurLoop) override
Computes safety information for a loop checks loop body & header for the possibility of may throw exc...
bool anyBlockMayThrow() const override
Returns true iff any block of the loop for which this info is contains an instruction that may throw ...
bool blockMayThrow(const BasicBlock *BB) const override
Returns true iff the block BB potentially may throw exception.
An efficient, type-erasing, non-owning reference to a callable.
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
@ Other
Any other memory.
Definition ModRef.h:68
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:1917
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
LLVM_ABI bool mayContainIrreducibleControl(const Function &F, const LoopInfo *LI)
ExplorationDirection
Enum that allows us to spell out the direction.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition MIRParser.h:39
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition BitVector.h:880
A "must be executed context" for a given program point PP is the set of instructions,...
const bool ExploreInterBlock
Parameter that limit the performed exploration.
const_iterator & begin(const Instruction *PP) const
Return an iterator to explore the cached context around PP.
LLVM_ABI const BasicBlock * findBackwardJoinPoint(const BasicBlock *InitBB)
Find the next join point from InitBB in backward direction.
LLVM_ABI const Instruction * getMustBeExecutedNextInstruction(MustBeExecutedIterator &It, const Instruction *PP)
Return the next instruction that is guaranteed to be executed after PP.
iterator & end()
Return an universal end iterator.
MustBeExecutedContextExplorer(bool ExploreInterBlock, bool ExploreCFGForward, bool ExploreCFGBackward, GetterTy< const LoopInfo > LIGetter=[](const Function &) { return nullptr;}, GetterTy< const DominatorTree > DTGetter=[](const Function &) { return nullptr;}, GetterTy< const PostDominatorTree > PDTGetter=[](const Function &) { return nullptr;})
In the description of the parameters we use PP to denote a program point for which the must be execut...
bool findInContextOf(const Instruction *I, const Instruction *PP)
Helper to look for I in the context of PP.
const_iterator & end() const
iterator & begin(const Instruction *PP)
Return an iterator to explore the context around PP.
llvm::iterator_range< iterator > range(const Instruction *PP)
}
LLVM_ABI const Instruction * getMustBeExecutedPrevInstruction(MustBeExecutedIterator &It, const Instruction *PP)
Return the previous instr.
bool checkForAllContext(const Instruction *PP, function_ref< bool(const Instruction *)> Pred)
}
LLVM_ABI const BasicBlock * findForwardJoinPoint(const BasicBlock *InitBB)
Find the next join point from InitBB in forward direction.
const_iterator & end(const Instruction *) const
bool findInContextOf(const Instruction *I, iterator &EIt, iterator &EEnd)
Helper to look for I in the context defined by EIt and EEnd.
iterator & end(const Instruction *)
llvm::iterator_range< const_iterator > range(const Instruction *PP) const
Return an iterator range to explore the cached context around PP.
const MustBeExecutedIterator const_iterator
MustBeExecutedIterator iterator
Iterator-based interface.
Must be executed iterators visit stretches of instructions that are guaranteed to be executed togethe...
bool operator!=(const MustBeExecutedIterator &Other) const
const Instruction * value_type
Type declarations that make his class an input iterator.
MustBeExecutedIterator(const MustBeExecutedIterator &Other)=default
MustBeExecutedContextExplorer ExplorerTy
}
const Instruction *& reference
const Instruction ** pointer
const Instruction * getCurrentInst() const
bool operator==(const MustBeExecutedIterator &Other) const
}
std::input_iterator_tag iterator_category
MustBeExecutedIterator(MustBeExecutedIterator &&Other)
MustBeExecutedIterator & operator=(MustBeExecutedIterator &&Other)
bool count(const Instruction *I) const
Return true if I was encountered by this iterator already.
MustBeExecutedIterator operator++(int)
friend struct MustBeExecutedContextExplorer
MustBeExecutedIterator & operator++()
Pre- and post-increment operators.
const Instruction *& operator*()
}
A CRTP mix-in for passes that should not be skipped.