This is an archive of the discontinued LLVM Phabricator instance.

[CMake] Support a simple case for bootstrap builds to generate PGO data
ClosedPublic

Authored by beanz on Dec 16 2015, 12:33 PM.

Details

Summary

This patch adds support for the clang multi-stage bootstrapping to support PGO profdata generation, and can build a 2 or 3 stage compiler.

With this patch applied you can configure your build directory with the following invocation of CMake:

cmake -G <generator> -C <path_to_clang>/cmake/caches/PGO-stage1.cmake <source dir>

After configuration the following additional targets will be generated:

stage2:
Builds a stage1 x86 compiler, runtime, and required tools (llvm-config, llvm-profdata) then uses that compiler to build an instrumented stage2 compiler.

stage2-generate-profdata:
Depends on "stage2" and will use the stage2 compiler to generate profdata based on the training files in <clang>/utils/perf-training

stage3:
Depends on "stage2-generate-profdata" and will use the stage1 compiler with the stage2 profdata to build a PGO-optimized compiler.

stage3-check-llvm:
Depends on stage3 and runs check-llvm using the stage3 compiler.

stage3-check-clang:
Depends on stage3 and runs check-clang using the stage3 compiler.

stage3-check-all:
Depends on stage3 and runs check-all using the stage3 compiler.

stage3-test-suite:
Depends on stage3 and runs the test-suite using the stage3 compiler (requires in-tree test-suite).

Diff Detail

Repository
rL LLVM

Event Timeline

beanz updated this revision to Diff 43050.Dec 16 2015, 12:33 PM
beanz retitled this revision from to [CMake] Support a simple case for bootstrap builds to generate PGO data.
beanz updated this object.
beanz added reviewers: bogner, silvas, chandlerc.
beanz added a subscriber: cfe-commits.
beanz updated this revision to Diff 43177.Dec 17 2015, 1:30 PM

Updates based on bogner's feedback.

  • Target stages are now stage2-instrumented and stage2 instead of stage2 and stage3.
  • Renamed PGO-stage1.cmake to PGO.cmake
beanz updated this revision to Diff 43183.Dec 17 2015, 2:15 PM

Updating to fix a bug in my CMake regex handling that caused the targets to not be mapped up correctly.

beanz updated this revision to Diff 43192.Dec 17 2015, 3:22 PM

One more dependency hookup fix, this one makes it so that stage2 doesn't depend on the stage2-instrumented compiler-rt, and avoids building it when you invoke the 'stage2' target.

This revision was automatically updated to reflect the committed changes.
chandlerc edited edge metadata.Dec 18 2015, 5:37 PM
chandlerc added a subscriber: chandlerc.

Uh, did you intend to commit this prior to Justin or others giving an LGTM?