<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0);">
<div style="font-family: Calibri, sans-serif; font-size: 14px;">Thanks to you both. </div>
<div style="font-family: Calibri, sans-serif; font-size: 14px;"><br>
</div>
<div style="font-family: Calibri, sans-serif; font-size: 14px;">On my Linux (centos6) system, I have reproduce a variant of the bug and learned about </div>
<div style="font-family: Calibri, sans-serif; font-size: 14px;">   -plugin-opt=-debug-pass=Arguments</div>
<div style="font-family: Calibri, sans-serif; font-size: 14px;">which I infer from comments is intended to built arguments to “opt” however I found that some of the arguments don’t seem to be quite correct. I assume this just minor bit rot. </div>
<div style="font-family: Calibri, sans-serif; font-size: 14px;"><br>
</div>
<div>
<div><font face="Consolas"> bin/opt -o pass1.bc -datalayout -notti -basictti -x86tti -targetlibinfo -no-aa -tbaa -scoped-noalias -assumption-tracker -basicaa -verify -verify-di -ipsccp -globalopt -c\</font></div>
<div><font face="Consolas">onstmerge -deadargelim -instcombine -basiccg -inline-cost -inline -prune-eh -globalopt -globaldce -basiccg -argpromotion -instcombine -lazy-value-info -jump-threading -domt\</font></div>
<div><font face="Consolas">ree -sroa -basiccg -functionattrs -globalsmodref-aa -domtree -loops -loop-simplify -lcssa -licm -memdep -mldst-motion -domtree -memdep -gvn -memdep -memcpyopt -dse -loops -\</font></div>
<div><font face="Consolas">scalar-evolution -loop-simplify -lcssa -indvars -loop-deletion -branch-prob -block-freq -loop-vectorize -scalar-evolution -alignment-from-assumptions -instcombine -lazy-val\</font></div>
<div><font face="Consolas">ue-info -jump-threading -simplifycfg -globaldce -verify -verify-di bug17623a.o</font></div>
<div><font face="Consolas">opt: Unknown command line argument '-basictti'.  Try: 'bin/opt -help'</font></div>
<div><font face="Consolas">opt: Did you mean '-basiccg'?</font></div>
<div><font face="Consolas">opt: Unknown command line argument '-x86tti'.  Try: 'bin/opt -help'</font></div>
<div><font face="Consolas">opt: Did you mean '-notti'?</font></div>
<div><font face="Consolas">opt: Unknown command line argument '-verify-di'.  Try: 'bin/opt -help'</font></div>
<div><font face="Consolas">opt: Did you mean '-verify'?</font></div>
<div><font face="Consolas">opt: Unknown command line argument '-verify-di'.  Try: 'bin/opt -help'</font></div>
<div><font face="Consolas">opt: Did you mean '-verify'?</font></div>
</div>
<div style="font-family: Calibri, sans-serif; font-size: 14px;"><br>
</div>
<div style="font-family: Calibri, sans-serif; font-size: 14px;"><br>
</div>
<div style="font-family: Calibri, sans-serif; font-size: 14px;">On 1/5/15, 1:16 PM, "Duncan P. N. Exon Smith" <<a href="mailto:dexonsmith@apple.com">dexonsmith@apple.com</a>> wrote:</div>
<div style="font-family: Calibri, sans-serif; font-size: 14px;"><br>
</div>
<blockquote id="MAC_OUTLOOK_ATTRIBUTION_BLOCKQUOTE" style="font-family: Calibri, sans-serif; font-size: 14px; border-left-color: rgb(181, 196, 223); border-left-width: 5px; border-left-style: solid; padding: 0px 0px 0px 5px; margin: 0px 0px 0px 5px;">
<div><br>
</div>
<blockquote id="MAC_OUTLOOK_ATTRIBUTION_BLOCKQUOTE" style="BORDER-LEFT: #b5c4df 5 solid; PADDING:0 0 0 5; MARGIN:0 0 0 5;">
<div>On 2015-Jan-05, at 01:14, Bill Wendling <<a href="mailto:isanbard@gmail.com">isanbard@gmail.com</a>> wrote:</div>
<div></div>
<div>On Jan 3, 2015, at 11:52 PM, Bill Wendling <<a href="mailto:isanbard@gmail.com">isanbard@gmail.com</a>> wrote:</div>
<div></div>
<blockquote id="MAC_OUTLOOK_ATTRIBUTION_BLOCKQUOTE" style="BORDER-LEFT: #b5c4df 5 solid; PADDING:0 0 0 5; MARGIN:0 0 0 5;">
<div>On Jan 2, 2015, at 8:32 PM, David Callahan <<a href="mailto:dcallahan@fb.com">dcallahan@fb.com</a>> wrote:</div>
<div></div>
<blockquote id="MAC_OUTLOOK_ATTRIBUTION_BLOCKQUOTE" style="BORDER-LEFT: #b5c4df 5 solid; PADDING:0 0 0 5; MARGIN:0 0 0 5;">
<div>Hi,</div>
<div>  </div>
<div>I am new to the LLVM dev community so forgive a perhaps obvious question. I am looking at bug 17623 which is an LTO/optimizer interaction bug.  I am working on a Mac with Xcode installed but have also built the 3.6 LLVM binaries (from a few month old local
 branch).</div>
