diff options
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/Attributes.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/IR/ConstantFold.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/IR/Constants.cpp | 16 | ||||
-rw-r--r-- | llvm/lib/IR/Type.cpp | 32 | ||||
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 11 |
5 files changed, 34 insertions, 37 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index 546a98670a2..0d89d127ed8 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -1382,7 +1382,7 @@ AttrBuilder &AttrBuilder::addRawValue(uint64_t Val) { //===----------------------------------------------------------------------===// /// \brief Which attributes cannot be applied to a type. -AttrBuilder AttributeFuncs::typeIncompatible(const Type *Ty) { +AttrBuilder AttributeFuncs::typeIncompatible(Type *Ty) { AttrBuilder Incompatible; if (!Ty->isIntegerTy()) diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index 46bb20e0d1b..5dd075a7690 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -1997,17 +1997,17 @@ static bool isInBoundsIndices(ArrayRef<IndexTy> Idxs) { } /// \brief Test whether a given ConstantInt is in-range for a SequentialType. -static bool isIndexInRangeOfSequentialType(const SequentialType *STy, +static bool isIndexInRangeOfSequentialType(SequentialType *STy, const ConstantInt *CI) { - if (const PointerType *PTy = dyn_cast<PointerType>(STy)) + if (auto *PTy = dyn_cast<PointerType>(STy)) // Only handle pointers to sized types, not pointers to functions. return PTy->getElementType()->isSized(); uint64_t NumElements = 0; // Determine the number of elements in our sequential type. - if (const ArrayType *ATy = dyn_cast<ArrayType>(STy)) + if (auto *ATy = dyn_cast<ArrayType>(STy)) NumElements = ATy->getNumElements(); - else if (const VectorType *VTy = dyn_cast<VectorType>(STy)) + else if (auto *VTy = dyn_cast<VectorType>(STy)) NumElements = VTy->getNumElements(); assert((isa<ArrayType>(STy) || NumElements > 0) && @@ -2178,7 +2178,7 @@ static Constant *ConstantFoldGetElementPtrImpl(Type *PointeeTy, Constant *C, // dimension. NewIdxs.resize(Idxs.size()); uint64_t NumElements = 0; - if (const ArrayType *ATy = dyn_cast<ArrayType>(Ty)) + if (auto *ATy = dyn_cast<ArrayType>(Ty)) NumElements = ATy->getNumElements(); else NumElements = cast<VectorType>(Ty)->getNumElements(); diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 308e6bde3d1..9365653516e 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -797,10 +797,10 @@ Constant *ConstantAggregateZero::getElementValue(unsigned Idx) const { } unsigned ConstantAggregateZero::getNumElements() const { - const Type *Ty = getType(); - if (const auto *AT = dyn_cast<ArrayType>(Ty)) + Type *Ty = getType(); + if (auto *AT = dyn_cast<ArrayType>(Ty)) return AT->getNumElements(); - if (const auto *VT = dyn_cast<VectorType>(Ty)) + if (auto *VT = dyn_cast<VectorType>(Ty)) return VT->getNumElements(); return Ty->getStructNumElements(); } @@ -838,10 +838,10 @@ UndefValue *UndefValue::getElementValue(unsigned Idx) const { } unsigned UndefValue::getNumElements() const { - const Type *Ty = getType(); - if (const auto *AT = dyn_cast<ArrayType>(Ty)) + Type *Ty = getType(); + if (auto *AT = dyn_cast<ArrayType>(Ty)) return AT->getNumElements(); - if (const auto *VT = dyn_cast<VectorType>(Ty)) + if (auto *VT = dyn_cast<VectorType>(Ty)) return VT->getNumElements(); return Ty->getStructNumElements(); } @@ -2430,9 +2430,9 @@ StringRef ConstantDataSequential::getRawDataValues() const { /// formed with a vector or array of the specified element type. /// ConstantDataArray only works with normal float and int types that are /// stored densely in memory, not with things like i42 or x86_f80. -bool ConstantDataSequential::isElementTypeCompatible(const Type *Ty) { +bool ConstantDataSequential::isElementTypeCompatible(Type *Ty) { if (Ty->isFloatTy() || Ty->isDoubleTy()) return true; - if (const IntegerType *IT = dyn_cast<IntegerType>(Ty)) { + if (auto *IT = dyn_cast<IntegerType>(Ty)) { switch (IT->getBitWidth()) { case 8: case 16: diff --git a/llvm/lib/IR/Type.cpp b/llvm/lib/IR/Type.cpp index 0891508d7b1..ad0013aed39 100644 --- a/llvm/lib/IR/Type.cpp +++ b/llvm/lib/IR/Type.cpp @@ -74,8 +74,8 @@ bool Type::canLosslesslyBitCastTo(Type *Ty) const { // Vector -> Vector conversions are always lossless if the two vector types // have the same size, otherwise not. Also, 64-bit vector types can be // converted to x86mmx. - if (const VectorType *thisPTy = dyn_cast<VectorType>(this)) { - if (const VectorType *thatPTy = dyn_cast<VectorType>(Ty)) + if (auto *thisPTy = dyn_cast<VectorType>(this)) { + if (auto *thatPTy = dyn_cast<VectorType>(Ty)) return thisPTy->getBitWidth() == thatPTy->getBitWidth(); if (Ty->getTypeID() == Type::X86_MMXTyID && thisPTy->getBitWidth() == 64) @@ -83,7 +83,7 @@ bool Type::canLosslesslyBitCastTo(Type *Ty) const { } if (this->getTypeID() == Type::X86_MMXTyID) - if (const VectorType *thatPTy = dyn_cast<VectorType>(Ty)) + if (auto *thatPTy = dyn_cast<VectorType>(Ty)) if (thatPTy->getBitWidth() == 64) return true; @@ -91,8 +91,8 @@ bool Type::canLosslesslyBitCastTo(Type *Ty) const { // remaining and ptr->ptr. Just select the lossless conversions. Everything // else is not lossless. Conservatively assume we can't losslessly convert // between pointers with different address spaces. - if (const PointerType *PTy = dyn_cast<PointerType>(this)) { - if (const PointerType *OtherPTy = dyn_cast<PointerType>(Ty)) + if (auto *PTy = dyn_cast<PointerType>(this)) { + if (auto *OtherPTy = dyn_cast<PointerType>(Ty)) return PTy->getAddressSpace() == OtherPTy->getAddressSpace(); return false; } @@ -100,14 +100,12 @@ bool Type::canLosslesslyBitCastTo(Type *Ty) const { } bool Type::isEmptyTy() const { - const ArrayType *ATy = dyn_cast<ArrayType>(this); - if (ATy) { + if (auto *ATy = dyn_cast<ArrayType>(this)) { unsigned NumElements = ATy->getNumElements(); return NumElements == 0 || ATy->getElementType()->isEmptyTy(); } - const StructType *STy = dyn_cast<StructType>(this); - if (STy) { + if (auto *STy = dyn_cast<StructType>(this)) { unsigned NumElements = STy->getNumElements(); for (unsigned i = 0; i < NumElements; ++i) if (!STy->getElementType(i)->isEmptyTy()) @@ -144,7 +142,7 @@ unsigned Type::getScalarSizeInBits() const { /// is only valid on floating point types. If the FP type does not /// have a stable mantissa (e.g. ppc long double), this method returns -1. int Type::getFPMantissaWidth() const { - if (const VectorType *VTy = dyn_cast<VectorType>(this)) + if (auto *VTy = dyn_cast<VectorType>(this)) return VTy->getElementType()->getFPMantissaWidth(); assert(isFloatingPointTy() && "Not a floating point type!"); if (getTypeID() == HalfTyID) return 11; @@ -159,11 +157,11 @@ int Type::getFPMantissaWidth() const { /// isSizedDerivedType - Derived types like structures and arrays are sized /// iff all of the members of the type are sized as well. Since asking for /// their size is relatively uncommon, move this operation out of line. -bool Type::isSizedDerivedType(SmallPtrSetImpl<const Type*> *Visited) const { - if (const ArrayType *ATy = dyn_cast<ArrayType>(this)) +bool Type::isSizedDerivedType(SmallPtrSetImpl<Type*> *Visited) const { + if (auto *ATy = dyn_cast<ArrayType>(this)) return ATy->getElementType()->isSized(Visited); - if (const VectorType *VTy = dyn_cast<VectorType>(this)) + if (auto *VTy = dyn_cast<VectorType>(this)) return VTy->getElementType()->isSized(Visited); return cast<StructType>(this)->isSized(Visited); @@ -556,13 +554,13 @@ StructType *StructType::create(StringRef Name, Type *type, ...) { return Ret; } -bool StructType::isSized(SmallPtrSetImpl<const Type*> *Visited) const { +bool StructType::isSized(SmallPtrSetImpl<Type*> *Visited) const { if ((getSubclassData() & SCDB_IsSized) != 0) return true; if (isOpaque()) return false; - if (Visited && !Visited->insert(this).second) + if (Visited && !Visited->insert(const_cast<StructType*>(this)).second) return false; // Okay, our struct is sized if all of the elements are, but if one of the @@ -647,7 +645,7 @@ Type *CompositeType::getTypeAtIndex(unsigned Idx) { return cast<SequentialType>(this)->getElementType(); } bool CompositeType::indexValid(const Value *V) const { - if (const StructType *STy = dyn_cast<StructType>(this)) { + if (auto *STy = dyn_cast<StructType>(this)) { // Structure indexes require (vectors of) 32-bit integer constants. In the // vector case all of the indices must be equal. if (!V->getType()->getScalarType()->isIntegerTy(32)) @@ -664,7 +662,7 @@ bool CompositeType::indexValid(const Value *V) const { } bool CompositeType::indexValid(unsigned Idx) const { - if (const StructType *STy = dyn_cast<StructType>(this)) + if (auto *STy = dyn_cast<StructType>(this)) return Idx < STy->getNumElements(); // Sequential types can be indexed by any integer. return true; diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 7d791acf838..05b7b607023 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -1365,7 +1365,7 @@ void Verifier::VerifyParameterAttrs(AttributeSet Attrs, unsigned Idx, Type *Ty, V); if (PointerType *PTy = dyn_cast<PointerType>(Ty)) { - SmallPtrSet<const Type*, 4> Visited; + SmallPtrSet<Type*, 4> Visited; if (!PTy->getElementType()->isSized(&Visited)) { Assert(!Attrs.hasAttribute(Idx, Attribute::ByVal) && !Attrs.hasAttribute(Idx, Attribute::InAlloca), @@ -1554,7 +1554,7 @@ void Verifier::VerifyStatepoint(ImmutableCallSite CS) { &CI); const Value *Target = CS.getArgument(2); - const PointerType *PT = dyn_cast<PointerType>(Target->getType()); + auto *PT = dyn_cast<PointerType>(Target->getType()); Assert(PT && PT->getElementType()->isFunctionTy(), "gc.statepoint callee must be of function pointer type", &CI, Target); FunctionType *TargetFuncType = cast<FunctionType>(PT->getElementType()); @@ -2674,7 +2674,7 @@ void Verifier::visitStoreInst(StoreInst &SI) { } void Verifier::visitAllocaInst(AllocaInst &AI) { - SmallPtrSet<const Type*, 4> Visited; + SmallPtrSet<Type*, 4> Visited; PointerType *PTy = AI.getType(); Assert(PTy->getAddressSpace() == 0, "Allocation instruction pointer not in the generic address space!", @@ -3469,9 +3469,8 @@ void Verifier::visitIntrinsicCallSite(Intrinsic::ID ID, CallSite CS) { // Assert that result type matches wrapped callee. const Value *Target = StatepointCS.getArgument(2); - const PointerType *PT = cast<PointerType>(Target->getType()); - const FunctionType *TargetFuncType = - cast<FunctionType>(PT->getElementType()); + auto *PT = cast<PointerType>(Target->getType()); + auto *TargetFuncType = cast<FunctionType>(PT->getElementType()); Assert(CS.getType() == TargetFuncType->getReturnType(), "gc.result result type does not match wrapped callee", CS); break; |