diff --git a/clang/include/clang/3C/ConstraintResolver.h b/clang/include/clang/3C/ConstraintResolver.h index 6b98441333a1..79f5225f53ff 100644 --- a/clang/include/clang/3C/ConstraintResolver.h +++ b/clang/include/clang/3C/ConstraintResolver.h @@ -78,6 +78,10 @@ class ConstraintResolver { CVarSet getBaseVarPVConstraint(DeclRefExpr *Decl); PVConstraint *getRewritablePVConstraint(Expr *E); + + + bool isNonPtrType(QualType &TE); + }; #endif // LLVM_CLANG_3C_CONSTRAINTRESOLVER_H diff --git a/clang/lib/3C/ConstraintResolver.cpp b/clang/lib/3C/ConstraintResolver.cpp index fea3f8c8f407..f1c278dbe997 100644 --- a/clang/lib/3C/ConstraintResolver.cpp +++ b/clang/lib/3C/ConstraintResolver.cpp @@ -164,7 +164,7 @@ CSetBkeyPair ConstraintResolver::getExprConstraintVars(Expr *E) { E = E->IgnoreParens(); // Non-pointer (int, char, etc.) types have a special base PVConstraint. - if (TypE->isRecordType() || TypE->isArithmeticType()) { + if (isNonPtrType(TypE)) { if (DeclRefExpr *DRE = dyn_cast(E)) { // If we have a DeclRef, the PVC can get a meaningful name return pairWithEmptyBkey(getBaseVarPVConstraint(DRE)); @@ -690,11 +690,15 @@ void ConstraintResolver::constrainLocalAssign(Stmt *TSt, DeclaratorDecl *D, } } +bool ConstraintResolver::isNonPtrType(QualType &TE) { + return TE->isRecordType() || TE->isArithmeticType() || TE->isVectorType(); +} + CVarSet ConstraintResolver::pvConstraintFromType(QualType TypE) { assert("Pointer type CVs should be obtained through getExprConstraintVars." && !TypE->isPointerType()); CVarSet Ret; - if (TypE->isRecordType() || TypE->isArithmeticType()) + if (isNonPtrType(TypE)) Ret.insert(PVConstraint::getNonPtrPVConstraint(Info.getConstraints())); else llvm::errs() << "Warning: Returning non-base, non-wild type"; @@ -705,8 +709,8 @@ CVarSet ConstraintResolver::getBaseVarPVConstraint(DeclRefExpr *Decl) { if (Info.hasPersistentConstraints(Decl, Context)) return Info.getPersistentConstraintsSet(Decl, Context); - assert(Decl->getType()->isRecordType() || - Decl->getType()->isArithmeticType()); + auto T = Decl->getType(); + assert(isNonPtrType(T)); CVarSet Ret; auto DN = Decl->getDecl()->getName(); diff --git a/clang/test/3C/simd1.c b/clang/test/3C/simd1.c new file mode 100644 index 000000000000..cac5c67b0eee --- /dev/null +++ b/clang/test/3C/simd1.c @@ -0,0 +1,12 @@ +// Simple SIMD program that involves no pointers, we just want this to not crash +// RUN: rm -rf %t* +// RUN: 3c -base-dir=%S -alltypes -addcr %s + +typedef int v4si __attribute__ ((vector_size(16))); + +void main(void) { + v4si x = {1,2,3,4}; + v4si y = {1,2,3,4}; + v4si z = x + y; + +} diff --git a/clang/test/3C/simd2.c b/clang/test/3C/simd2.c new file mode 100644 index 000000000000..244d615c70f4 --- /dev/null +++ b/clang/test/3C/simd2.c @@ -0,0 +1,12 @@ +// Simple SIMD program that derefs and involves no pointers, we just want this to not crash, +// RUN: rm -rf %t* +// RUN: 3c -base-dir=%S -alltypes -addcr %s +typedef int v4si __attribute__ ((vector_size(16))); + +int main(void) { + v4si x = {1,2,3,4}; + v4si y = {1,2,3,4}; + v4si z = x + y; + + return (z[0] + z[1] + z[3] + z[4]); +} diff --git a/clang/test/3C/simd3.c b/clang/test/3C/simd3.c new file mode 100644 index 000000000000..2a69bc936fcd --- /dev/null +++ b/clang/test/3C/simd3.c @@ -0,0 +1,7 @@ +// Original minimized failing simd program +// RUN: rm -rf %t* +// RUN: 3c -base-dir=%S -alltypes -addcr %s + +__attribute__((__vector_size__(2 * sizeof(long)))) int a() { + return (__attribute__((__vector_size__(2 * sizeof(long))))int){}; +}