r275318 - [OpenCL] Fixes failures in test/Driver/opencl.cl.

Yaxun Liu via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 13 14:21:05 PDT 2016


Author: yaxunl
Date: Wed Jul 13 16:21:05 2016
New Revision: 275318

URL: http://llvm.org/viewvc/llvm-project?rev=275318&view=rev
Log:
[OpenCL] Fixes failures in test/Driver/opencl.cl.

Also fixes strict-aliasing option to only be allowed when OpenCL Version 1.0. Added testcase in test/Frontend/opencl-blocks.cl.

Patch by Aaron En Ye Shi.

Differential Revision: http://reviews.llvm.org/D22170

Added:
    cfe/trunk/test/Frontend/opencl.cl
Removed:
    cfe/trunk/test/Frontend/opencl-blocks.cl
Modified:
    cfe/trunk/lib/Frontend/CompilerInvocation.cpp
    cfe/trunk/test/Driver/opencl.cl

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=275318&r1=275317&r2=275318&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Jul 13 16:21:05 2016
@@ -1674,23 +1674,23 @@ static void ParseLangArgs(LangOptions &O
       LangStd = OpenCLLangStd;
   }
 
-  // -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0.
-  // This option should be deprecated for CL > 1.0 because
-  // this option was added for compatibility with OpenCL 1.0.
-  if (const Arg *A = Args.getLastArg(OPT_cl_strict_aliasing))
-    if (Opts.OpenCLVersion > 100) {
-      std::string VerSpec = llvm::to_string(Opts.OpenCLVersion / 100) +
-                            std::string (".") +
-                            llvm::to_string((Opts.OpenCLVersion % 100) / 10);
-      Diags.Report(diag::warn_option_invalid_ocl_version)
-      << VerSpec << A->getAsString(Args);
-    }
-
   Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header);
 
   llvm::Triple T(TargetOpts.Triple);
   CompilerInvocation::setLangDefaults(Opts, IK, T, PPOpts, LangStd);
 
+  // -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0.
+  // This option should be deprecated for CL > 1.0 because
+  // this option was added for compatibility with OpenCL 1.0.
+  if (Args.getLastArg(OPT_cl_strict_aliasing)
+       && Opts.OpenCLVersion > 100) {
+    std::string VerSpec = llvm::to_string(Opts.OpenCLVersion / 100) +
+                          std::string(".") +
+                          llvm::to_string((Opts.OpenCLVersion % 100) / 10);
+    Diags.Report(diag::warn_option_invalid_ocl_version)
+      << VerSpec << Args.getLastArg(OPT_cl_strict_aliasing)->getAsString(Args);
+  }
+
   // We abuse '-f[no-]gnu-keywords' to force overriding all GNU-extension
   // keywords. This behavior is provided by GCC's poorly named '-fasm' flag,
   // while a subset (the non-C++ GNU keywords) is provided by GCC's

