<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2018-01-08 8:41 GMT-08:00 toddy wang <span dir="ltr"><<a href="mailto:wenwangtoddy@gmail.com" target="_blank">wenwangtoddy@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi Medhi,</div><div><br></div><div>It seems -mllvm does not work as expected. Anything wrong?</div><div><br></div><div>[twang15@c92 temp]$ clang++ -O3 -mllvm <b>-deadargelim</b> LULESH.cc</div><div>clang (LLVM option parsing): Unknown command line argument '-deadargelim'.  Try: 'clang (LLVM option parsing) -help'</div><div>clang (LLVM option parsing): Did you mean '-regalloc'?</div><div><br></div><div><div>[twang15@c92 temp]$ clang++ -O3 -mllvm <b>deadargelim</b> LULESH.cc</div><div>clang (LLVM option parsing): Unknown command line argument 'deadargelim'.  Try: 'clang (LLVM option parsing) -help'</div></div></div></blockquote><div><br></div><div>You can't schedule passes this way, only set parameters like -unroll-threshold=<uint> etc.<div><br></div><div>-- </div><div>Mehdi</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>-Tao</div></div><div class="gmail-HOEnZb"><div class="gmail-h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 8, 2018 at 11:12 AM, Mehdi AMINI <span dir="ltr"><<a href="mailto:joker.eph@gmail.com" target="_blank">joker.eph@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>2018-01-07 23:16 GMT-08:00 toddy wang <span dir="ltr"><<a href="mailto:wenwangtoddy@gmail.com" target="_blank">wenwangtoddy@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">-mllvm <value>          Additional arguments to forward to LLVM's option processing<br><div><br></div><div>This is dumped by clang. I am not sure what I am supposed to put as value in order to tune unrolling/inlining threshold.</div></div></blockquote><div><br></div><div><br></div></span><div>As the help says, this is used to pass argument to LLVM itself. If you remember you earlier question about setA (clang options) and setC (opt  options), this allows to reach setC from the clang command line.</div><div>Any option that you see in the output of `opt --help` can be set from clang using `-mllvm`. Same caveat as I mentioned before: these aren't supposed to be end-user options.</div><span class="gmail-m_-6131269690400626558HOEnZb"><font color="#888888"><div><br></div><div>-- </div><div>Mehdi</div></font></span><div><div class="gmail-m_-6131269690400626558h5"><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div class="gmail-m_-6131269690400626558m_-9051171570230846072HOEnZb"><div class="gmail-m_-6131269690400626558m_-9051171570230846072h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 8, 2018 at 2:02 AM, Sean Silva <span dir="ltr"><<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="auto">For the types of things that you are looking for, you may just want to try a bunch of -mllvm options. You can tune inlining and unrolling threshold like that, for example.</div><div class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345HOEnZb"><div class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345h5"><div class="gmail_extra"><br><div class="gmail_quote">On Jan 7, 2018 10:33 PM, "toddy wang via llvm-dev" <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Mehdi,<div><br></div><div>Now we have 5 pipelines. (In addition to the first 3, which I have described in detail above, please refer my latest reply for details)</div><div>1. clang + opt + gold</div><div>2. clang + opt + lld</div><div>3. clang + GNU ld/ gold /lld</div><div><br></div><div>4. clang + opt + llc + clang</div><div>clang <span style="font-size:12.800000190734863px">-emit-llvm </span><span style="font-size:12.800000190734863px">-O1 </span><span style="font-size:12.8px">-Xclang -disable-llvm-passes for c/c++ to .bc generation and </span><span style="font-size:12.800000190734863px">minimal </span><span style="font-size:12.8px"> front-end optimization</span></div><div><span style="font-size:12.8px">opt for single bc file optimization</span></div><div><span style="font-size:12.8px">llc single bc file to obj file generation and back-end optimization (no link-time optimization is possible, since llc works on 1 bc file at a time)</span></div><div><span style="font-size:12.8px">clang again for linking all obj file to generate final executable. (</span><span style="font-size:12.800000190734863px">although in principle there can be a link-time optimization even with all obj files, it requires a lot of work and is machine-dependent. This may also be the reason why modern compilers like LLVM/GCC/ICC, etc performs LTO not at obj level. But, obj level may yield extra benefit even LTO at intermediate level has been applied by compilers, because obj level can see more information.)</span></div><div><br></div><div><span style="font-size:12.800000190734863px">`clang -Ox` + `opt -Ox` + `llc -Ox` is too coarse-grain.</span><br></div><div><br></div><div><span style="font-size:12.800000190734863px">5. Modify clang to align with GCC/ICC so that many tunables are exposed at clang command line. Not sure how much work is needed, but at least requires an overall understanding of compiler internals, which can be gradually figured out.</span></div><div><br></div><div><span style="font-size:12.800000190734863px">I believe 5 is interesting, but 2 may be good enough. More experiments are needed before decision is made.</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 8, 2018 at 12:56 AM, Mehdi AMINI <span dir="ltr"><<a href="mailto:joker.eph@gmail.com" target="_blank">joker.eph@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Toddy,<div><br></div><div>You can achieve what you're looking for with a pipeline based on `clang -Ox` + `opt -Ox` + `llc -Ox` (or lld instead of llc), but this won't be guarantee'd to be well supported across releases of the compiler.</div><div><br></div><div>Otherwise, if there are some performance-releated (or not...) command line options you think clang is missing / would benefit, I invite you to propose adding them to <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a> and submit a patch!</div><div><br></div><div>Best,</div><span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511HOEnZb"><font color="#888888"><div><br></div><div>-- </div><div>Mehdi</div></font></span></div><div class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511HOEnZb"><div class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511h5"><div class="gmail_extra"><br><div class="gmail_quote">2018-01-07 21:03 GMT-08:00 toddy wang <span dir="ltr"><<a href="mailto:wenwangtoddy@gmail.com" target="_blank">wenwangtoddy@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thanks a lot, Mehdi.<div><br></div><div>For GCC, there are around 190 optimization flags exposed as command-line options.</div><div>For Clang/LLVM, the number is 40, and many important optimization parameters are not exposed at all, such as loop unrolling factor, inline function size parameters.</div><div><br></div><div>I understand there is very different idea for whether or not expose many flags to end-user.</div><div>Personally, I believe it is a reasonable to keep end-user controllable command-line options minimal for user-friendliness.</div><div>However, for users who care a lot for a tiny bit performance improvement, like HPC community, it may be better to expose as many fine-grained tunables in the form of command line options as possible. Or, at least there should be a way to achieve this fairly easy.</div><div><br></div><div>I am curious about which way is the best for my purpose.</div><div>Please see my latest reply for 3 possible fine-grained optimization pipeline.</div><div>Looking forward to more discussions.</div><div><br></div><div>Thanks a lot! </div></div><div class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725HOEnZb"><div class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 7, 2018 at 10:11 AM, Mehdi AMINI <span dir="ltr"><<a href="mailto:joker.eph@gmail.com" target="_blank">joker.eph@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>"SetC" options are LLVM cl::opt options, they are intended for LLVM developer and experimentations. If a settings is intended to be used as a public API, there is usually a programmatic way of setting it in LLVM.</div><div>"SetA" is what clang as a C++ compiler exposes to the end-user. Internally clang will (most of the time) use one or multiple LLVM APIs to propagate a settings.</div><div><br></div><div>Best,</div><span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238HOEnZb"><font color="#888888"><div><br></div><div>-- </div><div>Mehdi</div></font></span><div><div class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238h5"><div><div class="gmail_extra"><br><div class="gmail_quote">2018-01-05 17:41 GMT-08:00 toddy wang via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Craig, thanks a lot!<div><br></div><div>I'm actually confused by clang optimization flags.</div><div><br></div><div>If I run clang -help, it will show many optimizations (denoted as set A)  and non-optimization options (denoted as set B). </div><div>If I run llvm-as < /dev/null | opt -O0/1/2/3 -disable-output -debug-pass=Arguments, it also shows many optimization flags (denote as set C).</div><div><br></div><div>There are many options in set C while not in set A, and also options in set A but not in set C.</div><div><br></div><div>The general question is:  what is the relationship between set A and set C, at the same optimization level O0/O1/O2/O3?</div><div>Another question is: how to specify an option in set C as a clang command line option, if it is not in A?</div><div><br></div><div>For example, -dse is in set C but not in set A, how can I specify it as a clang option? Or simply I cannot do that.</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><div class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625HOEnZb"><div class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 5, 2018 at 7:55 PM, Craig Topper <span dir="ltr"><<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">O0 didn't start applying optnone until r304127 in May 2017 which is after the 4.0 family was branched. So only 5.0, 6.0, and trunk have that behavior. Commit message copied below<div><br></div><div>







