Make getAlignOf return an i64, for consistency with getSizeOf and
authorDan Gohman <gohman@apple.com>
Thu, 28 Jan 2010 02:43:22 +0000 (02:43 +0000)
committerDan Gohman <gohman@apple.com>
Thu, 28 Jan 2010 02:43:22 +0000 (02:43 +0000)
getOffsetOf, and remove the comment about assuming i8 is byte-aligned,
which is no longer applicable.

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

include/llvm/Constants.h
lib/VMCore/Constants.cpp

index f34f9cbf58b5537e6f34fb3db86935f6e1f76ea2..58077f0eb23a62a249b9d6a35dc8d5211c10f52d 100644 (file)
@@ -644,8 +644,7 @@ public:
   ///
 
   /// getAlignOf constant expr - computes the alignment of a type in a target
-  /// independent way (Note: the return type is an i32; Note: assumes that i8
-  /// is byte aligned).
+  /// independent way (Note: the return type is an i64).
   static Constant *getAlignOf(const Type* Ty);
   
   /// getSizeOf constant expr - computes the size of a type in a target
index 9e1154e95e33d517aee6bd717588914306d29d70..1415944885bbffc21a7651415ab3fa47920a7143 100644 (file)
@@ -1484,12 +1484,12 @@ Constant* ConstantExpr::getAlignOf(const Type* Ty) {
   const Type *AligningTy = StructType::get(Ty->getContext(),
                                    Type::getInt1Ty(Ty->getContext()), Ty, NULL);
   Constant *NullPtr = Constant::getNullValue(AligningTy->getPointerTo());
-  Constant *Zero = ConstantInt::get(Type::getInt32Ty(Ty->getContext()), 0);
+  Constant *Zero = ConstantInt::get(Type::getInt64Ty(Ty->getContext()), 0);
   Constant *One = ConstantInt::get(Type::getInt32Ty(Ty->getContext()), 1);
   Constant *Indices[2] = { Zero, One };
   Constant *GEP = getGetElementPtr(NullPtr, Indices, 2);
   return getCast(Instruction::PtrToInt, GEP,
-                 Type::getInt32Ty(Ty->getContext()));
+                 Type::getInt64Ty(Ty->getContext()));
 }
 
 Constant* ConstantExpr::getOffsetOf(const StructType* STy, unsigned FieldNo) {