Index: test/SemaOpenCL/kernel-attributes-invalid.cl
===================================================================
--- test/SemaOpenCL/kernel-attributes-invalid.cl	(revision 0)
+++ test/SemaOpenCL/kernel-attributes-invalid.cl	(revision 0)
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -verify %s 
+
+kernel __attribute__((vec_type_hint)) void kernel1() {} //expected-error{{'vec_type_hint' attribute requires type parameter}}
+
+kernel __attribute__((vec_type_hint(not_type))) void kernel2() {} //expected-error{{unknown type name 'not_type'}}
+
+kernel __attribute__((vec_type_hint(void))) void kernel3() {} //expected-error{{invalid attribute argument 'void' - expecting a vector or vectorizable scalar type}}
+
+kernel __attribute__((vec_type_hint(bool))) void kernel4() {} //expected-error{{invalid attribute argument 'bool' - expecting a vector or vectorizable scalar type}}
+
+kernel __attribute__((vec_type_hint(int))) __attribute__((vec_type_hint(float))) void kernel5() {} //expected-warning{{attribute 'vec_type_hint' is already applied with different parameters}}
+
+kernel __attribute__((work_group_size_hint(8,16,32,4))) void kernel6() {} //expected-error{{attribute requires exactly 3 arguments}}
+
+kernel __attribute__((work_group_size_hint(1,2,3))) __attribute__((work_group_size_hint(3,2,1))) void kernel7() {}  //expected-warning{{attribute 'work_group_size_hint' is already applied with different parameters}}
+
Index: test/CodeGenOpenCL/kernel-attributes.cl
===================================================================
--- test/CodeGenOpenCL/kernel-attributes.cl	(revision 176552)
+++ test/CodeGenOpenCL/kernel-attributes.cl	(working copy)
@@ -1,12 +1,16 @@
 // RUN: %clang_cc1 -emit-llvm -O0 -o - %s | FileCheck %s
 
-kernel __attribute__((reqd_work_group_size(1,2,4))) void kernel1(int a) {}
+typedef unsigned int uint4 __attribute__((ext_vector_type(4)));
 
-kernel __attribute__((work_group_size_hint(8,16,32))) void kernel2(int a) {}
+kernel  __attribute__((vec_type_hint(int))) __attribute__((reqd_work_group_size(1,2,4))) void kernel1(int a) {}
 
+kernel __attribute__((vec_type_hint(uint4))) __attribute__((work_group_size_hint(8,16,32))) void kernel2(int a) {}
+
 // CHECK: opencl.kernels = !{[[MDNODE0:![0-9]+]], [[MDNODE3:![0-9]+]]}
 
-// CHECK: [[MDNODE0]] = metadata !{void (i32)* @kernel1, metadata [[MDNODE2:![0-9]+]]}
+// CHECK: [[MDNODE0]] = metadata !{void (i32)* @kernel1, metadata [[MDNODE1:![0-9]+]], metadata [[MDNODE2:![0-9]+]]}
+// CHECK: [[MDNODE1]] = metadata !{metadata !"vec_type_hint", i32 undef, i32 1}
 // CHECK: [[MDNODE2]] = metadata !{metadata !"reqd_work_group_size", i32 1, i32 2, i32 4}
-// CHECK: [[MDNODE3]] = metadata !{void (i32)* @kernel2, metadata [[MDNODE5:![0-9]+]]}
+// CHECK: [[MDNODE3]] = metadata !{void (i32)* @kernel2, metadata [[MDNODE4:![0-9]+]], metadata [[MDNODE5:![0-9]+]]}
+// CHECK: [[MDNODE4]] = metadata !{metadata !"vec_type_hint", <4 x i32> undef, i32 0}
 // CHECK: [[MDNODE5]] = metadata !{metadata !"work_group_size_hint", i32 8, i32 16, i32 32}
