summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDaniel Berlin <dberlin@dberlin.org>2017-04-01 09:01:12 +0000
committerDaniel Berlin <dberlin@dberlin.org>2017-04-01 09:01:12 +0000
commitd042031f0f9e0b53a358ac8a4c2068420ed11b55 (patch)
tree50be6f0581f9a1f24aba8278c32a51f99fb73fe9 /llvm/lib/Transforms
parent7500c5641e2e9ddbe1eb45f9f0e3ea6c00ea3e2b (diff)
downloadbcm5719-llvm-d042031f0f9e0b53a358ac8a4c2068420ed11b55.tar.gz
bcm5719-llvm-d042031f0f9e0b53a358ac8a4c2068420ed11b55.zip
MemorySSA: Push const correctness further.
llvm-svn: 299295
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Utils/MemorySSA.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Utils/MemorySSA.cpp b/llvm/lib/Transforms/Utils/MemorySSA.cpp
index 42119f450a6..35a63bf9d3d 100644
--- a/llvm/lib/Transforms/Utils/MemorySSA.cpp
+++ b/llvm/lib/Transforms/Utils/MemorySSA.cpp
@@ -538,7 +538,8 @@ class ClobberWalker {
WC.insert(What, To, Loc, Query->IsCall);
}
- MemoryAccess *lookupCache(const MemoryAccess *MA, const MemoryLocation &Loc) {
+ MemoryAccess *lookupCache(const MemoryAccess *MA,
+ const MemoryLocation &Loc) const {
return shouldIgnoreCache() ? nullptr : WC.lookup(MA, Loc, Query->IsCall);
}
@@ -556,7 +557,7 @@ class ClobberWalker {
}
/// Find the nearest def or phi that `From` can legally be optimized to.
- MemoryAccess *getWalkTarget(const MemoryPhi *From) const {
+ const MemoryAccess *getWalkTarget(const MemoryPhi *From) const {
assert(From->getNumOperands() && "Phi with no operands?");
BasicBlock *BB = From->getBlock();
@@ -565,7 +566,7 @@ class ClobberWalker {
while ((Node = Node->getIDom())) {
auto *Defs = MSSA.getBlockDefs(Node->getBlock());
if (Defs)
- return const_cast<MemoryAccess *>(&*Defs->rbegin());
+ return &*Defs->rbegin();
}
return Result;
}
@@ -584,8 +585,9 @@ class ClobberWalker {
/// StopAt.
///
/// This does not test for whether StopAt is a clobber
- UpwardsWalkResult walkToPhiOrClobber(DefPath &Desc,
- MemoryAccess *StopAt = nullptr) {
+ UpwardsWalkResult
+ walkToPhiOrClobber(DefPath &Desc,
+ const MemoryAccess *StopAt = nullptr) const {
assert(!isa<MemoryUse>(Desc.Last) && "Uses don't exist in my world");
for (MemoryAccess *Current : def_chain(Desc.Last)) {
@@ -636,7 +638,7 @@ class ClobberWalker {
/// If this returns None, NewPaused is a vector of searches that terminated
/// at StopWhere. Otherwise, NewPaused is left in an unspecified state.
Optional<TerminatedPath>
- getBlockingAccess(MemoryAccess *StopWhere,
+ getBlockingAccess(const MemoryAccess *StopWhere,
SmallVectorImpl<ListIndex> &PausedSearches,
SmallVectorImpl<ListIndex> &NewPaused,
SmallVectorImpl<TerminatedPath> &Terminated) {
@@ -800,7 +802,7 @@ class ClobberWalker {
assert(!MSSA.isLiveOnEntryDef(Current) &&
"liveOnEntry wasn't treated as a clobber?");
- MemoryAccess *Target = getWalkTarget(Current);
+ const auto *Target = getWalkTarget(Current);
// If a TerminatedPath doesn't dominate Target, then it wasn't a legal
// optimization for the prior phi.
assert(all_of(TerminatedPaths, [&](const TerminatedPath &P) {
@@ -878,7 +880,7 @@ class ClobberWalker {
// If we couldn't find the dominating phi/liveOnEntry in the above loop,
// do it now.
if (!DefChainEnd)
- for (MemoryAccess *MA : def_chain(Target))
+ for (auto *MA : def_chain(const_cast<MemoryAccess *>(Target)))
DefChainEnd = MA;
// If any of the terminated paths don't dominate the phi we'll try to
OpenPOWER on IntegriCloud