[PATCH] D30920: Do not pass -Os and -Oz to the Gold plugin

Pirama Arumuga Nainar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 13 21:23:53 PDT 2017


pirama updated this revision to Diff 91671.
pirama added a comment.

Address review comments


https://reviews.llvm.org/D30920

Files:
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Driver/gold-lto.c


Index: test/Driver/gold-lto.c
===================================================================
--- test/Driver/gold-lto.c
+++ test/Driver/gold-lto.c
@@ -26,3 +26,9 @@
 // RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \
 // RUN:     | FileCheck %s --check-prefix=CHECK-X86-ANDROID
 // CHECK-X86-ANDROID: "-plugin" "{{.*}}/LLVMgold.so"
+//
+// Test that -Os and -Oz are not passed to the plugin
+// RUN: %clang -### %t.o -flto -Os 2>&1 \
+// RUN:     | FileCheck %s --implicit-check-not "-plugin-opt=Os"
+// RUN: %clang -### %t.o -flto -Oz 2>&1 \
+// RUN:     | FileCheck %s --implicit-check-not "-plugin-opt=Oz"
Index: lib/Driver/ToolChains/CommonArgs.cpp
===================================================================
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -368,9 +368,13 @@
     if (A->getOption().matches(options::OPT_O4) ||
         A->getOption().matches(options::OPT_Ofast))
       OOpt = "3";
-    else if (A->getOption().matches(options::OPT_O))
-      OOpt = A->getValue();
-    else if (A->getOption().matches(options::OPT_O0))
+    else if (A->getOption().matches(options::OPT_O)) {
+      StringRef OptLevel = A->getValue();
+      // Do not pass optimization levels pertaining to code size to the plugin.
+      // They are captured by corresponding function attributes.
+      if (OptLevel != "s" && OptLevel != "z")
+        OOpt = OptLevel;
+    } else if (A->getOption().matches(options::OPT_O0))
       OOpt = "0";
     if (!OOpt.empty())
       CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=O") + OOpt));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30920.91671.patch
Type: text/x-patch
Size: 1601 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170314/9cd1e899/attachment.bin>


More information about the cfe-commits mailing list