Index: include/clang/Basic/Attr.td
===================================================================
--- include/clang/Basic/Attr.td	(revision 176552)
+++ include/clang/Basic/Attr.td	(working copy)
@@ -720,8 +720,9 @@
   let ASTNode = 0;
 }
 
-def VecTypeHint : IgnoredAttr {
+def VecTypeHint : InheritableAttr {
   let Spellings = [GNU<"vec_type_hint">];
+  let Args = [TypeArgument<"TypeHint">, SourceLocArgument<"TypeLoc">];
 }
 
 def Visibility : InheritableAttr {
Index: include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- include/clang/Basic/DiagnosticSemaKinds.td	(revision 176552)
+++ include/clang/Basic/DiagnosticSemaKinds.td	(working copy)
@@ -1644,6 +1644,8 @@
   "attribute takes at least %0 argument%s0">;
 def err_attribute_missing_parameter_name : Error<
   "attribute requires unquoted parameter">;
+def err_attribute_requires_type_parameter : Error<
+  "%0 attribute requires type parameter">;
 def err_attribute_invalid_vector_type : Error<"invalid vector element type %0">;
 def err_attribute_bad_neon_vector_size : Error<
   "Neon vector size must be 64 or 128 bits">;
@@ -1672,6 +1674,8 @@
 def err_init_priority_object_attr : Error<
   "can only use 'init_priority' attribute on file-scope definitions "
   "of objects of class type">;
+def err_attribute_argument_vec_type_hint : Error<
+  "invalid attribute argument %0 - expecting a vector or vectorizable scalar type">;
 def err_attribute_argument_n_not_int : Error<
   "'%0' attribute requires parameter %1 to be an integer constant">;
 def err_attribute_argument_n_not_string : Error<
Index: include/clang/Sema/AttributeList.h
===================================================================
--- include/clang/Sema/AttributeList.h	(revision 176552)
+++ include/clang/Sema/AttributeList.h	(working copy)
@@ -17,6 +17,7 @@
 
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/VersionTuple.h"
+#include "clang/AST/Type.h"
 #include "clang/Sema/Ownership.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Allocator.h"
@@ -46,12 +47,18 @@
 
 /// AttributeList - Represents a syntactic attribute.
 ///
-/// For a GNU attribute, there are four forms of this construct:
+/// For a GNU attribute, there are five forms of this construct:
 ///
-/// 1: __attribute__(( const )). ParmName/Args/NumArgs will all be unused.
-/// 2: __attribute__(( mode(byte) )). ParmName used, Args/NumArgs unused.
-/// 3: __attribute__(( format(printf, 1, 2) )). ParmName/Args/NumArgs all used.
-/// 4: __attribute__(( aligned(16) )). ParmName is unused, Args/Num used.
+/// 1: __attribute__(( const )).
+///    ParmName/ParmType/Args/NumArgs unused.
+/// 2: __attribute__(( mode(byte) )).
+///    ParmName used, ParmType/Args/NumArgs unused.
+/// 3: __attribute__(( format(printf, 1, 2) )).
+///    ParmName/Args/NumArgs used, ParmType unused.
+/// 4: __attribute__(( aligned(16) )).
+///    ParmName/ParmType unused, Args/NumArgs used.
+/// 5: __attribute__(( vec_type_hint(int) )).
+///    ParmType used, ParmName/Args/NumArgs unused.
 ///
 class AttributeList { // TODO: This should really be called ParsedAttribute
 public:
@@ -75,6 +82,9 @@
   SourceLocation ParmLoc;
   SourceLocation EllipsisLoc;
 
+  /// The type parameter.
+  QualType ParmType;
+
   /// The number of expression arguments this attribute has.
   /// The expressions themselves are stored after the object.
   unsigned NumArgs : 16;
@@ -189,6 +199,21 @@
     AttrKind = getKind(getName(), getScopeName(), syntaxUsed);
   }
 
+  /// Constructor for attributes with type argument.
+  AttributeList(IdentifierInfo *attrName, SourceRange attrRange,
+                IdentifierInfo *scopeName, SourceLocation scopeLoc,
+                QualType parmType, SourceLocation parmLoc,
+                Syntax syntaxUsed)
+    : AttrName(attrName), ScopeName(scopeName),
+      AttrRange(attrRange), ScopeLoc(scopeLoc),
+      ParmLoc(parmLoc), ParmType(parmType),
+      NumArgs(0), SyntaxUsed(syntaxUsed), Invalid(false),
+      UsedAsTypeAttr(false), IsAvailability(false),
+      NextInPosition(0), NextInPool(0) {
+      AttrKind = getKind(getName(), getScopeName(), syntaxUsed);
+  }
+
+
   /// Constructor for type_tag_for_datatype attribute.
   AttributeList(IdentifierInfo *attrName, SourceRange attrRange,
                 IdentifierInfo *scopeName, SourceLocation scopeLoc,
@@ -230,6 +255,7 @@
   
   IdentifierInfo *getParameterName() const { return ParmName; }
   SourceLocation getParameterLoc() const { return ParmLoc; }
+  QualType getParameterType() const { return ParmType; }
 
   bool isAlignasAttribute() const {
     // FIXME: Use a better mechanism to determine this.
@@ -265,6 +291,9 @@
   /// or has a non empty argument expression list.
   bool hasParameterOrArguments() const { return ParmName || NumArgs; }
 
+  /// hasParameterType - Return true if this attribute has a type parameter.
+  bool hasParameterType() const { return !ParmType.isNull(); }
+
   /// getArg - Return the specified argument.
   Expr *getArg(unsigned Arg) const {
     assert(Arg < NumArgs && "Arg access out of range!");
@@ -492,6 +521,17 @@
                                           unavailable, MessageExpr, syntax));
   }
 
+  AttributeList *create(IdentifierInfo *attrName, SourceRange attrRange,
+                        IdentifierInfo *scopeName, SourceLocation scopeLoc,
+                        QualType parmType, SourceLocation parmLoc,
+                        AttributeList::Syntax syntax) {
+    void *memory = allocate(sizeof(AttributeList));
+    return add(new (memory) AttributeList(attrName, attrRange,
+                                          scopeName, scopeLoc,
+                                          parmType, parmLoc,
+                                          syntax));
+  }
+
   AttributeList *createIntegerAttribute(ASTContext &C, IdentifierInfo *Name,
                                         SourceLocation TokLoc, int Arg);
 
@@ -633,6 +673,17 @@
     return attr;
   }
 
+  AttributeList *addNew(IdentifierInfo *attrName, SourceRange attrRange,
+                        IdentifierInfo *scopeName, SourceLocation scopeLoc,
+                        QualType parmType, SourceLocation parmLoc,
+                        AttributeList::Syntax syntax) {
+    AttributeList *attr =
+      pool.create(attrName, attrRange, scopeName, scopeLoc, parmType, parmLoc,
+                  syntax);
+    add(attr);
+    return attr;
+  }
+
   /// Add type_tag_for_datatype attribute.
   AttributeList *addNewTypeTagForDatatype(
                         IdentifierInfo *attrName, SourceRange attrRange,
Index: lib/Sema/SemaDeclAttr.cpp
===================================================================
--- lib/Sema/SemaDeclAttr.cpp	(revision 176552)
+++ lib/Sema/SemaDeclAttr.cpp	(working copy)
@@ -2769,6 +2769,36 @@
                                        Attr.getAttributeSpellingListIndex()));
 }
 
