summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/include/clang/Driver/CC1Options.td7
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp6
-rw-r--r--clang/test/CodeGen/ext-vector-shuffle.c6
3 files changed, 15 insertions, 4 deletions
diff --git a/clang/include/clang/Driver/CC1Options.td b/clang/include/clang/Driver/CC1Options.td
index 03a4dd97eba..27db9cf5bfb 100644
--- a/clang/include/clang/Driver/CC1Options.td
+++ b/clang/include/clang/Driver/CC1Options.td
@@ -592,3 +592,10 @@ def dD : Flag<"-dD">,
HelpText<"Print macro definitions in -E mode in addition to normal output">;
def H : Flag<"-H">,
HelpText<"Show header includes and nesting depth">;
+
+//===----------------------------------------------------------------------===//
+// OpenCL Options
+//===----------------------------------------------------------------------===//
+
+def cl_opt_disable : Flag<"-cl-opt-disable">,
+ HelpText<"OpenCL only. This option disables all optimizations. The default is optimizations are enabled.">;
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index b4e676b43ec..8795b38a41c 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -774,8 +774,12 @@ using namespace clang::driver::cc1options;
static unsigned getOptimizationLevel(ArgList &Args, InputKind IK,
Diagnostic &Diags) {
+ unsigned DefaultOpt = 0;
+ if (IK == IK_OpenCL && !Args.hasArg(OPT_cl_opt_disable))
+ DefaultOpt = 2;
// -Os implies -O2
- return Args.hasArg(OPT_Os) ? 2 : Args.getLastArgIntValue(OPT_O, 0, Diags);
+ return Args.hasArg(OPT_Os) ? 2 :
+ Args.getLastArgIntValue(OPT_O, DefaultOpt, Diags);
}
static void ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
diff --git a/clang/test/CodeGen/ext-vector-shuffle.c b/clang/test/CodeGen/ext-vector-shuffle.c
index 1d147a3b3e3..d26602ae8d6 100644
--- a/clang/test/CodeGen/ext-vector-shuffle.c
+++ b/clang/test/CodeGen/ext-vector-shuffle.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 %s -x cl -emit-llvm -o - | not grep 'extractelement'
-// RUN: %clang_cc1 %s -x cl -emit-llvm -o - | not grep 'insertelement'
-// RUN: %clang_cc1 %s -x cl -emit-llvm -o - | grep 'shufflevector'
+// RUN: %clang_cc1 %s -x cl -cl-opt-disable -emit-llvm -o - | not grep 'extractelement'
+// RUN: %clang_cc1 %s -x cl -cl-opt-disable -emit-llvm -o - | not grep 'insertelement'
+// RUN: %clang_cc1 %s -x cl -cl-opt-disable -emit-llvm -o - | grep 'shufflevector'
typedef __attribute__(( ext_vector_type(2) )) float float2;
typedef __attribute__(( ext_vector_type(4) )) float float4;
OpenPOWER on IntegriCloud