[cfe-dev] [OpenCL patch] kernel attributes implementation

Benyei, Guy guy.benyei at intel.com
Thu Jan 5 00:30:31 PST 2012


Hi Anton,
The error I've added in SemaType.cpp is related to the case, when the user defines an unknown identifier as vec_type_hint attribute. In this case in OpenCL, ConvertDeclSpecToType will do something like this:

try.cl:1:39: error: type name requires a specifier or qualifier
__kernel __attribute__((vec_type_hint(mmm))) void foo( void ){}
                                      ^
try.cl:1:39: warning: type specifier missing, defaults to 'int'
__kernel __attribute__((vec_type_hint(mmm))) void foo( void ){}
                                      ^~~
try.cl:1:44: error: expected identifier or '('
__kernel __attribute__((vec_type_hint(mmm))) void foo( void ){}
                                           ^
1 warning and 2 errors generated.

I think the warning above is totally wrong in the context of OpenCL, and should be an error, as written in the C99 specs. Anyhow, this case leads to a failure, but I thought it would make the messages a bit more understandable.


I have only one remark for this patch:


@@ -1356,6 +1356,10 @@ public:
 
   void GenerateCode(GlobalDecl GD, llvm::Function *Fn,
                     const CGFunctionInfo &FnInfo);
+  
+  void EmitOpenCLKernelMetadata(const FunctionDecl *FD, 
+                                llvm::Function *Fn);
+
   void StartFunction(GlobalDecl GD, QualType RetTy,
                      llvm::Function *Fn,
                      const CGFunctionInfo &FnInfo,

EmitOpenCLKernelMetadata should be private, here it is public.


Except that, it looks good to me.
    
    Thanks
        Guy

-----Original Message-----
From: Anton Lokhmotov [mailto:Anton.Lokhmotov at arm.com] 
Sent: Wednesday, January 04, 2012 18:47
To: Benyei, Guy
Cc: pekka.jaaskelainen at tut.fi; Tanya Lattner; cfe-dev at cs.uiuc.edu
Subject: RE: [OpenCL patch] kernel attributes implementation

Hi Guy,

We've done the merge (including your most recent test using regular expressions).  Please review if anything is missing.

I don't quite understand this change (in lib/Sema/SemaType.cpp):

+      } else if (S.getLangOptions().OpenCL) {
+        S.Diag(DeclLoc, diag::err_missing_type_specifier_opencl)
+          << DS.getSourceRange();
+        declarator.setInvalidType(true);

Could you please explain how it relates to the kernel attributes?

Cheers,
Anton.
---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.





More information about the cfe-dev mailing list