This is an archive of the discontinued LLVM Phabricator instance.

[Clang][CMake] Use perf-training for Clang-BOLT
ClosedPublic

Authored by Amir on Feb 7 2023, 11:01 PM.

Details

Summary

Leverage perf-training flow for BOLT profile collection, enabling reproducible
BOLT optimization. Remove the use of bootstrapped build for profile collection.

Test Plan:

  • Regular (single-stage) build
$ cmake ... -C .../clang/cmake/caches/BOLT.cmake
$ ninja clang-bolt
...
[21/24] Instrumenting clang binary with BOLT
[21/24] Generating BOLT profile for Clang
[23/24] Merging BOLT fdata
Profile from 2 files merged.
[24/24] Optimizing Clang with BOLT
... 
          1291202496 : executed instructions (-1.1%)
            27005133 : taken branches (-71.5%)
...
  • Two stage build (ThinLTO+InstPGO)
$ cmake ... -C .../clang/cmake/caches/BOLT.cmake -C .../clang/cmake/caches/BOLT-PGO.cmake
$ ninja clang-bolt
$ ninja stage2-clang-bolt
...
[2756/2759] Instrumenting clang binary with BOLT
[2756/2759] Generating BOLT profile for Clang
[2758/2759] Merging BOLT fdata
[2759/2759] Optimizing Clang with BOLT
...
BOLT-INFO: 7092 out of 184104 functions in the binary (3.9%) have non-empty execution profile
           756531927 : executed instructions (-0.5%)
            15399400 : taken branches (-40.3%)
...

Diff Detail

Event Timeline

Amir created this revision.Feb 7 2023, 11:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2023, 11:01 PM
Herald added a subscriber: wenlei. · View Herald Transcript
Amir requested review of this revision.Feb 7 2023, 11:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2023, 11:01 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
Amir retitled this revision from [Clang][CMake] Add BOLT perf-training (WIP) to [Clang][CMake] Add BOLT perf-training.Feb 8 2023, 12:15 PM
Amir edited the summary of this revision. (Show Details)
Amir added a reviewer: beanz.
Matt added a subscriber: Matt.Feb 8 2023, 12:33 PM
Amir updated this revision to Diff 495941.Feb 8 2023, 1:39 PM

Fixed BOLT-PGO build

Amir edited the summary of this revision. (Show Details)Feb 8 2023, 1:40 PM
Amir edited the summary of this revision. (Show Details)
Amir retitled this revision from [Clang][CMake] Add BOLT perf-training to [Clang][CMake] Use perf-training for Clang-BOLT.Feb 8 2023, 3:18 PM
Amir updated this revision to Diff 496274.Feb 9 2023, 4:05 PM
Amir edited the summary of this revision. (Show Details)

Remove sysroot_flags

Amir updated this revision to Diff 500956.Feb 27 2023, 4:01 PM

Rebase, reduce changes

beanz accepted this revision.May 13 2023, 12:54 AM

LGTM.

Sorry for the delays reviewing!

This revision is now accepted and ready to land.May 13 2023, 12:54 AM
Amir added a comment.May 13 2023, 10:34 AM

LGTM.

Sorry for the delays reviewing!

Thanks!

This revision was landed with ongoing or failed builds.May 13 2023, 10:36 AM
This revision was automatically updated to reflect the committed changes.