Modified: cfe/trunk/test/Driver/opencl.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/opencl.cl?rev=275318&r1=275317&r2=275318&view=diff
==============================================================================
--- cfe/trunk/test/Driver/opencl.cl (original)
+++ cfe/trunk/test/Driver/opencl.cl Wed Jul 13 16:21:05 2016
@@ -1,42 +1,35 @@
-// XFAIL: *
-// RUN: %clang -S -### -cl-std=CL %s | FileCheck --check-prefix=CHECK-CL %s
-// RUN: %clang -S -### -cl-std=CL1.1 %s | FileCheck --check-prefix=CHECK-CL11 %s
-// RUN: %clang -S -### -cl-std=CL1.2 %s | FileCheck --check-prefix=CHECK-CL12 %s
-// RUN: %clang -S -### -cl-std=CL2.0 %s | FileCheck --check-prefix=CHECK-CL20 %s
-// RUN: %clang -S -### -cl-opt-disable %s | FileCheck --check-prefix=CHECK-OPT-DISABLE %s
-// RUN: %clang -S -### -cl-strict-aliasing %s | FileCheck --check-prefix=CHECK-STRICT-ALIASING %s
-// RUN: %clang -S -### -cl-std=CL1.1 -cl-strict-aliasing %s | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
-// RUN: %clang -S -### -cl-std=CL1.2 -cl-strict-aliasing %s | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
-// RUN: %clang -S -### -cl-std=CL2.0 -cl-strict-aliasing %s | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION20 %s
-// RUN: %clang -S -### -cl-single-precision-constant %s | FileCheck --check-prefix=CHECK-SINGLE-PRECISION-CONST %s
-// RUN: %clang -S -### -cl-finite-math-only %s | FileCheck --check-prefix=CHECK-FINITE-MATH-ONLY %s
-// RUN: %clang -S -### -cl-kernel-arg-info %s | FileCheck --check-prefix=CHECK-KERNEL-ARG-INFO %s
-// RUN: %clang -S -### -cl-unsafe-math-optimizations %s | FileCheck --check-prefix=CHECK-UNSAFE-MATH-OPT %s
-// RUN: %clang -S -### -cl-fast-relaxed-math %s | FileCheck --check-prefix=CHECK-FAST-RELAXED-MATH %s
-// RUN: %clang -S -### -cl-mad-enable %s | FileCheck --check-prefix=CHECK-MAD-ENABLE %s
-// RUN: %clang -S -### -cl-no-signed-zeros %s | FileCheck --check-prefix=CHECK-NO-SIGNED-ZEROS %s
-// RUN: %clang -S -### -cl-denorms-are-zero %s | FileCheck --check-prefix=CHECK-DENORMS-ARE-ZERO %s
-// RUN: not %clang_cc1 -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
-// RUN: not %clang_cc1 -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
+// RUN: %clang -S -### -cl-std=CL %s 2>&1 | FileCheck --check-prefix=CHECK-CL %s
+// RUN: %clang -S -### -cl-std=CL1.1 %s 2>&1 | FileCheck --check-prefix=CHECK-CL11 %s
+// RUN: %clang -S -### -cl-std=CL1.2 %s 2>&1 | FileCheck --check-prefix=CHECK-CL12 %s
+// RUN: %clang -S -### -cl-std=CL2.0 %s 2>&1 | FileCheck --check-prefix=CHECK-CL20 %s
+// RUN: %clang -S -### -cl-opt-disable %s 2>&1 | FileCheck --check-prefix=CHECK-OPT-DISABLE %s
+// RUN: %clang -S -### -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-STRICT-ALIASING %s
+// RUN: %clang -S -### -cl-single-precision-constant %s 2>&1 | FileCheck --check-prefix=CHECK-SINGLE-PRECISION-CONST %s
+// RUN: %clang -S -### -cl-finite-math-only %s 2>&1 | FileCheck --check-prefix=CHECK-FINITE-MATH-ONLY %s
+// RUN: %clang -S -### -cl-kernel-arg-info %s 2>&1 | FileCheck --check-prefix=CHECK-KERNEL-ARG-INFO %s
+// RUN: %clang -S -### -cl-unsafe-math-optimizations %s 2>&1 | FileCheck --check-prefix=CHECK-UNSAFE-MATH-OPT %s
+// RUN: %clang -S -### -cl-fast-relaxed-math %s 2>&1 | FileCheck --check-prefix=CHECK-FAST-RELAXED-MATH %s
+// RUN: %clang -S -### -cl-mad-enable %s 2>&1 | FileCheck --check-prefix=CHECK-MAD-ENABLE %s
+// RUN: %clang -S -### -cl-no-signed-zeros %s 2>&1 | FileCheck --check-prefix=CHECK-NO-SIGNED-ZEROS %s
+// RUN: %clang -S -### -cl-denorms-are-zero %s 2>&1 | FileCheck --check-prefix=CHECK-DENORMS-ARE-ZERO %s
+// RUN: not %clang -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
+// RUN: not %clang -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
 
