]> granicus.if.org Git - clang/commitdiff
Implement -cl-opt-disable
authorPeter Collingbourne <peter@pcc.me.uk>
Sat, 4 Dec 2010 01:50:45 +0000 (01:50 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Sat, 4 Dec 2010 01:50:45 +0000 (01:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120876 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/CC1Options.td
lib/Frontend/CompilerInvocation.cpp
test/CodeGen/ext-vector-shuffle.c

index 03a4dd97eba2114108dd72ce062d59e92570dbe9..27db9cf5bfb8d0abab9237e867987e304bba6afb 100644 (file)
@@ -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.">;
index b4e676b43ecd20d9f539e150bad958475c9dc660..8795b38a41c827dbdfc2671cbe3605df0054660e 100644 (file)
@@ -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,
index 1d147a3b3e322656cf87aeb85e611aed828c539c..d26602ae8d6327020094cbc17313f8733c32ba50 100644 (file)
@@ -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;