summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDaniel Berlin <dberlin@dberlin.org>2017-01-02 19:49:17 +0000
committerDaniel Berlin <dberlin@dberlin.org>2017-01-02 19:49:17 +0000
commitde43ef9601edf6f06b39d4b8dd56fe797bfc6fef (patch)
tree24ec99dcdf4c81f3c9c5b23f434a1a90fba9bca0 /llvm/lib
parent65d533ca427a3a14904a9645b5f80bb54e16189f (diff)
downloadbcm5719-llvm-de43ef9601edf6f06b39d4b8dd56fe797bfc6fef.tar.gz
bcm5719-llvm-de43ef9601edf6f06b39d4b8dd56fe797bfc6fef.zip
NewGVN: Clean up after removing possibility of null expressions.
llvm-svn: 290828
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/NewGVN.cpp31
1 files changed, 14 insertions, 17 deletions
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index d4200fc3908..b22c6b4ded5 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -714,16 +714,15 @@ const Expression *NewGVN::performSymbolicStoreEvaluation(Instruction *I,
// Unlike loads, we never try to eliminate stores, so we do not check if they
// are simple and avoid value numbering them.
auto *SI = cast<StoreInst>(I);
- // If this store's memorydef stores the same value as the last store, the
- // memory accesses are equivalent.
- // Get the expression, if any, for the RHS of the MemoryDef.
MemoryAccess *StoreAccess = MSSA->getMemoryAccess(SI);
- MemoryAccess *StoreRHS = lookupMemoryAccessEquiv(
- cast<MemoryDef>(StoreAccess)->getDefiningAccess());
- const Expression *OldStore = createStoreExpression(SI, StoreRHS, B);
- // See if this store expression already has a value, and it's the same as our
- // current store. FIXME: Right now, we only do this for simple stores.
+ // See if we are defined by a previous store expression, it already has a
+ // value, and it's the same value as our current store. FIXME: Right now, we
+ // only do this for simple stores, we should expand to cover memcpys, etc.
if (SI->isSimple()) {
+ // Get the expression, if any, for the RHS of the MemoryDef.
+ MemoryAccess *StoreRHS = lookupMemoryAccessEquiv(
+ cast<MemoryDef>(StoreAccess)->getDefiningAccess());
+ const Expression *OldStore = createStoreExpression(SI, StoreRHS, B);
CongruenceClass *CC = ExpressionToClass.lookup(OldStore);
if (CC && CC->DefiningExpr && isa<StoreExpression>(CC->DefiningExpr) &&
CC->RepLeader == lookupOperandLeader(SI->getValueOperand(), SI, B))
@@ -1094,16 +1093,14 @@ void NewGVN::performCongruenceFinding(Value *V, const Expression *E) {
// If this is a MemoryDef, we need to update the equivalence table. If
// we determined the expression is congruent to a different memory
// state, use that different memory state. If we determined it didn't,
- // we update that as well.
- // Right now, the only way they can be equivalent is for store
+ // we update that as well. Right now, we only support store
// expressions.
- if (!isa<MemoryUse>(MA)) {
- if (E && isa<StoreExpression>(E) && EClass->Members.size() != 1) {
- auto *DefAccess = cast<StoreExpression>(E)->getDefiningAccess();
- setMemoryAccessEquivTo(MA, DefAccess != MA ? DefAccess : nullptr);
- } else {
- setMemoryAccessEquivTo(MA, nullptr);
- }
+ if (!isa<MemoryUse>(MA) && isa<StoreExpression>(E) &&
+ EClass->Members.size() != 1) {
+ auto *DefAccess = cast<StoreExpression>(E)->getDefiningAccess();
+ setMemoryAccessEquivTo(MA, DefAccess != MA ? DefAccess : nullptr);
+ } else {
+ setMemoryAccessEquivTo(MA, nullptr);
}
markMemoryUsersTouched(MA);
}
OpenPOWER on IntegriCloud