summaryrefslogtreecommitdiff
path: root/lib/IR
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2013-07-31 00:17:33 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2013-07-31 00:17:33 +0000
commit1bf0ec4e1642a532c0121de8ccc0878d6403c9d3 (patch)
tree4e88f3228fce8e73c2c6e0f62041b7b2c924189a /lib/IR
parent9ce8b2818d0c143fd58f4772d2002a15653079dd (diff)
downloadllvm-1bf0ec4e1642a532c0121de8ccc0878d6403c9d3.tar.gz
llvm-1bf0ec4e1642a532c0121de8ccc0878d6403c9d3.tar.bz2
llvm-1bf0ec4e1642a532c0121de8ccc0878d6403c9d3.tar.xz
Fix ptr vector inconsistency in CreatePointerCast
One form would accept a vector of pointers, and the other did not. Make both accept vectors of pointers, and add an assertion for the number of elements. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187464 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR')
-rw-r--r--lib/IR/Instructions.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/IR/Instructions.cpp b/lib/IR/Instructions.cpp
index 49a9e8c18d..d88fb6d4e3 100644
--- a/lib/IR/Instructions.cpp
+++ b/lib/IR/Instructions.cpp
@@ -2415,22 +2415,30 @@ CastInst *CastInst::CreateTruncOrBitCast(Value *S, Type *Ty,
CastInst *CastInst::CreatePointerCast(Value *S, Type *Ty,
const Twine &Name,
BasicBlock *InsertAtEnd) {
- assert(S->getType()->isPointerTy() && "Invalid cast");
- assert((Ty->isIntegerTy() || Ty->isPointerTy()) &&
+ assert(S->getType()->isPtrOrPtrVectorTy() && "Invalid cast");
+ assert((Ty->isIntOrIntVectorTy() || Ty->isPtrOrPtrVectorTy()) &&
+ "Invalid cast");
+ assert(Ty->isVectorTy() == S->getType()->isVectorTy() && "Invalid cast");
+ assert(!Ty->isVectorTy() ||
+ Ty->getVectorNumElements() == S->getType()->getVectorNumElements() &&
"Invalid cast");
- if (Ty->isIntegerTy())
+ if (Ty->isIntOrIntVectorTy())
return Create(Instruction::PtrToInt, S, Ty, Name, InsertAtEnd);
return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
}
/// @brief Create a BitCast or a PtrToInt cast instruction
-CastInst *CastInst::CreatePointerCast(Value *S, Type *Ty,
- const Twine &Name,
+CastInst *CastInst::CreatePointerCast(Value *S, Type *Ty,
+ const Twine &Name,
Instruction *InsertBefore) {
assert(S->getType()->isPtrOrPtrVectorTy() && "Invalid cast");
assert((Ty->isIntOrIntVectorTy() || Ty->isPtrOrPtrVectorTy()) &&
"Invalid cast");
+ assert(Ty->isVectorTy() == S->getType()->isVectorTy() && "Invalid cast");
+ assert(!Ty->isVectorTy() ||
+ Ty->getVectorNumElements() == S->getType()->getVectorNumElements() &&
+ "Invalid cast");
if (Ty->isIntOrIntVectorTy())
return Create(Instruction::PtrToInt, S, Ty, Name, InsertBefore);