Peng Yu via llvm-dev
2019-Jan-20 17:28 UTC
[llvm-dev] Does specifying -O2 affect *0.0.preopt.bc when LDFLAGS=" -flto -fuse-ld=gold -Wl, -plugin-opt=save-temps "?
I use the following environment variables to hijack exiting make toolchain to generate bitcode files. CC=clang CXX=clang++ RANLIB=llvm-ranlib CPPFLAGS=" -g -flto " CFLAGS="-std=gnu99 " LDFLAGS=" -flto -fuse-ld=gold -Wl,-plugin-opt=save-temps " For the final executable myprog, I got the following files. But the original make toolchain may specify options like -O2. In this case, is myprog.0.0.preopt.bc still the same as if -O2 were not specified? Or myprog.0.0.preopt.bc would not be the same whether -O2 is specified or not. - myprog.0.0.preopt.bc - myprog.0.2.internalize.bc - myprog.0.4.opt.bc - myprog.0.5.precodegen.bc - myprog.o - myprog.resolution.txt -- Regards, Peng
Tim Northover via llvm-dev
2019-Jan-20 18:17 UTC
[llvm-dev] Does specifying -O2 affect *0.0.preopt.bc when LDFLAGS=" -flto -fuse-ld=gold -Wl, -plugin-opt=save-temps "?
On Sun, 20 Jan 2019 at 17:28, Peng Yu via llvm-dev <llvm-dev at lists.llvm.org> wrote:> For the final executable myprog, I got the following files. But the > original make toolchain may specify options like -O2. In this case, is > myprog.0.0.preopt.bc still the same as if -O2 were not specified? Or > myprog.0.0.preopt.bc would not be the same whether -O2 is specified or > not.Clang generates slightly different code based on the optimization level. It attaches specific attributes to each function generated for certain levels: -Oz --> "minsize" -Os --> "optsize" -O0 --> "optnone" (this is also the default). At -O, -O1, -O2 and -O3 no attribute gets attached. They're just handled by configuring LLVM slightly differently while running its passes. There may be other differences, but if so I'm not aware of them. Another question more suited for cfe-dev really. Cheers. Tim.