This is intended to reduce the binary size of both phase 1 and phase 2 builds.
By compiling chrome on Windows (using -Os in both phases), the binary size of phase 1 is reduced by 27.5% and binary size of phase 2 is reduced by 8.4%.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This is probably OK for -Os (SizeLevel == 1), but we need to be careful with Oz (SizeLevel == 2).
We already know that enabling preinliner in general will reduce size -- as the preinliner is pretty conservative. But there will be cases size will be increased.
I would like more test results (like bootstrap clang) before committing.
Zequan, to build clang with PGO, you can follow the steps in Chrome's script to build clang with PGO:
https://source.chromium.org/chromium/chromium/src/+/master:tools/clang/scripts/build.py;l=703?q=clang%2Fscripts%2F%20build.py&ss=chromium
Regarding -Oz / minsize / SizeLevel 2, what we have discovered is that *not* running the preinliner makes the instrumented binary almost unusably large. Even if 75 is the wrong inline threshold for minsize, it's better than not running the preinliner. I think we should run with it.
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp | ||
---|---|---|
334 | This code is duplicated for the NPM and the old PM. Please keep them in sync. |
I don't see binary size difference (<1%), when bootstrap clang with this change. I was using steps at https://llvm.org/docs/HowToBuildWithPGO.html#building-clang-with-pgo.
Thanks, my concerns are addressed, and I believe @xur's are as well. Please wait for his input before landing, though.
Sorry to the late response (I somehow missed the reply).
(1) Can we add some comments to explain the reason for enabling this for -Oz -- I think the comments from @rnk is useful to some people (at least to me).
(2) Also please add a testcase.
Feel free to commit to address the above two issues.
I see two pre-commit test failures on the patch. Can you take a look at those as well?
This code is duplicated for the NPM and the old PM. Please keep them in sync.