[PATCH] D34219: Allow -profile-guided-section-prefix more than once

Mark Santaniello via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 14 13:13:01 PDT 2017


marksantaniello created this revision.

At present, `-profile-guided-section-prefix` is a `cl::Optional` option, which means it demands to be passed exactly zero or one times.  Our build system makes it pretty tricky to guarantee this.  We often accidentally pass the flag more than once (but always with the same "false" value) which results in an error, after which compilation fails:

  clang (LLVM option parsing): for the -profile-guided-section-prefix option: may only occur zero or one times!

While we work on improving our build system, it also seems reasonable just to allow `-profile-guided-section-prefix` to be passed more than once, by to `cl::ZeroOrMore`.  Quoting the documentation <http://llvm.org/docs/CommandLine.html#controlling-the-number-of-occurrences-required-and-allowed>:

> The cl::ZeroOrMore modifier ... indicates that your program will allow the option to be specified zero or more times.
>  ...
>  If an option is specified multiple times for an option of the cl::opt class, only the last value will be retained.




Repository:
  rL LLVM

https://reviews.llvm.org/D34219

Files:
  lib/CodeGen/CodeGenPrepare.cpp


Index: lib/CodeGen/CodeGenPrepare.cpp
===================================================================
--- lib/CodeGen/CodeGenPrepare.cpp
+++ lib/CodeGen/CodeGenPrepare.cpp
@@ -134,7 +134,7 @@
     cl::desc("Disable protection against removing loop preheaders"));

 static cl::opt<bool> ProfileGuidedSectionPrefix(
-    "profile-guided-section-prefix", cl::Hidden, cl::init(true),
+    "profile-guided-section-prefix", cl::Hidden, cl::init(true), cl::ZeroOrMore,
     cl::desc("Use profile info to add section prefix for hot/cold functions"));

 static cl::opt<unsigned> FreqRatioToSkipMerge(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34219.102596.patch
Type: text/x-patch
Size: 596 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170614/604238de/attachment.bin>


More information about the llvm-commits mailing list