summaryrefslogtreecommitdiff
path: root/lib/Analysis/LoopInfo.cpp
diff options
context:
space:
mode:
authorSilviu Baranga <silviu.baranga@arm.com>2016-05-13 14:54:50 +0000
committerSilviu Baranga <silviu.baranga@arm.com>2016-05-13 14:54:50 +0000
commit412498b9548fc548304b5f536327961f02b8a9d3 (patch)
tree04730d6b39ed5c59efcea041262783698c4fe4ee /lib/Analysis/LoopInfo.cpp
parent99761932398ca321fc330a01e2d6b70543295233 (diff)
[scan-build] fix warnings emiited on LLVM Analysis code base
Fix "Logic error" warnings of the type "Called C++ object pointer is null" reported by Clang Static Analyzer on the following files: lib/Analysis/ScalarEvolution.cpp, lib/Analysis/LoopInfo.cpp. Patch by Apelete Seketeli! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269424 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/LoopInfo.cpp')
-rw-r--r--lib/Analysis/LoopInfo.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp
index 2ac1ae2e5cf..252b5957c9f 100644
--- a/lib/Analysis/LoopInfo.cpp
+++ b/lib/Analysis/LoopInfo.cpp
@@ -376,7 +376,7 @@ namespace {
/// Find the new parent loop for all blocks within the "unloop" whose last
/// backedges has just been removed.
class UnloopUpdater {
- Loop *Unloop;
+ Loop &Unloop;
LoopInfo *LI;
LoopBlocksDFS DFS;
@@ -393,7 +393,7 @@ class UnloopUpdater {
public:
UnloopUpdater(Loop *UL, LoopInfo *LInfo) :
- Unloop(UL), LI(LInfo), DFS(UL), FoundIB(false) {}
+ Unloop(*UL), LI(LInfo), DFS(UL), FoundIB(false) {}
void updateBlockParents();
@@ -409,7 +409,7 @@ protected:
/// Update the parent loop for all blocks that are directly contained within the
/// original "unloop".
void UnloopUpdater::updateBlockParents() {
- if (Unloop->getNumBlocks()) {
+ if (Unloop.getNumBlocks()) {
// Perform a post order CFG traversal of all blocks within this loop,
// propagating the nearest loop from sucessors to predecessors.
LoopBlocksTraversal Traversal(DFS, LI);
@@ -421,14 +421,14 @@ void UnloopUpdater::updateBlockParents() {
if (NL != L) {
// For reducible loops, NL is now an ancestor of Unloop.
- assert((NL != Unloop && (!NL || NL->contains(Unloop))) &&
+ assert((NL != &Unloop && (!NL || NL->contains(&Unloop))) &&
"uninitialized successor");
LI->changeLoopFor(*POI, NL);
}
else {
// Or the current block is part of a subloop, in which case its parent
// is unchanged.
- assert((FoundIB || Unloop->contains(L)) && "uninitialized successor");
+ assert((FoundIB || Unloop.contains(L)) && "uninitialized successor");
}
}
}
@@ -436,7 +436,7 @@ void UnloopUpdater::updateBlockParents() {
// the DFS result cached by Traversal.
bool Changed = FoundIB;
for (unsigned NIters = 0; Changed; ++NIters) {
- assert(NIters < Unloop->getNumBlocks() && "runaway iterative algorithm");
+ assert(NIters < Unloop.getNumBlocks() && "runaway iterative algorithm");
// Iterate over the postorder list of blocks, propagating the nearest loop
// from successors to predecessors as before.
@@ -447,7 +447,7 @@ void UnloopUpdater::updateBlockParents() {
Loop *L = LI->getLoopFor(*POI);
Loop *NL = getNearestLoop(*POI, L);
if (NL != L) {
- assert(NL != Unloop && (!NL || NL->contains(Unloop)) &&
+ assert(NL != &Unloop && (!NL || NL->contains(&Unloop)) &&
"uninitialized successor");
LI->changeLoopFor(*POI, NL);
Changed = true;
@@ -460,17 +460,17 @@ void UnloopUpdater::updateBlockParents() {
void UnloopUpdater::removeBlocksFromAncestors() {
// Remove all unloop's blocks (including those in nested subloops) from
// ancestors below the new parent loop.
- for (Loop::block_iterator BI = Unloop->block_begin(),
- BE = Unloop->block_end(); BI != BE; ++BI) {
+ for (Loop::block_iterator BI = Unloop.block_begin(),
+ BE = Unloop.block_end(); BI != BE; ++BI) {
Loop *OuterParent = LI->getLoopFor(*BI);
- if (Unloop->contains(OuterParent)) {
- while (OuterParent->getParentLoop() != Unloop)
+ if (Unloop.contains(OuterParent)) {
+ while (OuterParent->getParentLoop() != &Unloop)
OuterParent = OuterParent->getParentLoop();
OuterParent = SubloopParents[OuterParent];
}
// Remove blocks from former Ancestors except Unloop itself which will be
// deleted.
- for (Loop *OldParent = Unloop->getParentLoop(); OldParent != OuterParent;
+ for (Loop *OldParent = Unloop.getParentLoop(); OldParent != OuterParent;
OldParent = OldParent->getParentLoop()) {
assert(OldParent && "new loop is not an ancestor of the original");
OldParent->removeBlockFromLoop(*BI);
@@ -480,9 +480,9 @@ void UnloopUpdater::removeBlocksFromAncestors() {
/// Update the parent loop for all subloops directly nested within unloop.
void UnloopUpdater::updateSubloopParents() {
- while (!Unloop->empty()) {
- Loop *Subloop = *std::prev(Unloop->end());
- Unloop->removeChildLoop(std::prev(Unloop->end()));
+ while (!Unloop.empty()) {
+ Loop *Subloop = *std::prev(Unloop.end());
+ Unloop.removeChildLoop(std::prev(Unloop.end()));
assert(SubloopParents.count(Subloop) && "DFS failed to visit subloop");
if (Loop *Parent = SubloopParents[Subloop])
@@ -504,16 +504,16 @@ Loop *UnloopUpdater::getNearestLoop(BasicBlock *BB, Loop *BBLoop) {
Loop *NearLoop = BBLoop;
Loop *Subloop = nullptr;
- if (NearLoop != Unloop && Unloop->contains(NearLoop)) {
+ if (NearLoop != &Unloop && Unloop.contains(NearLoop)) {
Subloop = NearLoop;
// Find the subloop ancestor that is directly contained within Unloop.
- while (Subloop->getParentLoop() != Unloop) {
+ while (Subloop->getParentLoop() != &Unloop) {
Subloop = Subloop->getParentLoop();
assert(Subloop && "subloop is not an ancestor of the original loop");
}
// Get the current nearest parent of the Subloop exits, initially Unloop.
NearLoop =
- SubloopParents.insert(std::make_pair(Subloop, Unloop)).first->second;
+ SubloopParents.insert(std::make_pair(Subloop, &Unloop)).first->second;
}
succ_iterator I = succ_begin(BB), E = succ_end(BB);
@@ -526,33 +526,33 @@ Loop *UnloopUpdater::getNearestLoop(BasicBlock *BB, Loop *BBLoop) {
continue; // self loops are uninteresting
Loop *L = LI->getLoopFor(*I);
- if (L == Unloop) {
+ if (L == &Unloop) {
// This successor has not been processed. This path must lead to an
// irreducible backedge.
assert((FoundIB || !DFS.hasPostorder(*I)) && "should have seen IB");
FoundIB = true;
}
- if (L != Unloop && Unloop->contains(L)) {
+ if (L != &Unloop && Unloop.contains(L)) {
// Successor is in a subloop.
if (Subloop)
continue; // Branching within subloops. Ignore it.
// BB branches from the original into a subloop header.
- assert(L->getParentLoop() == Unloop && "cannot skip into nested loops");
+ assert(L->getParentLoop() == &Unloop && "cannot skip into nested loops");
// Get the current nearest parent of the Subloop's exits.
L = SubloopParents[L];
// L could be Unloop if the only exit was an irreducible backedge.
}
- if (L == Unloop) {
+ if (L == &Unloop) {
continue;
}
// Handle critical edges from Unloop into a sibling loop.
- if (L && !L->contains(Unloop)) {
+ if (L && !L->contains(&Unloop)) {
L = L->getParentLoop();
}
// Remember the nearest parent loop among successors or subloop exits.
- if (NearLoop == Unloop || !NearLoop || NearLoop->contains(L))
+ if (NearLoop == &Unloop || !NearLoop || NearLoop->contains(L))
NearLoop = L;
}
if (Subloop) {