mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
Factor out a loopHasNoAbnormalExits; NFC
llvm-svn: 272236
This commit is contained in:
parent
f7f711ffaa
commit
3b2361a5ba
@ -781,13 +781,15 @@ namespace llvm {
|
||||
SmallVector<PointerIntPair<const Loop *, 2, LoopDisposition>, 2>>
|
||||
LoopDispositions;
|
||||
|
||||
/// A cache of the predicate "does the given loop contain an instruction
|
||||
/// that can abnormally exit the loop (i.e. via throwing an exception, by
|
||||
/// terminating the thread cleanly or by infinite looping in a called
|
||||
/// function)?" The last one is strictly not leaving the loop, but is
|
||||
/// identical to leaving the loop from the viewpoint of reasoning about
|
||||
/// undefined behavior.
|
||||
DenseMap<const Loop *, bool> LoopHasAbnormalExit;
|
||||
/// Cache for \c loopHasNoAbnormalExits.
|
||||
DenseMap<const Loop *, bool> LoopHasNoAbnormalExits;
|
||||
|
||||
/// Returns true if \p L contains no instruction that can abnormally exit
|
||||
/// the loop (i.e. via throwing an exception, by terminating the thread
|
||||
/// cleanly or by infinite looping in a called function). Strictly
|
||||
/// speaking, the last one is not leaving the loop, but is identical to
|
||||
/// leaving the loop for reasoning about undefined behavior.
|
||||
bool loopHasNoAbnormalExits(const Loop *L);
|
||||
|
||||
/// Compute a LoopDisposition value.
|
||||
LoopDisposition computeLoopDisposition(const SCEV *S, const Loop *L);
|
||||
|
@ -4906,13 +4906,12 @@ bool ScalarEvolution::isAddRecNeverPoison(const Instruction *I, const Loop *L) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!LatchControlDependentOnPoison)
|
||||
return false;
|
||||
return LatchControlDependentOnPoison && loopHasNoAbnormalExits(L);
|
||||
}
|
||||
|
||||
// Now check if loop has abonormal exits (or not), and cache the information.
|
||||
|
||||
auto Itr = LoopHasAbnormalExit.find(L);
|
||||
if (Itr == LoopHasAbnormalExit.end()) {
|
||||
bool ScalarEvolution::loopHasNoAbnormalExits(const Loop *L) {
|
||||
auto Itr = LoopHasNoAbnormalExits.find(L);
|
||||
if (Itr == LoopHasNoAbnormalExits.end()) {
|
||||
bool HasAbnormalExit = false;
|
||||
for (auto *BB : L->getBlocks()) {
|
||||
HasAbnormalExit = any_of(*BB, [](Instruction &I) {
|
||||
@ -4921,12 +4920,12 @@ bool ScalarEvolution::isAddRecNeverPoison(const Instruction *I, const Loop *L) {
|
||||
if (HasAbnormalExit)
|
||||
break;
|
||||
}
|
||||
auto InsertPair = LoopHasAbnormalExit.insert({L, HasAbnormalExit});
|
||||
auto InsertPair = LoopHasNoAbnormalExits.insert({L, !HasAbnormalExit});
|
||||
assert(InsertPair.second && "We just checked!");
|
||||
Itr = InsertPair.first;
|
||||
}
|
||||
|
||||
return !Itr->second;
|
||||
return Itr->second;
|
||||
}
|
||||
|
||||
const SCEV *ScalarEvolution::createSCEV(Value *V) {
|
||||
@ -5490,7 +5489,7 @@ void ScalarEvolution::forgetLoop(const Loop *L) {
|
||||
for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I)
|
||||
forgetLoop(*I);
|
||||
|
||||
LoopHasAbnormalExit.erase(L);
|
||||
LoopHasNoAbnormalExits.erase(L);
|
||||
}
|
||||
|
||||
void ScalarEvolution::forgetValue(Value *V) {
|
||||
|
Loading…
Reference in New Issue
Block a user