diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index cdf9a58..ca06747 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -4335,6 +4335,16 @@ public:
   child_range children() { return child_range(&SrcExpr, &SrcExpr+1); }
 };
 
+/// DummyTypeExpr - Not a real expression, but a simple container for a type.
+/// Should be used to pass type arguments to attributes, like OpenCL's
+/// vec_type_hint.
+class DummyTypeExpr : public Expr {
+public:
+  DummyTypeExpr(QualType type)
+    : Expr(NoStmtClass, type, VK_RValue, OK_Ordinary,
+           false, false, false, false) {}
+};
+
 /// PseudoObjectExpr - An expression which accesses a pseudo-object
 /// l-value.  A pseudo-object is an abstract object, accesses to which
 /// are translated to calls.  The pseudo-object expression has a
diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td
index 99180e4..ddcb077 100644
--- a/include/clang/Basic/Attr.td
+++ b/include/clang/Basic/Attr.td
@@ -578,6 +578,16 @@ def ReqdWorkGroupSize : InheritableAttr {
               UnsignedArgument<"ZDim">];
 }
 
+def Endian : InheritableAttr {
+  let Spellings = [GNU<"endian">];
+  let Args = [IdentifierArgument<"platform">];
+}
+
+def VecTypeHint : InheritableAttr {
+  let Spellings = [GNU<"vec_type_hint">];
+  let Args = [TypeArgument<"TypeHint">, SourceLocArgument<"TypeLoc">];
+}
+
 def WorkGroupSizeHint :  InheritableAttr {
   let Spellings = [GNU<"work_group_size_hint">];
   let Args = [UnsignedArgument<"XDim">, 
@@ -664,13 +674,6 @@ def VectorSize : Attr {
   let ASTNode = 0;
 }
 
-def VecTypeHint : Attr {
-  let Spellings = [GNU<"vec_type_hint">];
-  let ASTNode = 0;
-  let SemaHandler = 0;
-  let Ignored = 1;
-}
-
 def Visibility : InheritableAttr {
   let Clone = 0;
   let Spellings = [GNU<"visibility">];
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index c0829f3..126ce3d 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1513,6 +1513,8 @@ def err_attribute_argument_outof_range : Error<
 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_invalid_type : 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<
diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h
index e609594..158c1bc 100644
--- a/include/clang/Sema/Sema.h
+++ b/include/clang/Sema/Sema.h
@@ -3139,6 +3139,8 @@ public:
                              SourceLocation BuiltinLoc,
                              SourceLocation RParenLoc);
 
+  ExprResult ActOnDummyTypeExpr(ParsedType ParsedTy);
+
   //===---------------------------- C++ Features --------------------------===//
 
   // Act on C++ namespaces
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index cb10a0d..01c5cc9 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -262,6 +262,25 @@ void CodeGenFunction::EmitOpenCLKernelMetadata(const FunctionDecl *FD,
   llvm::SmallVector <llvm::Value*, 5> kernelMDArgs;
   kernelMDArgs.push_back(Fn);
 
+  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>()) {
     llvm::SmallVector <llvm::Value*, 5> attrMDArgs;
     attrMDArgs.push_back(llvm::MDString::get(Context, "work_group_size_hint"));
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
index 6b4c346..257c9a8 100644
--- a/lib/CodeGen/CodeGenFunction.h
+++ b/lib/CodeGen/CodeGenFunction.h
@@ -1200,6 +1200,9 @@ private:
   /// 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 
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index 7d0f9c2..df0e656 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -199,6 +199,10 @@ void Parser::ParseGNUAttributeArgs(IdentifierInfo *AttrName,
   IdentifierInfo *ParmName = 0;
   SourceLocation ParmLoc;
   bool BuiltinType = false;
+  bool TypeParsed = false;
+
+  TypeResult T;
+  SourceRange TypeRange;
 
   switch (Tok.getKind()) {
   case tok::kw_char:
@@ -218,12 +222,16 @@ void Parser::ParseGNUAttributeArgs(IdentifierInfo *AttrName,
   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;
+    BuiltinType = true; TypeParsed = true;
+    T = ParseTypeName(&TypeRange);
     break;
 
   case tok::identifier:
+    if(AttrName->isStr("vec_type_hint")) {
+      TypeParsed = true;
+      T = ParseTypeName(&TypeRange);
+      break;
+    }
     ParmName = Tok.getIdentifierInfo();
     ParmLoc = ConsumeToken();
     break;
@@ -233,8 +241,9 @@ void Parser::ParseGNUAttributeArgs(IdentifierInfo *AttrName,
   }
 
   ExprVector ArgExprs(Actions);
+  bool isInvalid = 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())
@@ -270,9 +279,24 @@ void Parser::ParseGNUAttributeArgs(IdentifierInfo *AttrName,
       SkipUntil(tok::r_paren, false, true); // skip until ')'
     }
   }
+  else if(AttrName->isStr("vec_type_hint")) {
+    if(T.get() && !T.isInvalid()) {
+      ExprResult ArgExpr = Actions.ActOnDummyTypeExpr(T.get());
+      ArgExprs.push_back(ArgExpr.release());
+    } else {
+      if (Tok.is(tok::identifier)) ConsumeToken();
+      if (TypeParsed) isInvalid = true;
+    }
+
+    if (!Tok.is(tok::r_paren)) {
+      Diag(Tok, diag::err_expected_rparen);
+      ConsumeToken();
+      SkipUntil(tok::r_paren, false, true);
+    }
+  }
 
   SourceLocation RParen = Tok.getLocation();
-  if (!ExpectAndConsume(tok::r_paren, diag::err_expected_rparen)) {
+  if (!ExpectAndConsume(tok::r_paren, diag::err_expected_rparen) && !isInvalid) {
     AttributeList *attr =
       Attrs.addNew(AttrName, SourceRange(AttrNameLoc, RParen), 0, AttrNameLoc,
                    ParmName, ParmLoc, ArgExprs.take(), ArgExprs.size(),
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 65fceaa..e5c46f9 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -2409,6 +2409,35 @@ static void handleWorkGroupSize(Sema &S, Decl *D,
                                        WGSize[0], WGSize[1], WGSize[2]));
 }
 
+static void handleVecTypeHint(Sema &S, Decl *D,
+                              const AttributeList &Attr) {
+  // Attribute has exactly 1 argument.
+  if (!checkAttributeNumArgs(S, Attr, 1)) return;
+
+  QualType QType = Attr.getArg(0)->getType();
+
+  if (!(QType->isExtVectorType() ||
+        QType->isIntegralType(S.getASTContext()) ||
+        QType->isFloatingType()) ||
+       QType->isBooleanType()) {
+    S.Diag(Attr.getLoc(), diag::err_attribute_argument_invalid_type) << QType;
+    return;
+  }
+
+  if (Attr.getKind() == AttributeList::AT_VecTypeHint
+    && D->hasAttr<VecTypeHintAttr>()) {
+      VecTypeHintAttr *A = D->getAttr<VecTypeHintAttr>();
+      if (A->getTypeHint() != QType) {
+        S.Diag(Attr.getLoc(), diag::warn_duplicate_attribute) <<
+          Attr.getName();
+        return;
+      }
+  }
+
+  D->addAttr(::new (S.Context) VecTypeHintAttr(Attr.getLoc(), S.Context,
+                                                     QType, Attr.getLoc()));
+}
+
 SectionAttr *Sema::mergeSectionAttr(Decl *D, SourceRange Range,
                                     StringRef Name) {
   if (SectionAttr *ExistingAttr = D->getAttr<SectionAttr>()) {
@@ -4078,6 +4107,13 @@ static void ProcessInheritableDeclAttr(Sema &S, Scope *scope, Decl *D,
   case AttributeList::AT_ReqdWorkGroupSize:
     handleWorkGroupSize(S, D, Attr); break;
 
+  case AttributeList::AT_VecTypeHint:
+    handleVecTypeHint(S, D, Attr); break;
+
+  case AttributeList::AT_Endian:
+    // Ignored.
+    break;
+
   case AttributeList::AT_InitPriority: 
       handleInitPriorityAttr(S, D, Attr); break;
       
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 07f3c1d..9bc158a 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -3884,6 +3884,11 @@ ExprResult Sema::ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy,
                RParenLoc));
 }
 
+ExprResult Sema::ActOnDummyTypeExpr(ParsedType ParsedTy) {
+  QualType type = GetTypeFromParser(ParsedTy);
+  return Owned(new (Context) DummyTypeExpr(type));
+}
+
 /// BuildResolvedCallExpr - Build a call to a resolved expression,
 /// i.e. an expression not of \p OverloadTy.  The expression should
 /// unary-convert to an expression of function-pointer or
diff --git a/test/CodeGenOpenCL/kernel-attributes.cl b/test/CodeGenOpenCL/kernel-attributes.cl
index 014285f..5503284 100644
--- a/test/CodeGenOpenCL/kernel-attributes.cl
+++ b/test/CodeGenOpenCL/kernel-attributes.cl
@@ -2,13 +2,15 @@
 
 typedef float float4 __attribute__((ext_vector_type(4)));
 
-kernel __attribute__((reqd_work_group_size(1,2,4))) void kernel1(int a) {}
+kernel __attribute__((vec_type_hint(int))) __attribute__((reqd_work_group_size(1,2,4))) void kernel1(int a) {}
 
-kernel __attribute__((work_group_size_hint(8,16,32))) void kernel2(float4 a) {}
+kernel __attribute__((vec_type_hint(float4))) __attribute__((work_group_size_hint(8,16,32))) void kernel2(float4 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 (<4 x float>)* @kernel2, metadata [[MDNODE5:![0-9]+]]}
+// CHECK: [[MDNODE3]] = metadata !{void (<4 x float>)* @kernel2, metadata [[MDNODE4:![0-9]+]], metadata [[MDNODE5:![0-9]+]]}
+// CHECK: [[MDNODE4]] = metadata !{metadata !"vec_type_hint", <4 x float> undef, i32 0}
 // CHECK: [[MDNODE5]] = metadata !{metadata !"work_group_size_hint", i32 8, i32 16, i32 32}
diff --git a/test/SemaOpenCL/kernel-attributes-invalid.cl b/test/SemaOpenCL/kernel-attributes-invalid.cl
index b425a6f..97da6e7 100644
--- a/test/SemaOpenCL/kernel-attributes-invalid.cl
+++ b/test/SemaOpenCL/kernel-attributes-invalid.cl
@@ -1,5 +1,10 @@
 // RUN: %clang_cc1 -verify %s 
 
+kernel __attribute__((vec_type_hint(void))) void kernel1() {} //expected-error{{expecting a vector or vectorizable scalar type}}
+
 kernel __attribute__((work_group_size_hint(8,16,32,4))) void kernel2() {} //expected-error{{attribute requires exactly 3 arguments}}
 
+
+kernel __attribute__((vec_type_hint(int))) __attribute__((vec_type_hint(float))) void kernel3() {} //expected-warning{{attribute 'vec_type_hint' is already applied with different parameters}}
+
 kernel __attribute__((work_group_size_hint(1,2,3))) __attribute__((work_group_size_hint(3,2,1))) void kernel4() {}  //expected-warning{{attribute 'work_group_size_hint' is already applied with different parameters}}
