[llvm-commits] [llvm] r61899 - in /llvm/trunk: include/llvm/DerivedTypes.h lib/VMCore/Verifier.cpp

Bob Wilson bob.wilson at apple.com
Wed Jan 7 15:44:28 PST 2009


Author: bwilson
Date: Wed Jan  7 17:44:27 2009
New Revision: 61899

URL: http://llvm.org/viewvc/llvm-project?rev=61899&view=rev
Log:
Assert that VectorType::getTruncatedElementVectorType is not used with
odd bit-width vector elements.  Add a check in the verifier for this also.

Modified:
    llvm/trunk/include/llvm/DerivedTypes.h
    llvm/trunk/lib/VMCore/Verifier.cpp

Modified: llvm/trunk/include/llvm/DerivedTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DerivedTypes.h?rev=61899&r1=61898&r2=61899&view=diff

==============================================================================
--- llvm/trunk/include/llvm/DerivedTypes.h (original)
+++ llvm/trunk/include/llvm/DerivedTypes.h Wed Jan  7 17:44:27 2009
@@ -385,6 +385,8 @@
   ///
   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());
   }

Modified: llvm/trunk/lib/VMCore/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=61899&r1=61898&r2=61899&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Verifier.cpp (original)
+++ llvm/trunk/lib/VMCore/Verifier.cpp Wed Jan  7 17:44:27 2009
@@ -1395,16 +1395,22 @@
     // 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);
     }





More information about the llvm-commits mailing list