mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.51k stars 1.6k forks source link

Add support for LLVM/clang when using b_pgo #5251

Open tpgxyz opened 5 years ago

tpgxyz commented 5 years ago

Please add option to detect and use LLVM/clang PGO flags and tools when b_pgo=generate/use is passed and when default compiler is set to LLVM/clang.

i.e. b_pgo=generate Set these:

LLVM_PROFILE_FILE=${name}-%p.profile.d
CFLAGS+= -fprofile-instr-generate
CXXFLAGS+= -fprofile-instr-generate
LDFLAGS+= -fprofile-instr-generate

When stage 1 is done, merge the profile data llvm-profdata merge --output ${name}.profile *.profile.d

b_pgo=use Set these:

CFLAGS+= -fprofile-instr-use=$(realpath ${name}.profile)
CXXFLAGS+= -fprofile-instr-use=$(realpath ${name}.profile)
LDFLAGS+= -fprofile-instr-use=$(realpath ${name}.profile)
ms178 commented 1 year ago

As BOLT makes the use of LLVM/Clang PGO even more attractive nowadays, support in Meson for PGO and BOLT would be great for easier integration (e.g. for super-optimized Mesa builds).

zamazan4ik commented 6 months ago

By the way, using -fprofile-instr-generate/-fprofile-instr-use (FrontEnd PGO aka FE PGO) in Clang is not recommended. Instead, -fprofile-generate/-fprofile-use (IR PGO) should be used.