Fix memory corruption. If one of the SCEV creation functions calls another but
authorNick Lewycky <nicholas@mxc.ca>
Wed, 26 Jan 2011 08:40:22 +0000 (08:40 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Wed, 26 Jan 2011 08:40:22 +0000 (08:40 +0000)
doesn't return immediately after then the insert position in UniqueSCEVs will
be out of date. No test because this is a memory corruption issue. Fixes PR9051!

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

lib/Analysis/ScalarEvolution.cpp

index c10af50dd597dd7ac958caf28e7adcf72dae3cd4..c2f3ac071de2c7e3a3c64000ba87ac19ae5c0536 100644 (file)
@@ -831,6 +831,7 @@ const SCEV *ScalarEvolution::getTruncateExpr(const SCEV *Op,
     }
     if (!hasTrunc)
       return getAddExpr(Operands, false, false);
+    UniqueSCEVs.FindNodeOrInsertPos(ID, IP);  // Mutates IP, returns NULL.
   }
 
   // trunc(x1*x2*...*xN) --> trunc(x1)*trunc(x2)*...*trunc(xN) if we can
@@ -845,6 +846,7 @@ const SCEV *ScalarEvolution::getTruncateExpr(const SCEV *Op,
     }
     if (!hasTrunc)
       return getMulExpr(Operands, false, false);
+    UniqueSCEVs.FindNodeOrInsertPos(ID, IP);  // Mutates IP, returns NULL.
   }
 
   // If the input value is a chrec scev, truncate the chrec's operands.