summaryrefslogtreecommitdiffstats
path: root/llvm/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
commit065ced9bede6f05bd03afbf9b3180c133e45dfa1 (patch)
treed0ea2e2dbba4369fb5fe70a332a290faee24d82d /llvm/lib/IR
parent107b74c6c36b832924a061db9cc12a8a9428d6a4 (diff)
downloadbcm5719-llvm-065ced9bede6f05bd03afbf9b3180c133e45dfa1.tar.gz
bcm5719-llvm-065ced9bede6f05bd03afbf9b3180c133e45dfa1.zip
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. llvm-svn: 187464
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/Instructions.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 49a9e8c18d2..d88fb6d4e3c 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/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);
OpenPOWER on IntegriCloud