[clang] 86cd353 - [LTO][clang] Using Single Dash Consistently when Passing LTO Options

Qiongsi Wu via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 27 11:53:12 PDT 2022


Author: Qiongsi Wu
Date: 2022-09-27T14:50:41-04:00
New Revision: 86cd3535206d6db611260aae6f2869202eae4bb4

URL: https://github.com/llvm/llvm-project/commit/86cd3535206d6db611260aae6f2869202eae4bb4
DIFF: https://github.com/llvm/llvm-project/commit/86cd3535206d6db611260aae6f2869202eae4bb4.diff

LOG: [LTO][clang] Using Single Dash Consistently when Passing LTO Options

The following three static functions in `clang/lib/Driver/ToolChains/CommonArgs.cpp`

```
static void renderRpassOptions(...)
static void renderRemarksOptions(...)
static void renderRemarksHotnessOptions(...)
```

use `--plugin-opt` for the plugin option prefix, while the function `tools::addLTOOptions`  uses `-plugin-opt`. This patch makes sure that we only use `-plugin-opt` (single dash) everywhere. It is not clear to me that why we decided to use `--plugin-opt` in https://reviews.llvm.org/D85810. If using `--plugin-opt` is intended, I'd love to hear the reason and I will close this patch.

We intend to followup this patch with a few other patches that teach `clang` to pass plugin options to the AIX linker, which uses a different prefix (`-bplugin_opt:`).

Reviewed By: w2yehia

