diff options
| author | Peter Collingbourne <peter@pcc.me.uk> | 2016-11-13 06:58:45 +0000 |
|---|---|---|
| committer | Peter Collingbourne <peter@pcc.me.uk> | 2016-11-13 06:58:45 +0000 |
| commit | 9d5fd4db814e661ff7acf3a9d473e9d72b5f4d93 (patch) | |
| tree | 40ebdafdb6f3e6697d4d1cb2c8a4dc2f85164c8c | |
| parent | 0528a31ddf430bdeb1711ba930b6d530f78af3ad (diff) | |
| download | bcm5719-llvm-9d5fd4db814e661ff7acf3a9d473e9d72b5f4d93.tar.gz bcm5719-llvm-9d5fd4db814e661ff7acf3a9d473e9d72b5f4d93.zip | |
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
| -rw-r--r-- | llvm/include/llvm/IR/Type.h | 15 | ||||
| -rw-r--r-- | llvm/lib/IR/Instructions.cpp | 3 |
2 files changed, 14 insertions, 4 deletions
diff --git a/llvm/include/llvm/IR/Type.h b/llvm/include/llvm/IR/Type.h index 52ef5605f7d..4e2ef5301f5 100644 --- a/llvm/include/llvm/IR/Type.h +++ b/llvm/include/llvm/IR/Type.h @@ -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; diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp index dcd0feb43cb..693879be181 100644 --- a/llvm/lib/IR/Instructions.cpp +++ b/llvm/lib/IR/Instructions.cpp @@ -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; |

