[llvm-branch-commits] [llvm-branch] r113111 - in /llvm/branches/release_28: ./ lib/Analysis/ValueTracking.cpp test/Transforms/GlobalOpt/crash.ll

Bill Wendling isanbard at gmail.com
Sun Sep 5 10:45:44 PDT 2010


Author: void
Date: Sun Sep  5 12:45:44 2010
New Revision: 113111

URL: http://llvm.org/viewvc/llvm-project?rev=113111&view=rev
Log:
Approved by Chris:

$ svn merge -c 113109 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r113109 into '.':
U    test/Transforms/GlobalOpt/crash.ll
U    lib/Analysis/ValueTracking.cpp

Log:
fix PR8063, a crash in globalopt in the malloc analysis code.


Modified:
    llvm/branches/release_28/   (props changed)
    llvm/branches/release_28/lib/Analysis/ValueTracking.cpp
    llvm/branches/release_28/test/Transforms/GlobalOpt/crash.ll

Propchange: llvm/branches/release_28/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Sep  5 12:45:44 2010
@@ -1 +1,2 @@
 /llvm/branches/Apple/Pertwee:110850,110961
+/llvm/trunk:113109

Modified: llvm/branches/release_28/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_28/lib/Analysis/ValueTracking.cpp?rev=113111&r1=113110&r2=113111&view=diff
==============================================================================
--- llvm/branches/release_28/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/branches/release_28/lib/Analysis/ValueTracking.cpp Sun Sep  5 12:45:44 2010
@@ -880,19 +880,20 @@
     }
 
     Value *Mul0 = NULL;
-    Value *Mul1 = NULL;
-    bool M0 = ComputeMultiple(Op0, Base, Mul0,
-                              LookThroughSExt, Depth+1);
-    bool M1 = ComputeMultiple(Op1, Base, Mul1,
-                              LookThroughSExt, Depth+1);
-
-    if (M0) {
-      if (isa<Constant>(Op1) && isa<Constant>(Mul0)) {
-        // V == Base * (Mul0 * Op1), so return (Mul0 * Op1)
-        Multiple = ConstantExpr::getMul(cast<Constant>(Mul0),
-                                        cast<Constant>(Op1));
-        return true;
-      }
+    if (ComputeMultiple(Op0, Base, Mul0, LookThroughSExt, Depth+1)) {
+      if (Constant *Op1C = dyn_cast<Constant>(Op1))
+        if (Constant *MulC = dyn_cast<Constant>(Mul0)) {
+          if (Op1C->getType()->getPrimitiveSizeInBits() < 
+              MulC->getType()->getPrimitiveSizeInBits())
+            Op1C = ConstantExpr::getZExt(Op1C, MulC->getType());
+          if (Op1C->getType()->getPrimitiveSizeInBits() > 
+              MulC->getType()->getPrimitiveSizeInBits())
+            MulC = ConstantExpr::getZExt(MulC, Op1C->getType());
+          
+          // V == Base * (Mul0 * Op1), so return (Mul0 * Op1)
+          Multiple = ConstantExpr::getMul(MulC, Op1C);
+          return true;
+        }
 
       if (ConstantInt *Mul0CI = dyn_cast<ConstantInt>(Mul0))
         if (Mul0CI->getValue() == 1) {
@@ -902,13 +903,21 @@
         }
     }
 
-    if (M1) {
-      if (isa<Constant>(Op0) && isa<Constant>(Mul1)) {
-        // V == Base * (Mul1 * Op0), so return (Mul1 * Op0)
-        Multiple = ConstantExpr::getMul(cast<Constant>(Mul1),
-                                        cast<Constant>(Op0));
-        return true;
-      }
+    Value *Mul1 = NULL;
+    if (ComputeMultiple(Op1, Base, Mul1, LookThroughSExt, Depth+1)) {
+      if (Constant *Op0C = dyn_cast<Constant>(Op0))
+        if (Constant *MulC = dyn_cast<Constant>(Mul1)) {
+          if (Op0C->getType()->getPrimitiveSizeInBits() < 
+              MulC->getType()->getPrimitiveSizeInBits())
+            Op0C = ConstantExpr::getZExt(Op0C, MulC->getType());
+          if (Op0C->getType()->getPrimitiveSizeInBits() > 
+              MulC->getType()->getPrimitiveSizeInBits())
+            MulC = ConstantExpr::getZExt(MulC, Op0C->getType());
+          
+          // V == Base * (Mul1 * Op0), so return (Mul1 * Op0)
+          Multiple = ConstantExpr::getMul(MulC, Op0C);
+          return true;
+        }
 
       if (ConstantInt *Mul1CI = dyn_cast<ConstantInt>(Mul1))
         if (Mul1CI->getValue() == 1) {

Modified: llvm/branches/release_28/test/Transforms/GlobalOpt/crash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_28/test/Transforms/GlobalOpt/crash.ll?rev=113111&r1=113110&r2=113111&view=diff
==============================================================================
--- llvm/branches/release_28/test/Transforms/GlobalOpt/crash.ll (original)
+++ llvm/branches/release_28/test/Transforms/GlobalOpt/crash.ll Sun Sep  5 12:45:44 2010
@@ -40,3 +40,18 @@
 }
 
 declare noalias i8* @malloc(i64) nounwind
+
+
+; PR8063
+ at permute_bitrev.bitrev = internal global i32* null, align 8
+define void @permute_bitrev() nounwind {
+entry:
+  %tmp = load i32** @permute_bitrev.bitrev, align 8
+  %conv = sext i32 0 to i64
+  %mul = mul i64 %conv, 4
+  %call = call i8* @malloc(i64 %mul)
+  %0 = bitcast i8* %call to i32*
+  store i32* %0, i32** @permute_bitrev.bitrev, align 8
+  ret void
+}
+





More information about the llvm-branch-commits mailing list