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