Update clang to r339409b.
Change-Id: Ied8a188bb072c40035320acedc86164b66d920af
diff --git a/linux-x64/clang/include/llvm/Analysis/MustExecute.h b/linux-x64/clang/include/llvm/Analysis/MustExecute.h
index 97ad76d..40a0273 100644
--- a/linux-x64/clang/include/llvm/Analysis/MustExecute.h
+++ b/linux-x64/clang/include/llvm/Analysis/MustExecute.h
@@ -31,28 +31,60 @@
class Loop;
/// Captures loop safety information.
-/// It keep information for loop & its header may throw exception or otherwise
+/// It keep information for loop blocks may throw exception or otherwise
/// exit abnormaly on any iteration of the loop which might actually execute
/// at runtime. The primary way to consume this infromation is via
/// isGuaranteedToExecute below, but some callers bailout or fallback to
/// alternate reasoning if a loop contains any implicit control flow.
-struct LoopSafetyInfo {
+/// NOTE: LoopSafetyInfo contains cached information regarding loops and their
+/// particular blocks. This information is only dropped on invocation of
+/// computeLoopSafetyInfo. If the loop or any of its block is deleted, or if
+/// any thrower instructions have been added or removed from them, or if the
+/// control flow has changed, or in case of other meaningful modifications, the
+/// LoopSafetyInfo needs to be recomputed. If a meaningful modifications to the
+/// loop were made and the info wasn't recomputed properly, the behavior of all
+/// methods except for computeLoopSafetyInfo is undefined.
+class LoopSafetyInfo {
bool MayThrow = false; // The current loop contains an instruction which
// may throw.
bool HeaderMayThrow = false; // Same as previous, but specific to loop header
+
+ /// Collect all blocks from \p CurLoop which lie on all possible paths from
+ /// the header of \p CurLoop (inclusive) to BB (exclusive) into the set
+ /// \p Predecessors. If \p BB is the header, \p Predecessors will be empty.
+ void collectTransitivePredecessors(
+ const Loop *CurLoop, const BasicBlock *BB,
+ SmallPtrSetImpl<const BasicBlock *> &Predecessors) const;
+
+public:
// Used to update funclet bundle operands.
DenseMap<BasicBlock *, ColorVector> BlockColors;
+ /// Returns true iff the header block of the loop for which this info is
+ /// calculated contains an instruction that may throw or otherwise exit
+ /// abnormally.
+ bool headerMayThrow() const;
+
+ /// Returns true iff any block of the loop for which this info is contains an
+ /// instruction that may throw or otherwise exit abnormally.
+ bool anyBlockMayThrow() const;
+
+ /// Return true if we must reach the block \p BB under assumption that the
+ /// loop \p CurLoop is entered and no instruction throws or otherwise exits
+ /// abnormally.
+ bool allLoopPathsLeadToBlock(const Loop *CurLoop, const BasicBlock *BB,
+ const DominatorTree *DT) const;
+
+ /// Computes safety information for a loop checks loop body & header for
+ /// the possibility of may throw exception, it takes LoopSafetyInfo and loop
+ /// as argument. Updates safety information in LoopSafetyInfo argument.
+ /// Note: This is defined to clear and reinitialize an already initialized
+ /// LoopSafetyInfo. Some callers rely on this fact.
+ void computeLoopSafetyInfo(Loop *);
+
LoopSafetyInfo() = default;
};
-/// Computes safety information for a loop checks loop body & header for
-/// the possibility of may throw exception, it takes LoopSafetyInfo and loop as
-/// argument. Updates safety information in LoopSafetyInfo argument.
-/// Note: This is defined to clear and reinitialize an already initialized
-/// LoopSafetyInfo. Some callers rely on this fact.
-void computeLoopSafetyInfo(LoopSafetyInfo *, Loop *);
-
/// Returns true if the instruction in a loop is guaranteed to execute at least
/// once (under the assumption that the loop is entered).
bool isGuaranteedToExecute(const Instruction &Inst, const DominatorTree *DT,