[cfe-commits] r68088 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/CodeGen/ext-vector.c test/Sema/exprs.c

Chris Lattner sabre at nondot.org
Tue Mar 31 00:46:54 PDT 2009


Author: lattner
Date: Tue Mar 31 02:46:52 2009
New Revision: 68088

URL: http://llvm.org/viewvc/llvm-project?rev=68088&view=rev
Log:
Codegen sometimes crashes on comparisons that aren't legal, just
disable this feature for now, to err on the side of rejecting instead
of sometimes crashing.  rdar://6326239

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/CodeGen/ext-vector.c
    cfe/trunk/test/Sema/exprs.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=68088&r1=68087&r2=68088&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Mar 31 02:46:52 2009
@@ -948,6 +948,8 @@
   "comparison between pointer and integer (%0 and %1)">;
 def ext_typecheck_comparison_of_distinct_pointers : Warning<
   "comparison of distinct pointer types (%0 and %1)">;
+def err_typecheck_vector_comparison : Error<
+  "comparison of vector types (%0 and %1) not supported yet">;
 def err_typecheck_assign_const : Error<"read-only variable is not assignable">;
 def err_stmtexpr_file_scope : Error<
   "statement expression not allowed at file scope">;

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=68088&r1=68087&r2=68088&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Mar 31 02:46:52 2009
@@ -3566,6 +3566,14 @@
     CheckFloatComparison(Loc,lex,rex);
   }
 
+  // FIXME: Vector compare support in the LLVM backend is not fully reliable,
+  // just reject all vector comparisons for now.
+  if (1) {
+    Diag(Loc, diag::err_typecheck_vector_comparison)
+      << lType << rType << lex->getSourceRange() << rex->getSourceRange();
+    return QualType();
+  }
+
   // Return the type for the comparison, which is the same as vector type for
   // integer vectors, or an integer type of identical size and number of
   // elements for floating point vectors.
@@ -3576,7 +3584,7 @@
   unsigned TypeSize = Context.getTypeSize(VTy->getElementType());
   if (TypeSize == Context.getTypeSize(Context.IntTy))
     return Context.getExtVectorType(Context.IntTy, VTy->getNumElements());
-  else if (TypeSize == Context.getTypeSize(Context.LongTy))
+  if (TypeSize == Context.getTypeSize(Context.LongTy))
     return Context.getExtVectorType(Context.LongTy, VTy->getNumElements());
 
   assert(TypeSize == Context.getTypeSize(Context.LongLongTy) &&

Modified: cfe/trunk/test/CodeGen/ext-vector.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ext-vector.c?rev=68088&r1=68087&r2=68088&view=diff

==============================================================================
--- cfe/trunk/test/CodeGen/ext-vector.c (original)
+++ cfe/trunk/test/CodeGen/ext-vector.c Tue Mar 31 02:46:52 2009
@@ -74,14 +74,17 @@
   a *= c;
   a /= c;
 
+  // Vector comparisons can sometimes crash the x86 backend: rdar://6326239,
+  // reject them until the implementation is stable.
+#if 0
   int4 cmp;
-
   cmp = a < b;
   cmp = a <= b;
   cmp = a < b;
   cmp = a >= b;
   cmp = a == b;
   cmp = a != b;
+#endif
 }
 
 void test7(int4 *ap, int4 *bp, int c) {
@@ -112,12 +115,15 @@
   a /= c;
   a %= c;
 
+  // Vector comparisons can sometimes crash the x86 backend: rdar://6326239,
+  // reject them until the implementation is stable.
+#if 0
   int4 cmp;
-
   cmp = a < b;
   cmp = a <= b;
   cmp = a < b;
   cmp = a >= b;
   cmp = a == b;
   cmp = a != b;
+#endif
 }

Modified: cfe/trunk/test/Sema/exprs.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/exprs.c?rev=68088&r1=68087&r2=68088&view=diff

==============================================================================
--- cfe/trunk/test/Sema/exprs.c (original)
+++ cfe/trunk/test/Sema/exprs.c Tue Mar 31 02:46:52 2009
@@ -91,3 +91,16 @@
   P();
   P = ^(){}; // expected-error {{blocks support disabled - compile with -fblocks}}
 }
+
+
+// rdar://6326239 - Vector comparisons are not fully trusted yet, until the
+// backend is known to work, just unconditionally reject them.
+void test14() {
+  typedef long long __m64 __attribute__((__vector_size__(8))); // expected-warning {{extension used}}
+  typedef short __v4hi __attribute__((__vector_size__(8))); // expected-warning {{extension used}}
+
+  __v4hi a;
+  __m64 mask = (__m64)((__v4hi)a >  // expected-error {{comparison of vector types ('__v4hi' and '__v4hi') not supported yet}}
+                      (__v4hi)a);
+}
+





More information about the cfe-commits mailing list