<div>  </div>
<div>The default version of “ld” from Apple supports an option “-save-temps” which I believe saves bitcode both before and after the optimizer (and the bug is visible as a difference between these two)</div>
<div>  </div>
<div>~/llvm-install/bin/clang -flto -O2 -c -o bug17623.o bug17623.c</div>
<div>"/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 -lSystem /Users/dcallahan/llvm-install/bin/..\</div>
<div>/lib/clang/3.6.0/lib/darwin/libclang_rt.osx.a -save-temps -o bug36 bug17623.o</div>
<div>  </div>
<div>(this produces bug36.lto.bc and bug36.lto.opt.bc)</div>
<div>  </div>
<div>However, if I use “opt” to try and duplicate the actions run by “ld”, as in:</div>
<div>  </div>
<div>~/llvm-install/bin/opt -O2 -o bug36.opt.bc bug36.lto.bc</div>
<div>  </div>
<div>This generates a different (much cleaner and correct!) output.</div>
<div>  </div>
<div>So my questions are:</div>
<div>1.     Is it feasible to get “opt” to reproduce the behavior of “ld”?</div>
</blockquote>
<div></div>
<div>The optimizations that occur during LTO (the ‘ld’ command) are different from the “normal” optimizations that opt runs. For one, LLVM has a view of the whole program, not just one compilation unit at a time. If you want to look at some of the optimizations
 that it performs, you can use the “opt -std-link-opts” command.</div>
<div></div>
<blockquote id="MAC_OUTLOOK_ATTRIBUTION_BLOCKQUOTE" style="BORDER-LEFT: #b5c4df 5 solid; PADDING:0 0 0 5; MARGIN:0 0 0 5;">
<div>2.     Assuming I am just missing some parameters to “opt”, how do I determine what they should be?</div>
</blockquote>
<div></div>
<div>The link time optimizations are enabled via the "-std-link-opts” option.</div>
<div></div>
</blockquote>
</blockquote>
<div><br>
</div>
<div>You might also need to add `-internalize-public-api-list` to prevent</div>
<div>functions like `main()` from getting internalized (and dead-stripped).</div>
<div><br>
</div>
<blockquote id="MAC_OUTLOOK_ATTRIBUTION_BLOCKQUOTE" style="BORDER-LEFT: #b5c4df 5 solid; PADDING:0 0 0 5; MARGIN:0 0 0 5;">
<div>I forgot to mention that you will need to link all of the .bc files together using 'llvm-link’ before you run ‘opt -std-link-opts’ on it.</div>
</blockquote>
<div><br>
</div>
<div>(If you're starting from bug36.lto.bc then they've already been linked.)</div>
</blockquote>
</body>
</html>