AlexeySachkov updated this revision to Diff 169851.
AlexeySachkov added a comment.

Added test


https://reviews.llvm.org/D53200

Files:
  lib/Serialization/ASTWriter.cpp
  test/Headers/opencl-pragma-extension-begin.cl
  test/Headers/opencl-pragma-extension-begin.h


Index: test/Headers/opencl-pragma-extension-begin.h
===================================================================
--- /dev/null
+++ test/Headers/opencl-pragma-extension-begin.h
@@ -0,0 +1,4 @@
+
+#pragma OPENCL EXTENSION cl_my_ext : begin
+void cl_my_ext_foo();
+#pragma OPENCL EXTENSION cl_my_ext : end
Index: test/Headers/opencl-pragma-extension-begin.cl
===================================================================
--- /dev/null
+++ test/Headers/opencl-pragma-extension-begin.cl
@@ -0,0 +1,13 @@
+// RUN: rm -rf %t.ocl.pragma.ext.begin
+// RUN: mkdir -p %t.ocl.pragma.ext.begin
+//
+// RUN: %clang_cc1 -cl-std=CL1.2 -include %S/opencl-pragma-extension-begin.h 
-triple spir-unknown-unknown -O0 -emit-llvm -o - -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t.ocl.pragma.ext.begin %s 2>&1
+//
+// RUN: rm -rf %t.ocl.pragma.ext.begin
+// RUN: mkdir -p %t.ocl.pragma.ext.begin
+//
+// RUN: %clang_cc1 -cl-std=CL2.0 -include %S/opencl-pragma-extension-begin.h 
-triple spir-unknown-unknown -O0 -emit-llvm -o - -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t.ocl.pragma.ext.begin %s 2>&1
+
+void __kernel test(__global int *data) {
+  *data = 10;
+}
Index: lib/Serialization/ASTWriter.cpp
===================================================================
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -5014,13 +5014,16 @@
   WriteFPPragmaOptions(SemaRef.getFPOptions());
   WriteOpenCLExtensions(SemaRef);
   WriteOpenCLExtensionTypes(SemaRef);
-  WriteOpenCLExtensionDecls(SemaRef);
   WriteCUDAPragmas(SemaRef);
 
   // If we're emitting a module, write out the submodule information.
   if (WritingModule)
     WriteSubmodules(WritingModule);
 
+  // We need to have information about submodules to correctly deserialize
+  // decls from OpenCLExtensionDecls block
+  WriteOpenCLExtensionDecls(SemaRef);
+
   Stream.EmitRecord(SPECIAL_TYPES, SpecialTypes);
 
   // Write the record containing external, unnamed definitions.


Index: test/Headers/opencl-pragma-extension-begin.h
===================================================================
--- /dev/null
+++ test/Headers/opencl-pragma-extension-begin.h
@@ -0,0 +1,4 @@
+
+#pragma OPENCL EXTENSION cl_my_ext : begin
+void cl_my_ext_foo();
+#pragma OPENCL EXTENSION cl_my_ext : end
Index: test/Headers/opencl-pragma-extension-begin.cl
===================================================================
--- /dev/null
+++ test/Headers/opencl-pragma-extension-begin.cl
@@ -0,0 +1,13 @@
+// RUN: rm -rf %t.ocl.pragma.ext.begin
+// RUN: mkdir -p %t.ocl.pragma.ext.begin
+//
+// RUN: %clang_cc1 -cl-std=CL1.2 -include %S/opencl-pragma-extension-begin.h -triple spir-unknown-unknown -O0 -emit-llvm -o - -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.ocl.pragma.ext.begin %s 2>&1
+//
+// RUN: rm -rf %t.ocl.pragma.ext.begin
+// RUN: mkdir -p %t.ocl.pragma.ext.begin
+//
+// RUN: %clang_cc1 -cl-std=CL2.0 -include %S/opencl-pragma-extension-begin.h -triple spir-unknown-unknown -O0 -emit-llvm -o - -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.ocl.pragma.ext.begin %s 2>&1
+
+void __kernel test(__global int *data) {
+  *data = 10;
+}
Index: lib/Serialization/ASTWriter.cpp
===================================================================
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -5014,13 +5014,16 @@
   WriteFPPragmaOptions(SemaRef.getFPOptions());
   WriteOpenCLExtensions(SemaRef);
   WriteOpenCLExtensionTypes(SemaRef);
-  WriteOpenCLExtensionDecls(SemaRef);
   WriteCUDAPragmas(SemaRef);
 
   // If we're emitting a module, write out the submodule information.
   if (WritingModule)
     WriteSubmodules(WritingModule);
 
+  // We need to have information about submodules to correctly deserialize
+  // decls from OpenCLExtensionDecls block
+  WriteOpenCLExtensionDecls(SemaRef);
+
   Stream.EmitRecord(SPECIAL_TYPES, SpecialTypes);
 
   // Write the record containing external, unnamed definitions.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to