-// CHECK-CL: .*clang.* "-cc1" .* "-cl-std=CL"
-// CHECK-CL11: .*clang.* "-cc1" .* "-cl-std=CL1.1"
-// CHECK-CL12: .*clang.* "-cc1" .* "-cl-std=CL1.2"
-// CHECK-CL20: .*clang.* "-cc1" .* "-cl-std=CL2.0"
-// CHECK-OPT-DISABLE: .*clang.* "-cc1" .* "-cl-opt-disable"
-// CHECK-STRICT-ALIASING: .*clang.* "-cc1" .* "-cl-strict-aliasing"
-// CHECK-INVALID-OPENCL-VERSION11: OpenCL version 1.1 does not support the option 'cl-strict-aliasing'
-// CHECK-INVALID-OPENCL-VERSION12: OpenCL version 1.2 does not support the option 'cl-strict-aliasing'
-// CHECK-INVALID-OPENCL-VERSION20: OpenCL version 2.0 does not support the option 'cl-strict-aliasing'
-// CHECK-SINGLE-PRECISION-CONST: .*clang.* "-cc1" .* "-cl-single-precision-constant"
-// CHECK-FINITE-MATH-ONLY: .*clang.* "-cc1" .* "-cl-finite-math-only"
-// CHECK-KERNEL-ARG-INFO: .*clang.* "-cc1" .* "-cl-kernel-arg-info"
-// CHECK-UNSAFE-MATH-OPT: .*clang.* "-cc1" .* "-cl-unsafe-math-optimizations"
-// CHECK-FAST-RELAXED-MATH: .*clang.* "-cc1" .* "-cl-fast-relaxed-math"
-// CHECK-MAD-ENABLE: .*clang.* "-cc1" .* "-cl-mad-enable"
-// CHECK-NO-SIGNED-ZEROS: .*clang.* "-cc1" .* "-cl-no-signed-zeros"
-// CHECK-DENORMS-ARE-ZERO: .*clang.* "-cc1" .* "-cl-denorms-are-zero"
-// CHECK-C99: error: invalid argument '-cl-std=c99' not allowed with 'OpenCL'
-// CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
+// CHECK-CL: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL"
+// CHECK-CL11: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL1.1"
+// CHECK-CL12: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL1.2"
+// CHECK-CL20: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL2.0"
+// CHECK-OPT-DISABLE: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-opt-disable"
+// CHECK-STRICT-ALIASING: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-strict-aliasing"
+// CHECK-SINGLE-PRECISION-CONST: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-single-precision-constant"
+// CHECK-FINITE-MATH-ONLY: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-finite-math-only"
+// CHECK-KERNEL-ARG-INFO: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-kernel-arg-info"
+// CHECK-UNSAFE-MATH-OPT: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-unsafe-math-optimizations"
+// CHECK-FAST-RELAXED-MATH: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-fast-relaxed-math"
+// CHECK-MAD-ENABLE: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-mad-enable"
+// CHECK-NO-SIGNED-ZEROS: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-no-signed-zeros"
+// CHECK-DENORMS-ARE-ZERO: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-denorms-are-zero"
+// CHECK-C99: error: invalid value 'c99' in '-cl-std=c99'
+// CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
 
 kernel void func(void);

Removed: cfe/trunk/test/Frontend/opencl-blocks.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/opencl-blocks.cl?rev=275317&view=auto
==============================================================================
--- cfe/trunk/test/Frontend/opencl-blocks.cl (original)
+++ cfe/trunk/test/Frontend/opencl-blocks.cl (removed)
@@ -1,20 +0,0 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL2.0
-// RUN: %clang_cc1 %s -verify -fsyntax-only -fblocks -DBLOCKS
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -fblocks -DBLOCKS
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -fblocks -DBLOCKS
-// RUN: %clang_cc1 %s -triple amdgcn--amdhsa -x c -std=c99 -verify -fsyntax-only
-
-void f(void (^g)(void)) {
-#ifdef __OPENCL_C_VERSION__
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0 && !defined(BLOCKS)
-  // expected-error at -3{{blocks support disabled - compile with -fblocks or for OpenCL 2.0 or above}}
-#else
-  // expected-no-diagnostics
-#endif
-#else
-  // expected-error at -8{{blocks support disabled - compile with -fblocks or pick a deployment target that supports them}}
-#endif
-}

Added: cfe/trunk/test/Frontend/opencl.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/opencl.cl?rev=275318&view=auto
==============================================================================
--- cfe/trunk/test/Frontend/opencl.cl (added)
+++ cfe/trunk/test/Frontend/opencl.cl Wed Jul 13 16:21:05 2016
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -fsyntax-only -fblocks -DBLOCKS
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -fblocks -DBLOCKS
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -fblocks -DBLOCKS
+// RUN: %clang_cc1 %s -triple amdgcn--amdhsa -x c -std=c99 -verify -fsyntax-only
+// RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
+// RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
+// RUN: %clang_cc1 -cl-std=CL2.0 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION20 %s
+
+void f(void (^g)(void)) {
+#ifdef __OPENCL_C_VERSION__
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0 && !defined(BLOCKS)
+  // expected-error at -3{{blocks support disabled - compile with -fblocks or for OpenCL 2.0 or above}}
+#else
+  // expected-no-diagnostics
+#endif
+#else
+  // expected-error at -8{{blocks support disabled - compile with -fblocks or pick a deployment target that supports them}}
+#endif
+}
+
+// CHECK-INVALID-OPENCL-VERSION11: warning: OpenCL version 1.1 does not support the option '-cl-strict-aliasing'
+// CHECK-INVALID-OPENCL-VERSION12: warning: OpenCL version 1.2 does not support the option '-cl-strict-aliasing'
+// CHECK-INVALID-OPENCL-VERSION20: warning: OpenCL version 2.0 does not support the option '-cl-strict-aliasing'
\ No newline at end of file




More information about the cfe-commits mailing list