Fix memory corruption I introduced a few checkins ago.
authorAndrew Trick <atrick@apple.com>
Thu, 13 Oct 2011 18:49:23 +0000 (18:49 +0000)
committerAndrew Trick <atrick@apple.com>
Thu, 13 Oct 2011 18:49:23 +0000 (18:49 +0000)
Self-review easily caught this obvious bug.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141880 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ScalarEvolutionNormalization.cpp

index 0670e46392214063b29a5f66fe0caae04e30907a..c66ecd6e872794942b5f032d96b246a7a4e9dbd0 100644 (file)
@@ -202,12 +202,13 @@ TransformSubExpr(const SCEV *S, Instruction *User, Value *OperandValToReplace) {
   if (isa<SCEVConstant>(S) || isa<SCEVUnknown>(S))
     return S;
 
-  const SCEV *&ExprRef = Transformed[S];
-  if (ExprRef)
-    return ExprRef;
+  const SCEV *Result = Transformed.lookup(S);
+  if (Result)
+    return Result;
 
-  ExprRef = TransformImpl(S, User, OperandValToReplace);
-  return ExprRef;
+  Result = TransformImpl(S, User, OperandValToReplace);
+  Transformed[S] = Result;
+  return Result;
 }
 
 /// Top level driver for transforming an expression DAG into its requested