diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2014-01-22 19:21:33 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2014-01-22 19:21:33 +0000 |
commit | fc3c91d0cbd7be7346834e47cf4a00d178cd114b (patch) | |
tree | e98bdff7343b6ebaecc70cf75ecbfc7e4c467719 /llvm/unittests/IR/InstructionsTest.cpp | |
parent | dad963039874d88f0adc6889b64283fe5d1c94c6 (diff) | |
download | bcm5719-llvm-fc3c91d0cbd7be7346834e47cf4a00d178cd114b.tar.gz bcm5719-llvm-fc3c91d0cbd7be7346834e47cf4a00d178cd114b.zip |
Bug 18228 - Fix accepting bitcasts between vectors of pointers with a
different number of elements.
Bitcasts were passing with vectors of pointers with different number of
elements since the number of elements was checking
SrcTy->getVectorNumElements() == SrcTy->getVectorNumElements() which
isn't helpful. The addrspacecast was also wrong, but that case at least
is caught by the verifier. Refactor bitcast and addrspacecast handling
in castIsValid to be more readable and fix this problem.
llvm-svn: 199821
Diffstat (limited to 'llvm/unittests/IR/InstructionsTest.cpp')
-rw-r--r-- | llvm/unittests/IR/InstructionsTest.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/unittests/IR/InstructionsTest.cpp b/llvm/unittests/IR/InstructionsTest.cpp index 0ae236cb3cc..cbdf18c6468 100644 --- a/llvm/unittests/IR/InstructionsTest.cpp +++ b/llvm/unittests/IR/InstructionsTest.cpp @@ -145,6 +145,7 @@ TEST(InstructionsTest, CastInst) { Type *V2Int64PtrTy = VectorType::get(Int64PtrTy, 2); Type *V2Int32PtrTy = VectorType::get(Int32PtrTy, 2); + Type *V4Int32PtrTy = VectorType::get(Int32PtrTy, 4); const Constant* c8 = Constant::getNullValue(V8x8Ty); const Constant* c64 = Constant::getNullValue(V8x64Ty); @@ -205,6 +206,21 @@ TEST(InstructionsTest, CastInst) { EXPECT_FALSE(CastInst::isBitCastable(V2Int64Ty, V2Int32Ty)); + EXPECT_FALSE(CastInst::castIsValid(Instruction::BitCast, + Constant::getNullValue(V4Int32PtrTy), + V2Int32PtrTy)); + EXPECT_FALSE(CastInst::castIsValid(Instruction::BitCast, + Constant::getNullValue(V2Int32PtrTy), + V4Int32PtrTy)); + + EXPECT_FALSE(CastInst::castIsValid(Instruction::AddrSpaceCast, + Constant::getNullValue(V4Int32PtrAS1Ty), + V2Int32PtrTy)); + EXPECT_FALSE(CastInst::castIsValid(Instruction::AddrSpaceCast, + Constant::getNullValue(V2Int32PtrTy), + V4Int32PtrAS1Ty)); + + // Check that assertion is not hit when creating a cast with a vector of // pointers // First form |