This is an archive of the discontinued LLVM Phabricator instance.

[cmake] Add an option to build llvm with IR PGO
ClosedPublic

Authored by vsk on Sep 19 2017, 5:50 PM.

Details

Summary

This adds an LLVM_ENABLE_IR_PGO option to enable building llvm and its tools with IR PGO instrumentation.

Usage: -DLLVM_BUILD_INSTRUMENTED=On -DLLVM_ENABLE_IR_PGO=On (both options must be enabled)

Diff Detail

Repository
rL LLVM

Event Timeline

vsk created this revision.Sep 19 2017, 5:50 PM
davidxl added inline comments.Sep 19 2017, 6:05 PM
cmake/modules/HandleLLVMOptions.cmake
751 ↗(On Diff #115938)

-fprofile-generate=<> is supported as well, why not using that?

vsk added inline comments.Sep 19 2017, 6:21 PM
cmake/modules/HandleLLVMOptions.cmake
751 ↗(On Diff #115938)

That flag treats its argument as a directory and appends '/default_%m.profraw'. It's not possible to use it along with LLVM_PROFILE_FILE_PATTERN off-the-shelf, as that would introduce multiple %Nm specifiers.

Would you prefer finding the dirname of LLVM_PROFILE_FILE_PATTERN, and using that instead?

davidxl added inline comments.Sep 19 2017, 6:50 PM
cmake/modules/HandleLLVMOptions.cmake
751 ↗(On Diff #115938)

"Would you prefer finding the dirname of LLVM_PROFILE_FILE_PATTERN, and using that instead?" -- that seems better -- to avoid exposing -fprofile-instrument-path

vsk updated this revision to Diff 115953.Sep 19 2017, 7:03 PM
vsk marked 3 inline comments as done.
  • Use -fprofile-generate=<data-dir> instead of a hidden frontend option. I tested this by building llvm-config with LLVM_BUILD_INSTRUMENTED and LLVM_ENABLE_IR_PGO -- both workflows lgtm.
vsk edited the summary of this revision. (Show Details)Sep 19 2017, 7:04 PM
vsk updated this revision to Diff 115956.Sep 19 2017, 7:25 PM
vsk edited the summary of this revision. (Show Details)
  • Make it possible to use LLVM_ENABLE_IR_PGO and LLVM_BUILD_INSTRUMENTED together. This will make it possible to use the Apple PGO cmake cache with IR PGO.
davidxl accepted this revision.Sep 19 2017, 7:28 PM

lgtm

This revision is now accepted and ready to land.Sep 19 2017, 7:28 PM
This revision was automatically updated to reflect the committed changes.