1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

IR: Change the Type::get{Array,Vector,Pointer}ElementType() functions to perform the correct type assertion.

Previously we were only asserting that the type was a sequential type.

llvm-svn: 286749
This commit is contained in:
Peter Collingbourne 2016-11-13 06:58:45 +00:00
parent 9ac74a90b3
commit 4667da9b99
2 changed files with 14 additions and 4 deletions

View File

@ -344,12 +344,21 @@ public:
}
inline uint64_t getArrayNumElements() const;
Type *getArrayElementType() const { return getSequentialElementType(); }
Type *getArrayElementType() const {
assert(getTypeID() == ArrayTyID);
return ContainedTys[0];
}
inline unsigned getVectorNumElements() const;
Type *getVectorElementType() const { return getSequentialElementType(); }
Type *getVectorElementType() const {
assert(getTypeID() == VectorTyID);
return ContainedTys[0];
}
Type *getPointerElementType() const { return getSequentialElementType(); }
Type *getPointerElementType() const {
assert(getTypeID() == PointerTyID);
return ContainedTys[0];
}
/// Get the address space of this pointer or pointer vector type.
inline unsigned getPointerAddressSpace() const;

View File

@ -2550,7 +2550,8 @@ unsigned CastInst::isEliminableCastPair(
case 14:
// bitcast, addrspacecast -> addrspacecast if the element type of
// bitcast's source is the same as that of addrspacecast's destination.
if (SrcTy->getPointerElementType() == DstTy->getPointerElementType())
if (SrcTy->getScalarType()->getPointerElementType() ==
DstTy->getScalarType()->getPointerElementType())
return Instruction::AddrSpaceCast;
return 0;