Hi, 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). 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) ~/llvm-install/bin/clang -flto -O2 -c -o bug17623.o bug17623.c "/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 -lSystem /Users/dcallahan/llvm-install/bin/..\ /lib/clang/3.6.0/lib/darwin/libclang_rt.osx.a -save-temps -o bug36 bug17623.o (this produces bug36.lto.bc and bug36.lto.opt.bc) However, if I use “opt” to try and duplicate the actions run by “ld”, as in: ~/llvm-install/bin/opt -O2 -o bug36.opt.bc bug36.lto.bc This generates a different (much cleaner and correct!) output. So my questions are: 1. Is it feasible to get “opt” to reproduce the behavior of “ld”? 2. Assuming I am just missing some parameters to “opt”, how do I determine what they should be? Thanks David -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150103/753549c7/attachment.html>
On Jan 2, 2015, at 8:32 PM, David Callahan <dcallahan at fb.com> wrote:> Hi, > > 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). > > 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) > > ~/llvm-install/bin/clang -flto -O2 -c -o bug17623.o bug17623.c > "/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 -lSystem /Users/dcallahan/llvm-install/bin/..\ > /lib/clang/3.6.0/lib/darwin/libclang_rt.osx.a -save-temps -o bug36 bug17623.o > > (this produces bug36.lto.bc and bug36.lto.opt.bc) > > However, if I use “opt” to try and duplicate the actions run by “ld”, as in: > > ~/llvm-install/bin/opt -O2 -o bug36.opt.bc bug36.lto.bc > > This generates a different (much cleaner and correct!) output. > > So my questions are: > 1. Is it feasible to get “opt” to reproduce the behavior of “ld”?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.> 2. Assuming I am just missing some parameters to “opt”, how do I determine what they should be?The link time optimizations are enabled via the "-std-link-opts” option. -bw -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150103/d053aad4/attachment.html>
On Jan 3, 2015, at 11:52 PM, Bill Wendling <isanbard at gmail.com> wrote:> On Jan 2, 2015, at 8:32 PM, David Callahan <dcallahan at fb.com> wrote: > >> Hi, >> >> 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). >> >> 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) >> >> ~/llvm-install/bin/clang -flto -O2 -c -o bug17623.o bug17623.c >> "/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 -lSystem /Users/dcallahan/llvm-install/bin/..\ >> /lib/clang/3.6.0/lib/darwin/libclang_rt.osx.a -save-temps -o bug36 bug17623.o >> >> (this produces bug36.lto.bc and bug36.lto.opt.bc) >> >> However, if I use “opt” to try and duplicate the actions run by “ld”, as in: >> >> ~/llvm-install/bin/opt -O2 -o bug36.opt.bc bug36.lto.bc >> >> This generates a different (much cleaner and correct!) output. >> >> So my questions are: >> 1. Is it feasible to get “opt” to reproduce the behavior of “ld”? > > 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. > >> 2. Assuming I am just missing some parameters to “opt”, how do I determine what they should be? > > The link time optimizations are enabled via the "-std-link-opts” option. >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. -bw -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150105/908c314b/attachment.html>
tools/llvm-lto should get you pretty close. On Fri, Jan 2, 2015 at 8:32 PM, David Callahan <dcallahan at fb.com> wrote:> Hi, > > > > 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). > > > > 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) > > > > ~/llvm-install/bin/clang -flto -O2 -c -o bug17623.o bug17623.c > > "/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 > -lSystem /Users/dcallahan/llvm-install/bin/..\ > > /lib/clang/3.6.0/lib/darwin/libclang_rt.osx.a -save-temps -o bug36 > bug17623.o > > > > (this produces bug36.lto.bc and bug36.lto.opt.bc) > > > > However, if I use “opt” to try and duplicate the actions run by “ld”, as > in: > > > > ~/llvm-install/bin/opt -O2 -o bug36.opt.bc bug36.lto.bc > > > > This generates a different (much cleaner and correct!) output. > > > > So my questions are: > > 1. Is it feasible to get “opt” to reproduce the behavior of “ld”? > > 2. Assuming I am just missing some parameters to “opt”, how do I > determine what they should be? > > Thanks > > David > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150105/6559e7a1/attachment.html>
> On 2015-Jan-05, at 12:59, Sean Silva <chisophugis at gmail.com> wrote: > > tools/llvm-lto should get you pretty close.Be aware that unless you tell `llvm-lto` to hang on to specific symbols, LTO can dead-strip them after -internalize. Try adding -exported-symbol=_main if you're hitting this.> On Fri, Jan 2, 2015 at 8:32 PM, David Callahan <dcallahan at fb.com> wrote: > Hi, > > > > 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). > > > > 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) > > > > ~/llvm-install/bin/clang -flto -O2 -c -o bug17623.o bug17623.c > > "/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 -lSystem /Users/dcallahan/llvm-install/bin/..\ > > /lib/clang/3.6.0/lib/darwin/libclang_rt.osx.a -save-temps -o bug36 bug17623.o > > > > (this produces bug36.lto.bc and bug36.lto.opt.bc) > > > > However, if I use “opt” to try and duplicate the actions run by “ld”, as in: > > > > ~/llvm-install/bin/opt -O2 -o bug36.opt.bc bug36.lto.bc > > > > This generates a different (much cleaner and correct!) output. > > > > So my questions are: > > 1. Is it feasible to get “opt” to reproduce the behavior of “ld”? > > 2. Assuming I am just missing some parameters to “opt”, how do I determine what they should be? > > Thanks > > David > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev