summaryrefslogtreecommitdiff
path: root/contrib/llvm/lib/Analysis/MemorySSAUpdater.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-06-10 19:17:14 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-06-10 19:17:14 +0000
commitdb17bf38c59bc172953ed66cfe1b10c03c6bc383 (patch)
tree2712281fec99b99c2fcafd5b46439dfdd93261aa /contrib/llvm/lib/Analysis/MemorySSAUpdater.cpp
parent686fb94a00297bf9ff49d93b948925552a2ce8e0 (diff)
parent7ab83427af0f77b59941ceba41d509d7d097b065 (diff)
Notes
Diffstat (limited to 'contrib/llvm/lib/Analysis/MemorySSAUpdater.cpp')
-rw-r--r--contrib/llvm/lib/Analysis/MemorySSAUpdater.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/contrib/llvm/lib/Analysis/MemorySSAUpdater.cpp b/contrib/llvm/lib/Analysis/MemorySSAUpdater.cpp
index da5c79ab6c81..1ff84471c094 100644
--- a/contrib/llvm/lib/Analysis/MemorySSAUpdater.cpp
+++ b/contrib/llvm/lib/Analysis/MemorySSAUpdater.cpp
@@ -14,6 +14,7 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallSet.h"
+#include "llvm/Analysis/MemorySSA.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/GlobalVariable.h"
@@ -24,7 +25,6 @@
#include "llvm/IR/Module.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FormattedStream.h"
-#include "llvm/Analysis/MemorySSA.h"
#include <algorithm>
#define DEBUG_TYPE "memoryssa"
@@ -124,17 +124,12 @@ MemoryAccess *MemorySSAUpdater::getPreviousDefInBlock(MemoryAccess *MA) {
return &*Iter;
} else {
// Otherwise, have to walk the all access iterator.
- auto Iter = MA->getReverseIterator();
- ++Iter;
- while (&*Iter != &*Defs->begin()) {
- if (!isa<MemoryUse>(*Iter))
- return &*Iter;
- --Iter;
- }
- // At this point it must be pointing at firstdef
- assert(&*Iter == &*Defs->begin() &&
- "Should have hit first def walking backwards");
- return &*Iter;
+ auto End = MSSA->getWritableBlockAccesses(MA->getBlock())->rend();
+ for (auto &U : make_range(++MA->getReverseIterator(), End))
+ if (!isa<MemoryUse>(U))
+ return cast<MemoryAccess>(&U);
+ // Note that if MA comes before Defs->begin(), we won't hit a def.
+ return nullptr;
}
}
return nullptr;