[PATCH] D57985: [test-suite] Add cmake option to use IR PGO (TEST_SUITE_USE_IR_PGO)

Vedant Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 8 16:17:57 PST 2019


vsk created this revision.
vsk added reviewers: MatzeB, anemet, tejohnson, xur.
Herald added subscribers: dexonsmith, kristof.beyls, javed.absar, mehdi_amini, mgorny.
vsk retitled this revision from "Add cmake option to use IR PGO (TEST_SUITE_USE_IR_PGO)" to "[test-suite] Add cmake option to use IR PGO (TEST_SUITE_USE_IR_PGO)".

This allows building programs in the test suite with LLVM's IR PGO
feature. Support for re-building programs with the collected profdata is
already present.

E.g, to build for training:

  $ cmake -G Ninja -DCMAKE_C_COMPILER=$CC -C ~/src/llvm-test-suite/cmake/caches/target-arm64-iphoneos-internal.cmake -C ~/src/llvm-test-suite/cmake/caches/ReleaseLTO.cmake ~/src/llvm-test-suite -DTEST_SUITE_REMOTE_HOST=device -DTEST_SUITE_PROFILE_GENERATE=On -DTEST_SUITE_USE_IR_PGO=On -DTEST_SUITE_BENCHMARKING_ONLY=On -DTEST_SUITE_RUN_TYPE=train

To collect profile data: `ninja && ninja rsync && llvm-lit .`

To re-build with training data present, just re-configure and re-run ninja:

  $ cmake -G Ninja -DCMAKE_C_COMPILER=$CC -C ~/src/llvm-test-suite/cmake/caches/target-arm64-iphoneos-internal.cmake -C ~/src/llvm-test-suite/cmake/caches/ReleaseLTO.cmake ~/src/llvm-test-suite -DTEST_SUITE_REMOTE_HOST=device -DTEST_SUITE_PROFILE_GENERATE=Off -DTEST_SUITE_BENCHMARKING_ONLY=On -DTEST_SUITE_RUN_TYPE=ref -DTEST_SUITE_PROFILE_USE=On


https://reviews.llvm.org/D57985

Files:
  CMakeLists.txt
  litsupport/README.md


Index: litsupport/README.md
===================================================================
--- litsupport/README.md
+++ litsupport/README.md
@@ -70,7 +70,8 @@
   ssh to run benchmarks on a remote device (assuming shared file systems).
 - `cmake -DTEST_SUITE_PROFILE_GENERATE` compiles benchmark with
   `-fprofile-instr-generate` and enables the `profilegen` module that runs
-  `llvm-profdata` after running the benchmarks.
+  `llvm-profdata` after running the benchmarks. To use LLVM IR PGO instead of
+  the clang frontend's PGO feature, set `-DTEST_SUITE_USE_IR_PGO=On`.
 
 Available modules are found in the `litsupport/modules` directory.
 
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -94,6 +94,8 @@
   endif()
 endif()
 
+option(TEST_SUITE_USE_IR_PGO
+  "Use IR PGO instrumentation (requires TEST_SUITE_PROFILE_GENERATE)" OFF)
 
 # Enable profile generate mode in lit. Note that this does not automatically
 # add something like -fprofile-instr-generate to the compiler flags.
@@ -109,9 +111,15 @@
   endif()
 
   set(TEST_SUITE_PROFILE_GENERATE "True")
-  list(APPEND CFLAGS -fprofile-instr-generate)
-  list(APPEND CXXFLAGS -fprofile-instr-generate)
-  list(APPEND LDFLAGS -fprofile-instr-generate)
+
+  set(profile_instrumentation_flags -fprofile-instr-generate)
+  if(TEST_SUITE_USE_IR_PGO)
+    set(profile_instrumentation_flags -fprofile-generate)
+  endif()
+
+  list(APPEND CFLAGS   ${profile_instrumentation_flags})
+  list(APPEND CXXFLAGS ${profile_instrumentation_flags})
+  list(APPEND LDFLAGS  ${profile_instrumentation_flags})
 else()
   set(TEST_SUITE_PROFILE_GENERATE "False")
 endif()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57985.186067.patch
Type: text/x-patch
Size: 1701 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190209/9f86f1c9/attachment.bin>


More information about the llvm-commits mailing list