We can do cast-add elimination even on casts that reinterpret
[oota-llvm.git] / lib / Target / TargetData.cpp
index 0b4dc98233cb59b201daa80f4b749bd9e324fa55..09bc6009dc81518d2c4d450919a3e8b9c62e6949 100644 (file)
@@ -12,7 +12,7 @@
 
 #include "llvm/Target/TargetData.h"
 #include "llvm/DerivedTypes.h"
-#include "llvm/ConstPoolVals.h"
+#include "llvm/ConstantVals.h"
 
 static inline void getTypeInfo(const Type *Ty, const TargetData *TD,
                               unsigned &Size, unsigned char &Alignment);
@@ -146,17 +146,17 @@ unsigned char TargetData::getTypeAlignment(const Type *Ty) const {
 }
 
 unsigned TargetData::getIndexedOffset(const Type *ptrTy,
-                                     const vector<ConstPoolVal*> &Idx) const {
+                                     const vector<Constant*> &Idx) const {
   const PointerType *PtrTy = cast<const PointerType>(ptrTy);
   unsigned Result = 0;
 
   // Get the type pointed to...
-  const Type *Ty = PtrTy->getValueType();
+  const Type *Ty = PtrTy->getElementType();
 
   for (unsigned CurIDX = 0; CurIDX < Idx.size(); ++CurIDX) {
     if (const StructType *STy = dyn_cast<const StructType>(Ty)) {
       assert(Idx[CurIDX]->getType() == Type::UByteTy && "Illegal struct idx");
-      unsigned FieldNo = ((ConstPoolUInt*)Idx[CurIDX++])->getValue();
+      unsigned FieldNo = cast<ConstantUInt>(Idx[CurIDX])->getValue();
 
       // Get structure layout information...
       const StructLayout *Layout = getStructLayout(STy);