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

Chris Lattner sabre at nondot.org
Fri Oct 23 22:27:19 PDT 2009


Author: lattner
Date: Sat Oct 24 00:27:19 2009
New Revision: 84993

URL: http://llvm.org/viewvc/llvm-project?rev=84993&view=rev
Log:
various cleanups suggested by Duncan

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=84993&r1=84992&r2=84993&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original)
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Sat Oct 24 00:27:19 2009
@@ -103,6 +103,8 @@
   assert(ByteOffset <= TD.getTypeAllocSize(C->getType()) &&
          "Out of range access");
   
+  // If this element is zero or undefined, we can just return since *CurPtr is
+  // zero initialized.
   if (isa<ConstantAggregateZero>(C) || isa<UndefValue>(C))
     return true;
   
@@ -115,7 +117,7 @@
     unsigned IntBytes = unsigned(CI->getBitWidth()/8);
     
     for (unsigned i = 0; i != BytesLeft && ByteOffset != IntBytes; ++i) {
-      CurPtr[i] = (unsigned char)(Val >> ByteOffset * 8);
+      CurPtr[i] = (unsigned char)(Val >> (ByteOffset * 8));
       ++ByteOffset;
     }
     return true;
@@ -130,6 +132,7 @@
       C = ConstantExpr::getBitCast(C, Type::getInt32Ty(C->getContext()));
       return ReadDataFromGlobal(C, ByteOffset, CurPtr, BytesLeft, TD);
     }
+    return false;
   }
 
   if (ConstantStruct *CS = dyn_cast<ConstantStruct>(C)) {
@@ -247,8 +250,7 @@
     return 0;
   
   GlobalVariable *GV = dyn_cast<GlobalVariable>(GVal);
-  if (!GV || !GV->isConstant() || !GV->hasInitializer() ||
-      !GV->hasDefinitiveInitializer() ||
+  if (!GV || !GV->isConstant() || !GV->hasDefinitiveInitializer() ||
       !GV->getInitializer()->getType()->isSized())
     return 0;
 





More information about the llvm-commits mailing list