qiongsiwu1 created this revision.
qiongsiwu1 added reviewers: w2yehia, MaskRay.
qiongsiwu1 added a project: clang.
Herald added subscribers: ormris, StephenFan, inglorion.
Herald added a project: All.
qiongsiwu1 requested review of this revision.
Herald added a subscriber: cfe-commits.

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

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

uses `--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 teaches `clang` 
to pass plugin options to the AIX linker, which uses a different prefix 
(`-bplugin_opt:`).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134668

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

Index: clang/test/Driver/opt-record.c
===================================================================
--- clang/test/Driver/opt-record.c
+++ 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"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===================================================================
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -66,16 +66,16 @@
 
 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,
@@ -96,28 +96,28 @@
   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,
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to