summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2009-01-07 23:44:27 +0000
committerBob Wilson <bob.wilson@apple.com>2009-01-07 23:44:27 +0000
commite8a299e90e555f757ea8adc0da1b0b377db63a17 (patch)
tree6d001383ae159d576992332941a58b78c7a5a1f2
parent8157cb9ef6895e8ef5931b31b5c73b0f70b5726f (diff)
downloadbcm5719-llvm-e8a299e90e555f757ea8adc0da1b0b377db63a17.tar.gz
bcm5719-llvm-e8a299e90e555f757ea8adc0da1b0b377db63a17.zip
Assert that VectorType::getTruncatedElementVectorType is not used with
odd bit-width vector elements. Add a check in the verifier for this also. llvm-svn: 61899
-rw-r--r--llvm/include/llvm/DerivedTypes.h2
-rw-r--r--llvm/lib/VMCore/Verifier.cpp14
2 files changed, 12 insertions, 4 deletions
diff --git a/llvm/include/llvm/DerivedTypes.h b/llvm/include/llvm/DerivedTypes.h
index 3bc00e9bb25..24681a51f84 100644
--- a/llvm/include/llvm/DerivedTypes.h
+++ b/llvm/include/llvm/DerivedTypes.h
@@ -385,6 +385,8 @@ public:
///
static VectorType *getTruncatedElementVectorType(const VectorType *VTy) {
unsigned EltBits = VTy->getElementType()->getPrimitiveSizeInBits();
+ assert((EltBits & 1) == 0 &&
+ "Cannot truncate vector element with odd bit-width");
const Type *EltTy = IntegerType::get(EltBits / 2);
return VectorType::get(EltTy, VTy->getNumElements());
}
diff --git a/llvm/lib/VMCore/Verifier.cpp b/llvm/lib/VMCore/Verifier.cpp
index 4a7915430ee..f9ad41b2c42 100644
--- a/llvm/lib/VMCore/Verifier.cpp
+++ b/llvm/lib/VMCore/Verifier.cpp
@@ -1395,16 +1395,22 @@ bool Verifier::PerformTypeCheck(Intrinsic::ID ID, Function *F, const Type *Ty,
// type.
if ((Match & (ExtendedElementVectorType |
TruncatedElementVectorType)) != 0) {
- if (!VTy) {
+ const IntegerType *IEltTy = dyn_cast<IntegerType>(EltTy);
+ if (!VTy || !IEltTy) {
CheckFailed("Intrinsic parameter #" + utostr(ArgNo - 1) + " is not "
- "a vector type.", F);
+ "an integral vector type.", F);
return false;
}
// Adjust the current Ty (in the opposite direction) rather than
// the type being matched against.
- if ((Match & ExtendedElementVectorType) != 0)
+ if ((Match & ExtendedElementVectorType) != 0) {
+ if ((IEltTy->getBitWidth() & 1) != 0) {
+ CheckFailed("Intrinsic parameter #" + utostr(ArgNo - 1) + " vector "
+ "element bit-width is odd.", F);
+ return false;
+ }
Ty = VectorType::getTruncatedElementVectorType(VTy);
- else
+ } else
Ty = VectorType::getExtendedElementVectorType(VTy);
Match &= ~(ExtendedElementVectorType | TruncatedElementVectorType);
}
OpenPOWER on IntegriCloud