Differential Revision: https://reviews.llvm.org/D134668

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/CommonArgs.cpp
    clang/test/Driver/opt-record.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 86ed6edfb86fa..d0abc4a0e26c2 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -67,16 +67,16 @@ using namespace llvm::opt;
 
 static void renderRpassOptions(const ArgList &Args, ArgStringList &CmdArgs) {
   if (const Arg *A = Args.getLastArg(options::OPT_Rpass_EQ))
-    CmdArgs.push_back(Args.MakeArgString(Twine("--plugin-opt=-pass-remarks=") +
+    CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=-pass-remarks=") +
                                          A->getValue()));
 
   if (const Arg *A = Args.getLastArg(options::OPT_Rpass_missed_EQ))
     CmdArgs.push_back(Args.MakeArgString(
-        Twine("--plugin-opt=-pass-remarks-missed=") + A->getValue()));
+        Twine("-plugin-opt=-pass-remarks-missed=") + A->getValue()));
 
   if (const Arg *A = Args.getLastArg(options::OPT_Rpass_analysis_EQ))
     CmdArgs.push_back(Args.MakeArgString(
-        Twine("--plugin-opt=-pass-remarks-analysis=") + A->getValue()));
+        Twine("-plugin-opt=-pass-remarks-analysis=") + A->getValue()));
 }
 
 static void renderRemarksOptions(const ArgList &Args, ArgStringList &CmdArgs,
@@ -97,28 +97,28 @@ static void renderRemarksOptions(const ArgList &Args, ArgStringList &CmdArgs,
   assert(!F.empty() && "Cannot determine remarks output name.");
   // Append "opt.ld.<format>" to the end of the file name.
   CmdArgs.push_back(
-      Args.MakeArgString(Twine("--plugin-opt=opt-remarks-filename=") + F +
+      Args.MakeArgString(Twine("-plugin-opt=opt-remarks-filename=") + F +
                          Twine(".opt.ld.") + Format));
 
   if (const Arg *A =
           Args.getLastArg(options::OPT_foptimization_record_passes_EQ))
     CmdArgs.push_back(Args.MakeArgString(
-        Twine("--plugin-opt=opt-remarks-passes=") + A->getValue()));
+        Twine("-plugin-opt=opt-remarks-passes=") + A->getValue()));
 
   CmdArgs.push_back(Args.MakeArgString(
-      Twine("--plugin-opt=opt-remarks-format=") + Format.data()));
+      Twine("-plugin-opt=opt-remarks-format=") + Format.data()));
 }
 
 static void renderRemarksHotnessOptions(const ArgList &Args,
                                         ArgStringList &CmdArgs) {
   if (Args.hasFlag(options::OPT_fdiagnostics_show_hotness,
                    options::OPT_fno_diagnostics_show_hotness, false))
-    CmdArgs.push_back("--plugin-opt=opt-remarks-with-hotness");
+    CmdArgs.push_back("-plugin-opt=opt-remarks-with-hotness");
 
   if (const Arg *A =
           Args.getLastArg(options::OPT_fdiagnostics_hotness_threshold_EQ))
     CmdArgs.push_back(Args.MakeArgString(
-        Twine("--plugin-opt=opt-remarks-hotness-threshold=") + A->getValue()));
+        Twine("-plugin-opt=opt-remarks-hotness-threshold=") + A->getValue()));
 }
 
 void tools::addPathIfExists(const Driver &D, const Twine &Path,

diff  --git a/clang/test/Driver/opt-record.c b/clang/test/Driver/opt-record.c
index 02840f49a86f7..fd7cabb284869 100644
--- a/clang/test/Driver/opt-record.c
+++ b/clang/test/Driver/opt-record.c
@@ -53,28 +53,28 @@
 // RUN: %clang -target x86_64-linux -### -o FOO -fuse-ld=lld -flto=thin -fdiagnostics-hotness-threshold=100 -Rpass=inline -Rpass-missed=inline -Rpass-analysis=inline %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS-RPASS
 // RUN: %clang -target x86_64-linux -### -o FOO -fuse-ld=lld -flto=thin -fdiagnostics-hotness-threshold=auto -Rpass=inline -Rpass-missed=inline -Rpass-analysis=inline %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS-AUTO
 
-// CHECK-NOPASS-NOT: "--plugin-opt=opt-remarks-filename="
-// CHECK-NOPASS-NOT: "--plugin-opt=opt-remarks-passes=inline"
-// CHECK-NOPASS-NOT: "--plugin-opt=opt-remarks-format=yaml"
-// CHECK-NOPASS-NOT: "--plugin-opt=opt-remarks-hotness-threshold=100"
-
-// CHECK-PASS-A:      "--plugin-opt=opt-remarks-filename=a.out.opt.ld.yaml"
-// CHECK-PASS-A-SAME: "--plugin-opt=opt-remarks-passes=inline"
-// CHECK-PASS-A-SAME: "--plugin-opt=opt-remarks-format=yaml"
-// CHECK-PASS-A-SAME: "--plugin-opt=opt-remarks-hotness-threshold=100"
-
-// CHECK-PASS:      "--plugin-opt=opt-remarks-filename=FOO.opt.ld.yaml"
-// CHECK-PASS-SAME: "--plugin-opt=opt-remarks-passes=inline"
-// CHECK-PASS-SAME: "--plugin-opt=opt-remarks-format=yaml"
-// CHECK-PASS-SAME: "--plugin-opt=opt-remarks-hotness-threshold=100"
-
-// CHECK-PASS-CUSTOM:      "--plugin-opt=opt-remarks-filename=FOO.txt.opt.ld.some-format"
-// CHECK-PASS-CUSTOM-SAME: "--plugin-opt=opt-remarks-format=some-format"
-// CHECK-PASS-CUSTOM-SAME: "--plugin-opt=opt-remarks-hotness-threshold=100"
-
-// CHECK-PASS-RPASS:      "--plugin-opt=-pass-remarks=inline"
-// CHECK-PASS-RPASS-SAME: "--plugin-opt=-pass-remarks-missed=inline"
-// CHECK-PASS-RPASS-SAME: "--plugin-opt=-pass-remarks-analysis=inline"
-// CHECK-PASS-RPASS-SAME: "--plugin-opt=opt-remarks-hotness-threshold=100"
-
-// CHECK-PASS-AUTO:   "--plugin-opt=opt-remarks-hotness-threshold=auto"
+// CHECK-NOPASS-NOT: "-plugin-opt=opt-remarks-filename="
+// CHECK-NOPASS-NOT: "-plugin-opt=opt-remarks-passes=inline"
+// CHECK-NOPASS-NOT: "-plugin-opt=opt-remarks-format=yaml"
+// CHECK-NOPASS-NOT: "-plugin-opt=opt-remarks-hotness-threshold=100"
+
+// CHECK-PASS-A:      "-plugin-opt=opt-remarks-filename=a.out.opt.ld.yaml"
+// CHECK-PASS-A-SAME: "-plugin-opt=opt-remarks-passes=inline"
+// CHECK-PASS-A-SAME: "-plugin-opt=opt-remarks-format=yaml"
+// CHECK-PASS-A-SAME: "-plugin-opt=opt-remarks-hotness-threshold=100"
+
+// CHECK-PASS:      "-plugin-opt=opt-remarks-filename=FOO.opt.ld.yaml"
+// CHECK-PASS-SAME: "-plugin-opt=opt-remarks-passes=inline"
+// CHECK-PASS-SAME: "-plugin-opt=opt-remarks-format=yaml"
+// CHECK-PASS-SAME: "-plugin-opt=opt-remarks-hotness-threshold=100"
+
+// CHECK-PASS-CUSTOM:      "-plugin-opt=opt-remarks-filename=FOO.txt.opt.ld.some-format"
+// CHECK-PASS-CUSTOM-SAME: "-plugin-opt=opt-remarks-format=some-format"
+// CHECK-PASS-CUSTOM-SAME: "-plugin-opt=opt-remarks-hotness-threshold=100"
+
+// CHECK-PASS-RPASS:      "-plugin-opt=-pass-remarks=inline"
+// CHECK-PASS-RPASS-SAME: "-plugin-opt=-pass-remarks-missed=inline"
+// CHECK-PASS-RPASS-SAME: "-plugin-opt=-pass-remarks-analysis=inline"
+// CHECK-PASS-RPASS-SAME: "-plugin-opt=opt-remarks-hotness-threshold=100"
+
+// CHECK-PASS-AUTO:   "-plugin-opt=opt-remarks-hotness-threshold=auto"


        


More information about the cfe-commits mailing list