r278862 - [CMake] Workflow improvements to PGO generation

Chris Bieneman via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 16 15:16:29 PDT 2016


Author: cbieneman
Date: Tue Aug 16 17:16:29 2016
New Revision: 278862

URL: http://llvm.org/viewvc/llvm-project?rev=278862&view=rev
Log:
[CMake] Workflow improvements to PGO generation

This patch adds a few new convenience options used by the PGO CMake cache to setup options on bootstrap stages. The new options are:

PGO_INSTRUMENT_LTO - Builds the instrumented and final builds with LTO
PGO_BUILD_CONFIGURATION - Accepts a CMake cache script that can be used for complex configuration of the stage2-instrumented and stage2 builds.

The patch also includes a fix for bootstrap dependencies so that the instrumented LTO tools don't get used when building the final stage, and it adds distribution targets to the passthrough.

Modified:
    cfe/trunk/CMakeLists.txt
    cfe/trunk/cmake/caches/PGO-stage2-instrumented.cmake
    cfe/trunk/cmake/caches/PGO.cmake

Modified: cfe/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=278862&r1=278861&r2=278862&view=diff
==============================================================================
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Tue Aug 16 17:16:29 2016
@@ -571,11 +571,22 @@ if (CLANG_ENABLE_BOOTSTRAP)
   if(LLVM_BUILD_INSTRUMENTED)
     set(PGO_DEP generate-profdata)
     set(PGO_OPT -DLLVM_PROFDATA_FILE=${CMAKE_CURRENT_BINARY_DIR}/utils/perf-training/clang.profdata)
-    set(COMPILER_OPTIONS
-      -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-      -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-      -DCMAKE_ASM_COMPILER=${CMAKE_ASM_COMPILER})
+    # Use the current tools for LTO instead of the instrumented ones
+    list(APPEND _BOOTSTRAP_DEFAULT_PASSTHROUGH
+      CMAKE_CXX_COMPILER
+      CMAKE_C_COMPILER
+      CMAKE_ASM_COMPILER
+      CMAKE_AR
+      CMAKE_RANLIB
+      DARWIN_LTO_LIBRARY
+      DYLD_LIBRARY_PATH)
+
+    set(COMPILER_OPTIONS)
+    set(LTO_LIBRARY)
     set(RUNTIME_DEP) # Don't set runtime dependencies
+    set(LTO_DEP)     # Don't need to depend on LTO
+    set(LTO_AR)
+    set(LTO_RANLIB)
   endif()
 
   # Find all variables that start with BOOTSTRAP_ and populate a variable with

Modified: cfe/trunk/cmake/caches/PGO-stage2-instrumented.cmake
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/PGO-stage2-instrumented.cmake?rev=278862&r1=278861&r2=278862&view=diff
==============================================================================
--- cfe/trunk/cmake/caches/PGO-stage2-instrumented.cmake (original)
+++ cfe/trunk/cmake/caches/PGO-stage2-instrumented.cmake Tue Aug 16 17:16:29 2016
@@ -1,9 +1,21 @@
-set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
 set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
-set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "")
+set(CLANG_BOOTSTRAP_TARGETS
+  distribution
+  install-distribution
+  check-all
+  check-llvm
+  check-clang
+  test-suite CACHE STRING "")
 
-set(CLANG_BOOTSTRAP_TARGETS check-all check-llvm check-clang test-suite CACHE STRING "")
+if(PGO_BUILD_CONFIGURATION)
+  include(${PGO_BUILD_CONFIGURATION})
+  set(CLANG_BOOTSTRAP_CMAKE_ARGS
+    -C ${PGO_BUILD_CONFIGURATION}
+    CACHE STRING "")
+else()
+  include(${CMAKE_CURRENT_LIST_DIR}/PGO-stage2.cmake)
 
-set(CLANG_BOOTSTRAP_CMAKE_ARGS
-  -C ${CMAKE_CURRENT_LIST_DIR}/PGO-stage2.cmake
-  CACHE STRING "")
+  set(CLANG_BOOTSTRAP_CMAKE_ARGS
+    -C ${CMAKE_CURRENT_LIST_DIR}/PGO-stage2.cmake
+    CACHE STRING "")
+endif()

Modified: cfe/trunk/cmake/caches/PGO.cmake
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/PGO.cmake?rev=278862&r1=278861&r2=278862&view=diff
==============================================================================
--- cfe/trunk/cmake/caches/PGO.cmake (original)
+++ cfe/trunk/cmake/caches/PGO.cmake Tue Aug 16 17:16:29 2016
@@ -7,11 +7,23 @@ set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED ON
 set(CLANG_BOOTSTRAP_TARGETS
   generate-profdata
   stage2
+  stage2-distribution
+  stage2-install-distribution
   stage2-check-all
   stage2-check-llvm
   stage2-check-clang
   stage2-test-suite CACHE STRING "")
 
+if(PGO_INSTRUMENT_LTO)
+  set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
+  set(BOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
+endif()
+
+if(PGO_BUILD_CONFIGURATION)
+  set(EXTRA_ARGS -DPGO_BUILD_CONFIGURATION=${PGO_BUILD_CONFIGURATION})
+endif()
+
 set(CLANG_BOOTSTRAP_CMAKE_ARGS
+  ${EXTRA_ARGS}
   -C ${CMAKE_CURRENT_LIST_DIR}/PGO-stage2-instrumented.cmake
   CACHE STRING "")




More information about the cfe-commits mailing list