+static void handleVecTypeHint(Sema &S, Decl *D,
+                              const AttributeList &Attr) {
+  if (!Attr.hasParameterType()) {
+    S.Diag(Attr.getLoc(), diag::err_attribute_requires_type_parameter) <<
+      Attr.getName();
+    return;
+  }
+
+  QualType ParmType = Attr.getParameterType();
+
+  if (!ParmType->isExtVectorType() &&
+      !ParmType->isFloatingType() &&
+      (ParmType->isBooleanType() || !ParmType->isIntegralType(S.getASTContext()))) {
+    S.Diag(Attr.getLoc(), diag::err_attribute_argument_vec_type_hint) << ParmType;
+    return;
+  }
+
+  if (Attr.getKind() == AttributeList::AT_VecTypeHint &&
+    D->hasAttr<VecTypeHintAttr>()) {
+    VecTypeHintAttr *A = D->getAttr<VecTypeHintAttr>();
+    if (A->getTypeHint() != ParmType) {
+      S.Diag(Attr.getLoc(), diag::warn_duplicate_attribute) << Attr.getName();
+      return;
+    }
+  }
+
+  D->addAttr(::new (S.Context) VecTypeHintAttr(Attr.getLoc(), S.Context,
+                                               ParmType, Attr.getLoc()));
+}
+
 SectionAttr *Sema::mergeSectionAttr(Decl *D, SourceRange Range,
                                     StringRef Name,
                                     unsigned AttrSpellingListIndex) {
@@ -4750,6 +4780,9 @@
   case AttributeList::AT_ReqdWorkGroupSize:
     handleWorkGroupSize(S, D, Attr); break;
 
+  case AttributeList::AT_VecTypeHint:
+    handleVecTypeHint(S, D, Attr); break;
+
   case AttributeList::AT_InitPriority: 
       handleInitPriorityAttr(S, D, Attr); break;
       
Index: lib/CodeGen/CodeGenFunction.cpp
===================================================================
--- lib/CodeGen/CodeGenFunction.cpp	(revision 176552)
+++ lib/CodeGen/CodeGenFunction.cpp	(working copy)
@@ -315,6 +315,25 @@
   if (CGM.getCodeGenOpts().EmitOpenCLArgMetadata)
     GenOpenCLArgMetadata(FD, Fn, CGM, Context, kernelMDArgs);
 
+  if (FD->hasAttr<VecTypeHintAttr>()) {
+    llvm::SmallVector <llvm::Value*, 3> attrMDArgs;
+    attrMDArgs.push_back(llvm::MDString::get(Context, "vec_type_hint"));
+
+    VecTypeHintAttr *attr = FD->getAttr<VecTypeHintAttr>();
+    QualType hintQTy = attr->getTypeHint();
+    llvm::Type *hintTy = CGM.getTypes().ConvertType(hintQTy);
+    attrMDArgs.push_back(llvm::UndefValue::get(hintTy));
+
+    const ExtVectorType *hintEltQTy = hintQTy->getAs<ExtVectorType>();
+    bool isSignedInteger = hintQTy->isSignedIntegerType() ||
+       (hintEltQTy && hintEltQTy->getElementType()->isSignedIntegerType());
+    attrMDArgs.push_back(llvm::ConstantInt::get(
+       llvm::IntegerType::get(Context, 32),
+       llvm::APInt(32, (uint64_t) (isSignedInteger?1:0))));
+
+    kernelMDArgs.push_back(llvm::MDNode::get(Context, attrMDArgs));
+  }
+  
   if (FD->hasAttr<WorkGroupSizeHintAttr>()) {
     WorkGroupSizeHintAttr *attr = FD->getAttr<WorkGroupSizeHintAttr>();
     llvm::Value *attrMDArgs[] = {
Index: lib/CodeGen/CodeGenFunction.h
===================================================================
--- lib/CodeGen/CodeGenFunction.h	(revision 176552)
+++ lib/CodeGen/CodeGenFunction.h	(working copy)
@@ -1203,6 +1203,9 @@
   /// Add a kernel metadata node to the named metadata node 'opencl.kernels'.
   /// In the kernel metadata node, reference the kernel function and metadata 
   /// nodes for its optional attribute qualifiers (OpenCL 1.1 6.7.2):
+  /// - A node for the vec_type_hint(<type>) qualifier contains string
+  ///   "vec_type_hint", an undefined value of the <type> data type,
+  ///   and a Boolean that is true if the <type> is integer and signed.
   /// - A node for the work_group_size_hint(X,Y,Z) qualifier contains string 
   ///   "work_group_size_hint", and three 32-bit integers X, Y and Z.
   /// - A node for the reqd_work_group_size(X,Y,Z) qualifier contains string 
Index: lib/Parse/ParseDecl.cpp
===================================================================
--- lib/Parse/ParseDecl.cpp	(revision 176552)
+++ lib/Parse/ParseDecl.cpp	(working copy)
@@ -214,6 +214,10 @@
   SourceLocation ParmLoc;
   bool BuiltinType = false;
 
+  TypeResult T;
+  SourceRange TypeRange;
+  bool TypeParsed = false;
+
   switch (Tok.getKind()) {
   case tok::kw_char:
   case tok::kw_wchar_t:
@@ -232,12 +236,17 @@
   case tok::kw_void:
   case tok::kw_typeof:
     // __attribute__(( vec_type_hint(char) ))
-    // FIXME: Don't just discard the builtin type token.
-    ConsumeToken();
     BuiltinType = true;
+    T = ParseTypeName(&TypeRange);
+    TypeParsed = true;
     break;
 
   case tok::identifier:
+    if (AttrName->isStr("vec_type_hint")) {
+      T = ParseTypeName(&TypeRange);
+      TypeParsed = true;
+      break;
+    }
     ParmName = Tok.getIdentifierInfo();
     ParmLoc = ConsumeToken();
     break;
@@ -247,8 +256,10 @@
   }
 
   ExprVector ArgExprs;
+  bool isInvalid = false;
+  bool isParmType = false;
 
-  if (!BuiltinType &&
+  if (!BuiltinType && !AttrName->isStr("vec_type_hint") &&
       (ParmLoc.isValid() ? Tok.is(tok::comma) : Tok.isNot(tok::r_paren))) {
     // Eat the comma.
     if (ParmLoc.isValid())
@@ -284,16 +295,30 @@
       SkipUntil(tok::r_paren, false, true); // skip until ')'
     }
   }
+  else if (AttrName->isStr("vec_type_hint")) {
+    if (T.get() && !T.isInvalid())
+      isParmType = true;
+    else {
+      if (Tok.is(tok::identifier)) ConsumeToken();
+      if (TypeParsed) isInvalid = true;
+    }
+  }
 
   SourceLocation RParen = Tok.getLocation();
-  if (!ExpectAndConsume(tok::r_paren, diag::err_expected_rparen)) {
+  if (!ExpectAndConsume(tok::r_paren, diag::err_expected_rparen) && !isInvalid) {
     SourceLocation AttrLoc = ScopeLoc.isValid() ? ScopeLoc : AttrNameLoc;
-    AttributeList *attr =
+    if (isParmType) {
+      QualType ParmType = Sema::GetTypeFromParser(T.get());
       Attrs.addNew(AttrName, SourceRange(AttrLoc, RParen),
-                   ScopeName, ScopeLoc, ParmName, ParmLoc,
-                   ArgExprs.data(), ArgExprs.size(), Syntax);
-    if (BuiltinType && attr->getKind() == AttributeList::AT_IBOutletCollection)
-      Diag(Tok, diag::err_iboutletcollection_builtintype);
+                   ScopeName, ScopeLoc, ParmType, ParmLoc, Syntax);
+    } else {
+      AttributeList *attr =
+        Attrs.addNew(AttrName, SourceRange(AttrLoc, RParen),
+                     ScopeName, ScopeLoc, ParmName, ParmLoc,
+                     ArgExprs.data(), ArgExprs.size(), Syntax);
+      if (BuiltinType && attr->getKind() == AttributeList::AT_IBOutletCollection)
+        Diag(Tok, diag::err_iboutletcollection_builtintype);
+    }
   }
 }
 
