<div dir="ltr">Hi,<div><br></div><div>in 20543 [0] I requested documentation about the clang front-end flags that might affect the program performance since these are not documented in the docs [1]. Following a request in [0] I would like to start a discussion about:</div>

<div><br></div><div>What to include and exclude from such a documentation page.</div><div><br></div><div>Once this is decided, that documentation can be written and submitted for further discussion and revision. This documentation could go in [1] under "Language and Target-Independent Features" in the subsection "Controlling code generation" or in a different subsection (options like -g which _might_ affect the performance of a generated binary are already documented in their own subsections here).</div>

<div><br></div><div>Documentation that is currently missing in [1] and that in my opinion is relevant:</div><div><br></div><div>(all this points are debatable and some debate has already happened in bugzilla, this is just the best starting point for a discussion that I could come up with)</div>

<div><br></div><div>1) Optimization levels: What optimization levels are there (O0-4, Ofast, Os, ...)? What is their intended usage? Typically they are equivalent to passing a series of command line arguments to the compiler, which arguments does each optimization level passes?  </div>

<div><br></div><div>2) Description of the command line arguments that might affect the performance of the generated binary such as -flto, -fstrict-aliasing, <span style="color:rgb(0,0,0);white-space:pre-wrap">-ffast-math, -fvectorize, -fvectorize-aggressive as well as </span>those passed by the optimization levels. In particular:</div>

<div>- What does each of these commands do? </div><div>- Are they enabled by an optimization level? If so, by which ones?</div><div><br></div><div>I would like to also have documentation here for commands that can affect performance but don't affect the optimizer per se such as -<span style="color:rgb(0,0,0);white-space:pre-wrap">fassume-sane-operator-new or even -DNDEBUG (debatable but it is a macro of special significance that controls, among others, the behavior of  <cassert>, although it has nothing to do with the compiler itself).</span></div>

<div><br></div><div><span style="color:rgb(0,0,0);white-space:pre-wrap">3) Controlling target-specific code generation: -march=native/-mtune=native and related options. I don't know much about these and can't find documentation about them anywhere in the clang docs.</span></div>

<div><span style="color:rgb(0,0,0);white-space:pre-wrap"><br></span></div><div><span style="color:rgb(0,0,0);white-space:pre-wrap">4) A mention of the existence of the LLVM-Opt with link to their documentation with a description about how to pass options to it directly and a warning that doing this is not recommended and that this options are not officially supported by clang and can change anytime. It is debatable wether some of these deserve special mention, e.g., sadly </span><span style="color:rgb(0,0,0);white-space:pre-wrap">-mllvm -inline-threshold=value can have a huge impact on performance.</span></div>

<div><br></div><div>5) Document those "performance-related" flags that do nothing but pass silently to achieve, e.g., gcc/msvsc compatibility.</div><div><br></div><div>Bests,</div><div>Gonzalo</div><div><br></div>

<div>[0] <a href="http://llvm.org/bugs/show_bug.cgi?id=20543">http://llvm.org/bugs/show_bug.cgi?id=20543</a></div><div>[1] <a href="http://clang.llvm.org/docs/UsersManual.html">http://clang.llvm.org/docs/UsersManual.html</a><br>

</div></div>