diff options
Diffstat (limited to 'llvm/lib/VMCore')
| -rw-r--r-- | llvm/lib/VMCore/ConstantFolding.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/VMCore/Type.cpp | 9 | ||||
| -rw-r--r-- | llvm/lib/VMCore/iMemory.cpp | 7 | 
3 files changed, 14 insertions, 10 deletions
| diff --git a/llvm/lib/VMCore/ConstantFolding.cpp b/llvm/lib/VMCore/ConstantFolding.cpp index db21bd3d782..1fee5012b45 100644 --- a/llvm/lib/VMCore/ConstantFolding.cpp +++ b/llvm/lib/VMCore/ConstantFolding.cpp @@ -608,10 +608,10 @@ static int IdxCompare(Constant *C1, Constant *C2) {    if (!isa<ConstantInt>(C1) || !isa<ConstantInt>(C2))      return -2; // don't know! -  // Ok, we have two differing integer indices.  Convert them to -  // be the same type.  Long is always big enough, so we use it. -  C1 = ConstantExpr::getCast(C1, Type::LongTy); -  C2 = ConstantExpr::getCast(C2, Type::LongTy); +  // Ok, we have two differing integer indices.  Sign extend them to be the same +  // type.  Long is always big enough, so we use it. +  C1 = ConstantExpr::getSignExtend(C1, Type::LongTy); +  C2 = ConstantExpr::getSignExtend(C2, Type::LongTy);    if (C1 == C2) return 0;  // Are they just differing types?    // If they are really different, now that they are the same type, then we diff --git a/llvm/lib/VMCore/Type.cpp b/llvm/lib/VMCore/Type.cpp index 1e2d741edfd..b7d71812400 100644 --- a/llvm/lib/VMCore/Type.cpp +++ b/llvm/lib/VMCore/Type.cpp @@ -295,8 +295,9 @@ const std::string &Type::getDescription() const {  bool StructType::indexValid(const Value *V) const {    // Structure indexes require unsigned integer constants. -  if (const ConstantUInt *CU = dyn_cast<ConstantUInt>(V)) -    return CU->getValue() < ContainedTys.size(); +  if (V->getType() == Type::UIntTy) +    if (const ConstantUInt *CU = dyn_cast<ConstantUInt>(V)) +      return CU->getValue() < ContainedTys.size();    return false;  } @@ -304,10 +305,8 @@ bool StructType::indexValid(const Value *V) const {  // element.  For a structure type, this must be a constant value...  //  const Type *StructType::getTypeAtIndex(const Value *V) const { -  assert(isa<Constant>(V) && "Structure index must be a constant!!"); +  assert(indexValid(V) && "Invalid structure index!");    unsigned Idx = cast<ConstantUInt>(V)->getValue(); -  assert(Idx < ContainedTys.size() && "Structure index out of range!"); -  assert(indexValid(V) && "Invalid structure index!"); // Duplicate check    return ContainedTys[Idx];  } diff --git a/llvm/lib/VMCore/iMemory.cpp b/llvm/lib/VMCore/iMemory.cpp index 7c8f66599f5..1fc1df8c95b 100644 --- a/llvm/lib/VMCore/iMemory.cpp +++ b/llvm/lib/VMCore/iMemory.cpp @@ -137,7 +137,12 @@ const Type* GetElementPtrInst::getIndexedType(const Type *Ptr,    if (!isa<PointerType>(Ptr)) return 0;   // Type isn't a pointer type!    // Handle the special case of the empty set index set... -  if (Idx.empty()) return cast<PointerType>(Ptr)->getElementType(); +  if (Idx.empty()) +    if (AllowCompositeLeaf || +        cast<PointerType>(Ptr)->getElementType()->isFirstClassType()) +      return cast<PointerType>(Ptr)->getElementType(); +    else +      return 0;    unsigned CurIdx = 0;    while (const CompositeType *CT = dyn_cast<CompositeType>(Ptr)) { | 

