r245913 - [clang-cl] Only respect /Oy- for x86_32

David Majnemer via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 24 17:46:46 PDT 2015


Author: majnemer
Date: Mon Aug 24 19:46:45 2015
New Revision: 245913

URL: http://llvm.org/viewvc/llvm-project?rev=245913&view=rev
Log:
[clang-cl] Only respect /Oy- for x86_32

The /Oy- flag should have no effect for 64-bit X86, it has reliable
unwind tables.

Modified:
    cfe/trunk/include/clang/Driver/CLCompatOptions.td
    cfe/trunk/lib/Driver/MSVCToolChain.cpp
    cfe/trunk/test/Driver/cl-fallback.c
    cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=245913&r1=245912&r2=245913&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Mon Aug 24 19:46:45 2015
@@ -104,10 +104,6 @@ def _SLASH_Os : CLFlag<"Os">, HelpText<"
   AliasArgs<["s"]>;
 def _SLASH_Ot : CLFlag<"Ot">, HelpText<"Optimize for speed">, Alias<O>,
   AliasArgs<["2"]>;
-def _SLASH_Oy : CLFlag<"Oy">, HelpText<"Enable frame pointer omission">,
-  Alias<fomit_frame_pointer>;
-def _SLASH_Oy_ : CLFlag<"Oy-">, HelpText<"Disable frame pointer omission">,
-  Alias<fno_omit_frame_pointer>;
 def _SLASH_QUESTION : CLFlag<"?">, Alias<help>,
   HelpText<"Display available options">;
 def _SLASH_Qvec : CLFlag<"Qvec">,

Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MSVCToolChain.cpp?rev=245913&r1=245912&r2=245913&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/MSVCToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/MSVCToolChain.cpp Mon Aug 24 19:46:45 2015
@@ -535,6 +535,9 @@ MSVCToolChain::TranslateArgs(const llvm:
   DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
   const OptTable &Opts = getDriver().getOpts();
 
+  // /Oy and /Oy- only has an effect under X86-32.
+  bool SupportsForcingFramePointer = getArch() == llvm::Triple::x86;
+
   // The -O[12xd] flag actually expands to several flags.  We must desugar the
   // flags so that options embedded can be negated.  For example, the '-O2' flag
   // enables '-Oy'.  Expanding '-O2' into its constituent flags allows us to
@@ -584,8 +587,9 @@ MSVCToolChain::TranslateArgs(const llvm:
               DAL->AddFlagArg(A, Opts.getOption(options::OPT_fbuiltin));
               DAL->AddJoinedArg(A, Opts.getOption(options::OPT_O), "2");
             }
-            DAL->AddFlagArg(A,
-                            Opts.getOption(options::OPT_fomit_frame_pointer));
+            if (SupportsForcingFramePointer)
+              DAL->AddFlagArg(A,
+                              Opts.getOption(options::OPT_fomit_frame_pointer));
             if (OptChar == '1' || OptChar == '2')
               DAL->AddFlagArg(A,
                               Opts.getOption(options::OPT_ffunction_sections));
@@ -593,13 +597,13 @@ MSVCToolChain::TranslateArgs(const llvm:
         }
         break;
       case 'b':
-        if (isdigit(OptStr[I + 1]))
+        if (I + 1 != E && isdigit(OptStr[I + 1]))
           ++I;
         break;
       case 'g':
         break;
       case 'i':
-        if (OptStr[I + 1] == '-') {
+        if (I + 1 != E && OptStr[I + 1] == '-') {
           ++I;
           DAL->AddFlagArg(A, Opts.getOption(options::OPT_fno_builtin));
         } else {
@@ -612,16 +616,23 @@ MSVCToolChain::TranslateArgs(const llvm:
       case 't':
         DAL->AddJoinedArg(A, Opts.getOption(options::OPT_O), "2");
         break;
-      case 'y':
-        if (OptStr[I + 1] == '-') {
+      case 'y': {
+        bool OmitFramePointer = true;
+        if (I + 1 != E && OptStr[I + 1] == '-') {
+          OmitFramePointer = false;
           ++I;
-          DAL->AddFlagArg(A,
-                          Opts.getOption(options::OPT_fno_omit_frame_pointer));
-        } else {
-          DAL->AddFlagArg(A, Opts.getOption(options::OPT_fomit_frame_pointer));
+        }
+        if (SupportsForcingFramePointer) {
+          if (OmitFramePointer)
+            DAL->AddFlagArg(A,
+                            Opts.getOption(options::OPT_fomit_frame_pointer));
+          else
+            DAL->AddFlagArg(
+                A, Opts.getOption(options::OPT_fno_omit_frame_pointer));
         }
         break;
       }
+      }
     }
   }
   return DAL;

Modified: cfe/trunk/test/Driver/cl-fallback.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-fallback.c?rev=245913&r1=245912&r2=245913&view=diff
==============================================================================
--- cfe/trunk/test/Driver/cl-fallback.c (original)
+++ cfe/trunk/test/Driver/cl-fallback.c Mon Aug 24 19:46:45 2015
@@ -1,7 +1,7 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
 
-// RUN: %clang_cl /fallback /Dfoo=bar /Ubaz /Ifoo /O0 /Ox /GR /GR- /Gy /Gy- \
+// RUN: %clang_cl --target=i686-pc-win32 /fallback /Dfoo=bar /Ubaz /Ifoo /O0 /Ox /GR /GR- /Gy /Gy- \
 // RUN:   /Gw /Gw- /LD /LDd /EHs /EHs- /Zl /MD /MDd /MTd /MT /FImyheader.h /Zi \
 // RUN:   -### -- %s 2>&1 \
 // RUN:   | FileCheck %s
@@ -41,16 +41,16 @@
 // RUN: %clang_cl /fallback /Od -### -- %s 2>&1 | FileCheck -check-prefix=O0 %s
 // O0: cl.exe
 // O0: "/Od"
-// RUN: %clang_cl /fallback /O1 -### -- %s 2>&1 | FileCheck -check-prefix=O1 %s
+// RUN: %clang_cl --target=i686-pc-win32 /fallback /O1 -### -- %s 2>&1 | FileCheck -check-prefix=O1 %s
 // O1: cl.exe
 // O1: "/Og" "/Os" "/Ob2" "/Oy" "/GF" "/Gy"
-// RUN: %clang_cl /fallback /O2 -### -- %s 2>&1 | FileCheck -check-prefix=O2 %s
+// RUN: %clang_cl --target=i686-pc-win32 /fallback /O2 -### -- %s 2>&1 | FileCheck -check-prefix=O2 %s
 // O2: cl.exe
 // O2: "/Oi" "/Og" "/Ot" "/Ob2" "/Oy" "/GF" "/Gy"
-// RUN: %clang_cl /fallback /Os -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
+// RUN: %clang_cl --target=i686-pc-win32 /fallback /Os -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
 // Os: cl.exe
 // Os: "/Os"
-// RUN: %clang_cl /fallback /Ox -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
+// RUN: %clang_cl --target=i686-pc-win32 /fallback /Ox -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
 // Ox: cl.exe
 // Ox: "/Oi" "/Og" "/Ot" "/Ob2" "/Oy" "/GF"
 

Modified: cfe/trunk/test/Driver/cl-options.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=245913&r1=245912&r2=245913&view=diff
==============================================================================
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Mon Aug 24 19:46:45 2015
@@ -110,14 +110,14 @@
 // Ox: -momit-leaf-frame-pointer
 // Ox: -O2
 
-// RUN: %clang_cl /O2sy- -### -- %s 2>&1 | FileCheck -check-prefix=PR24003 %s
+// RUN: %clang_cl --target=i686-pc-win32 /O2sy- -### -- %s 2>&1 | FileCheck -check-prefix=PR24003 %s
 // PR24003: -mdisable-fp-elim
 // PR24003: -momit-leaf-frame-pointer
 // PR24003: -Os
 
 // RUN: %clang_cl /Zs /Oy -- %s 2>&1
 
-// RUN: %clang_cl /Oy- -### -- %s 2>&1 | FileCheck -check-prefix=Oy_ %s
+// RUN: %clang_cl --target=i686-pc-win32 /Oy- -### -- %s 2>&1 | FileCheck -check-prefix=Oy_ %s
 // Oy_: -mdisable-fp-elim
 
 // RUN: %clang_cl /Qvec -### -- %s 2>&1 | FileCheck -check-prefix=Qvec %s




More information about the cfe-commits mailing list