[llvm-commits] [llvm] r79651 - /llvm/trunk/lib/Analysis/ConstantFolding.cpp

Dan Gohman gohman at apple.com
Fri Aug 21 11:27:26 PDT 2009


Author: djg
Date: Fri Aug 21 13:27:26 2009
New Revision: 79651

URL: http://llvm.org/viewvc/llvm-project?rev=79651&view=rev
Log:
Don't assume that the operand of an inttoptr is an pointer-sized integer.

Modified:
    llvm/trunk/lib/Analysis/ConstantFolding.cpp

Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=79651&r1=79650&r2=79651&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original)
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Fri Aug 21 13:27:26 2009
@@ -138,8 +138,10 @@
     // otherwise we can't.
     if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Ptr))
       if (CE->getOpcode() == Instruction::IntToPtr)
-        if (ConstantInt *Base = dyn_cast<ConstantInt>(CE->getOperand(0)))
+        if (ConstantInt *Base = dyn_cast<ConstantInt>(CE->getOperand(0))) {
           BasePtr = Base->getValue();
+          BasePtr.zextOrTrunc(BitWidth);
+        }
     
     if (BasePtr == 0)
       BaseIsInt = false;





More information about the llvm-commits mailing list