[llvm] [PGO]add bitcode-use-sample-profile (PR #66178)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 13 19:24:48 PDT 2023


lifengxiang1025 wrote:

@teresajohnson @WenleiHe @htyu @huangjd 
Sorry for implicit description.
For example,
I have foo.cpp and bar.cpp and steps as follow:
```
1. clang++ -c foo.cpp -flto=thin -o foo.o
   clang++ -c bar.cpp -flto=thin -o bar.o
3. ar libtest.a foo.o bar.o
4. ar x libtest.a
5. clang++ -x ir foo.o -flto=thin -fprofile-sample-use=xxx -o foo.o.o
    clang++ -x ir bar.o -flto=thin -fprofile-sample-use=xxx -o bar.o.o
7. thinlink->thinbackend->final link
```
In step 5. Because function doesn't have attribute "use-sample-profile". It can't do pgo's optimation. 
Only if in step1, add flags "-fprofile-sample-use=xxx". Function could have attribute "use-sample-profile".
This example happens when project use some third party libraries. I want to generate those third party libraries to bitcode archive and then do some optimation like pgo and thinlto. 

https://github.com/llvm/llvm-project/pull/66178


More information about the llvm-commits mailing list