aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-31 07:46:52 +0000
committerChris Lattner <sabre@nondot.org>2009-03-31 07:46:52 +0000
commitd013aa1ee78d8ead93179c179b7c0746e8d97dbb (patch)
tree7c2834d9978a0c1eeacd29c3b82a981db7b3fec9
parentb73e75cfda58c89e6cb196668409daa3c7e45d7f (diff)
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68088 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td2
-rw-r--r--lib/Sema/SemaExpr.cpp10
-rw-r--r--test/CodeGen/ext-vector.c10
-rw-r--r--test/Sema/exprs.c13
4 files changed, 32 insertions, 3 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index bad183df0a..69f18214b8 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -948,6 +948,8 @@ def ext_typecheck_comparison_of_pointer_integer : Warning<
"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">;
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 39d2a50f6d..ca5feb7be0 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -3566,6 +3566,14 @@ QualType Sema::CheckVectorCompareOperands(Expr *&lex, Expr *&rex,
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 @@ QualType Sema::CheckVectorCompareOperands(Expr *&lex, Expr *&rex,
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) &&
diff --git a/test/CodeGen/ext-vector.c b/test/CodeGen/ext-vector.c
index 249142a510..e3b6211ee9 100644
--- a/test/CodeGen/ext-vector.c
+++ b/test/CodeGen/ext-vector.c
@@ -74,14 +74,17 @@ void test6(float4 *ap, float4 *bp, float c) {
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 @@ void test7(int4 *ap, int4 *bp, int c) {
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
}
diff --git a/test/Sema/exprs.c b/test/Sema/exprs.c
index 80334078f1..ae4c37cd46 100644
--- a/test/Sema/exprs.c
+++ b/test/Sema/exprs.c
@@ -91,3 +91,16 @@ void test13(
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);
+}
+