<div dir="ltr"><br><div>The flags <font face="monospace, monospace">-fprofile-generate</font> and <font face="monospace, monospace">-fprofile-use</font> are currently ignored for GCC compatibility.  I would like to enable them and give them similar semantics to GCC.  These flags are baked pretty deeply into our build environment, so supporting them at the driver level will make our lives a lot simpler.</div><div><br></div><div>From <a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__gcc.gnu.org_onlinedocs_gcc_Optimize-2DOptions.html&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=MY4uSnJUGmFHgX96G2AXRBZWCjYCDaqw5Gz1iJGTJOc&s=P2Z25EVKLo18C0GjJMcTG-kPBbJVQysKhK9EGkcJDNs&e=" class="cremed">https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html</a>:</div><div><br></div><div><dt style="color:rgb(0,0,0);font-family:Times;font-size:medium"><code>-fprofile-generate</code></dt><dt style="color:rgb(0,0,0);font-family:Times;font-size:medium"><code>-fprofile-generate=</code><var>path</var></dt><dd style="color:rgb(0,0,0);font-family:Times;font-size:medium"><a name="index-fprofile-generate-1083" class="cremed"></a>Enable options usually used for instrumenting application to produce profile useful for later recompilation with profile feedback based optimization. You must use <samp><span class="">-fprofile-generate</span></samp> both when compiling and when linking your program.<p>The following options are enabled: <samp><span class="">-fprofile-arcs</span></samp>, <samp><span class="">-fprofile-values</span></samp>, <samp><span class="">-fvpt</span></samp>.</p><p>If <var>path</var> is specified, GCC looks at the <var>path</var> to find the profile feedback data files. See <samp><span class="">-fprofile-dir</span></samp>. <br></p></dd><dt style="color:rgb(0,0,0);font-family:Times;font-size:medium"><code>-fprofile-use</code></dt><dt style="color:rgb(0,0,0);font-family:Times;font-size:medium"><code>-fprofile-use=</code><var>path</var></dt><dd style="color:rgb(0,0,0);font-family:Times;font-size:medium"><a name="index-fprofile-use-1084" class="cremed"></a>Enable profile feedback-directed optimizations, and the following optimizations which are generally profitable only with profile feedback available: <samp><span class="">-fbranch-probabilities</span></samp>, <samp><span class="">-fvpt</span></samp>, <samp><span class="">-funroll-loops</span></samp>, <samp><span class="">-fpeel-loops</span></samp>, <samp><span class="">-ftracer</span></samp>, <samp><span class="">-ftree-vectorize</span></samp>, and <samp><span class="">ftree-loop-distribute-patterns</span></samp>.<p>By default, GCC emits an error message if the feedback profiles do not match the source code. This error can be turned into a warning by using <samp><span class="">-Wcoverage-mismatch</span></samp>. Note this may result in poorly optimized code.</p><p>If <var>path</var> is specified, GCC looks at the <var>path</var> to find the profile feedback data files. See <samp><span class="">-fprofile-dir</span></samp>. </p></dd></div><div><br></div><div>Note that the argument to <font face="monospace, monospace">-fprofile-generate</font> and <font face="monospace, monospace">-fprofile-use</font> is not a file name. It is a path prefix used to store the generated profile (in GCC's case, each object file in the binary generates its own profile file). In Clang, the flags would do the following:</div><div><ol><li><font face="monospace, monospace">-fprofile-generate=path-prefix</font> would cause the instrumented binary to write the profile <font face="monospace, monospace"><path-prefix>/default.profraw</font>. If <font face="monospace, monospace"><path-prefix></font> does not exist, it is created by the runtime.</li><li><font face="monospace, monospace">-fprofile-use=path-prefix</font> would cause the compiler to read from <font face="monospace, monospace"><path-prefix>/default.profile</font>.</li><li>I could also add support for <font face="monospace, monospace">-fprofile-dir</font>, but we don't really use it internally.</li></ol><div>As with <font face="monospace, monospace">-fprofile-instr-generate</font>, <font face="monospace, monospace">LLVM_PROFILE_FILE</font> would override the path prefix and name of the profile file.</div></div><div><br></div><div>Does this sound reasonable?</div><div><br></div><div><br></div><div>Thanks.  Diego.</div><div><br></div><div><br></div></div>