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