<p class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(43,102,201)"><span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-s1" style="font-variant-ligatures:no-common-ligatures">Author: Mehdi Amini <<a href="mailto:joker.eph@gmail.com" target="_blank">joker.eph@gmail.com</a>></span></p>
<p class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(43,102,201)"><span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-s1" style="font-variant-ligatures:no-common-ligatures">Date: <span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-Apple-converted-space">  </span>Mon May 29 05:38:20 2017 +0000</span></p>
<p class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-p2" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(43,102,201);min-height:13px"><span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-s1" style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(43,102,201)"><span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-Apple-converted-space">    </span>IRGen: Add optnone attribute on function during O0</span></p>
<p class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-p2" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(43,102,201);min-height:13px"><span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-s1" style="font-variant-ligatures:no-common-ligatures">    </span></p>
<p class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(43,102,201)"><span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-Apple-converted-space">    </span>Amongst other, this will help LTO to correctly handle/honor files</span></p>
<p class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(43,102,201)"><span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-Apple-converted-space">    </span>compiled with O0, helping debugging failures.</span></p>
<p class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(43,102,201)"><span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-Apple-converted-space">    </span>It also seems in line with how we handle other options, like how</span></p>
<p class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(43,102,201)"><span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-Apple-converted-space">    </span>-fnoinline adds the appropriate attribute as well.</span></p>
<p class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-p2" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(43,102,201);min-height:13px"><span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-s1" style="font-variant-ligatures:no-common-ligatures">    </span></p>
<p class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(43,102,201)"><span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail-Apple-converted-space">    </span>Differential Revision: <a href="https://reviews.llvm.org/D28404" target="_blank">https://reviews.llvm.org/D2840<wbr>4</a></span></p><span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643HOEnZb"><font color="#888888"><div><br></div><div><br></div></font></span></div></div><div class="gmail_extra"><span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643HOEnZb"><font color="#888888"><br clear="all"><div><div class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168gmail_signature">~Craig</div></div></font></span><div><div class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643h5">
<br><div class="gmail_quote">On Fri, Jan 5, 2018 at 4:49 PM, toddy wang <span dir="ltr"><<a href="mailto:wenwangtoddy@gmail.com" target="_blank">wenwangtoddy@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>@Zhaopei, thanks for the clarification.</div><div><br></div>@Craig and @Michael, for clang 4.0.1,  -Xclang -disable-O0-optnone gives the following error message. From which version -disable-O0-optnone gets supported?<div><br></div><div><div>[twang15@c89 temp]$ clang++ -O0 -Xclang -disable-O0-optnone -Xclang -disable-llvm-passes -c -emit-llvm -o a.bc LULESH.cc</div><div>error: unknown argument: '-disable-O0-optnone'</div><div><br></div><div>[twang15@c89 temp]$ clang++ --version</div><div>clang version 4.0.1 (tags/RELEASE_401/final)</div><div>Target: x86_64-unknown-linux-gnu</div></div></div><div class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168HOEnZb"><div class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 5, 2018 at 4:45 PM, Craig Topper <span dir="ltr"><<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">If you pass -O0 to clang, most functions will be tagged with an optnone function attribute that will prevent opt and llc even if you pass -O3 to opt and llc. This is the mostly likely cause for the slow down in 2.<div><br></div><div>You can disable the optnone function attribute behavior by passing "-Xclang -disable-O0-optnone" to clang</div></div><div class="gmail_extra"><span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168m_2034229146786603789HOEnZb"><font color="#888888"><br clear="all"><div><div class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168m_2034229146786603789m_-8339188297650556759gmail_signature">~Craig</div></div></font></span><div><div class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168m_2034229146786603789h5">
<br><div class="gmail_quote">On Fri, Jan 5, 2018 at 1:19 PM, toddy wang via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">I tried the following on LULESH1.0 serial version (<a href="https://codesign.llnl.gov/lulesh/LULESH.cc" target="_blank">https://codesign.llnl.gov/lul<wbr>esh/LULESH.cc</a>)<div><br></div><div>1. clang++ -O3 LULESH.cc; ./a.out 20</div><div>Runtime: 9.487353 second</div><div><br></div><div>2. clang++ -O0 -Xclang -disable-llvm-passes -c -emit-llvm -o a.bc LULESH.cc; opt -O3 a.bc -o b.bc; llc -O3 -filetype=obj b.bc -o b.o ; clang++ b.o -o b.out; ./b.out 20</div><div>Runtime: 24.15 seconds</div><div><br></div><div>3. clang++ -O3 -Xclang -disable-llvm-passes -c -emit-llvm -o a.bc LULESH.cc; opt -O3 a.bc -o b.bc; llc -O3 -filetype=obj b.bc -o b.o ; clang++ b.o -o b.out; ./b.out 20</div><div>Runtime: 9.53 seconds</div><div><br></div><div>1 and 3 have almost the same performance, while 2 is significantly worse, while I expect 1, 2 ,3 should have trivial difference.</div><div><br></div><div>Is this a wrong expectation?</div><div><br></div><div>@Peizhao, what did you try in your last post?</div></div><div class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168m_2034229146786603789m_-8339188297650556759HOEnZb"><div class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168m_2034229146786603789m_-8339188297650556759h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 11, 2017 at 12:15 PM, Peizhao Ou via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">It's really nice of you pointing out the -Xclang option, it makes things much easier. I really appreciate your help!<div><br></div><div>Best,</div><div>Peizhao</div></div><div class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168m_2034229146786603789m_-8339188297650556759m_9146112996686254187HOEnZb"><div class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168m_2034229146786603789m_-8339188297650556759m_9146112996686254187h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 10, 2017 at 10:12 PM, Mehdi Amini <span dir="ltr"><<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><br><div><span><blockquote type="cite"><div>On Apr 10, 2017, at 5:21 PM, Craig Topper via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168m_2034229146786603789m_-8339188297650556759m_9146112996686254187m_-1208587949809955168m_-6624049905980539258Apple-interchange-newline"><div><div dir="ltr">clang -O0 does not disable all optimization passes modify the IR.; In fact it causes most functions to get tagged with noinline to prevent inlinining</div></div></blockquote><div><br></div></span><div>It also disable lifetime instrinsics emission and TBAA, etc.</div><span><div><br></div><br><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>What you really need to do is</div><div><br></div><div>clang -O3 -c emit-llvm -o source.bc -v</div><div><br></div><div>Find the -cc1 command line from that output. Execute that command with --disable-llvm-passes. leave the -O3 and everything else.</div></div></div></blockquote><div><br></div></span><div>That’s a bit complicated: CC1 options can be passed through with -Xclang, for example here just adding to the regular clang invocation ` -Xclang -disable-llvm-passes`</div><div><br></div><div>Best,</div><div><br></div><div>— </div><span class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168m_2034229146786603789m_-8339188297650556759m_9146112996686254187m_-1208587949809955168HOEnZb"><font color="#888888"><div>Mehdi</div></font></span><div><div class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168m_2034229146786603789m_-8339188297650556759m_9146112996686254187m_-1208587949809955168h5"><div><br></div><div><br></div><br><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>You should be able to feed the output from that command to opt/llc and get consistent results.</div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail-m_-6131269690400626558m_-9051171570230846072m_4808859684241924345m_4520465742095058517m_1805951627687733511m_-1831920260230003725m_3271370202522945238m_8864012440332563625m_3056629956437223643m_-4997143994764681168m_2034229146786603789m_-8339188297650556759m_9146112996686254187m_-1208587949809955168m_-6624049905980539258gmail_signature">~Craig</div></div>
<br><div class="gmail_quote">On Mon, Apr 10, 2017 at 4:57 PM, Peizhao Ou via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi folks,<div><br></div><div>I am wondering about the relationship clang, opt and llc. I understand that this has been asked, e.g., <a href="http://stackoverflow.com/questions/40350990/relationship-between-clang-opt-llc-and-llvm-linker" target="_blank">http://stackoverflow.com<wbr>/questions/40350990/relationsh<wbr>ip-between-clang-opt-llc-and-l<wbr>lvm-linker</a>. Sorry for posting a similar question again, but I still have something that hasn't been resolved yet.</div><div><br></div><div>More specifically I am wondering about the following two approaches compiling optimized executable:</div><div><br></div><div>1. clang -O3 -c source.c -o source.o</div><div>    ...</div><div>    clang a.o b.o c.o ... -o executable</div><div><br></div><div>2. clang -O0 -c -emit-llvm -o source.bc</div><div>    opt -O3 source.bc -o source.bc</div><div>    llc -O3 -filetype=obj source.bc -o source.o</div><div>    ...</div><div>    clang a.o b.o c.o ... -o executable<br></div><div><br></div><div>I took a look at the source code of the clang tool and the opt tool, they both seem to use the PassManagerBuilder::populateMo<wbr>dulePassManager() and PassManagerBuilder::populateFu<wbr>nctionPassManager() functions to add passes to their optimization pipeline; and for the backend, the clang and llc both use the addPassesToEmitFile() function to generate object code.</div><div><br></div><div>So presumably the above two approaches to generating optimized executable file should do the same thing. However, I am seeing that the second approach is around 2% slower than the first approach (which is the way developers usually use) pretty consistently.</div><div><br></div><div>Can anyone point me to the reasons why this happens? Or even correct my wrong understanding of the relationship between these two approaches?</div><div><br></div><div>PS: I used the -debug-pass=Structure option to print out the passes, they seem the same except that the first approach has an extra pass called "-add-discriminator", but I don't think that's the reason.</div><div><br></div><div>Peizhao</div>















</div>
<br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>
______________________________<wbr>_________________<br>LLVM Developers mailing list<br><a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br></div></blockquote></div></div></div><br></div></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div></div>
</blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div></div></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>