[PATCH] D38066: [cmake] Add an option to build llvm with IR PGO
Vedant Kumar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 19 17:55:35 PDT 2017
vsk created this revision.
Herald added a subscriber: mgorny.
This adds an LLVM_ENABLE_IR_PGO option to enable building llvm and its tools with IR PGO instrumentation.
The option uses the existing LLVM_PROFILE_FILE_PATTERN variable to figure out where to store profiles. There doesn't seem to be a driver option to specify where profiles go, so I've worked around this for now by using a clang frontend option.
https://reviews.llvm.org/D38066
Files:
CMakeLists.txt
cmake/modules/HandleLLVMOptions.cmake
Index: cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- cmake/modules/HandleLLVMOptions.cmake
+++ cmake/modules/HandleLLVMOptions.cmake
@@ -746,6 +746,14 @@
CMAKE_EXE_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS)
+option(LLVM_ENABLE_IR_PGO "Build LLVM and tools with IR PGO instrumentation (experimental)" Off)
+mark_as_advanced(LLVM_ENABLE_IR_PGO)
+append_if(LLVM_ENABLE_IR_PGO "-fprofile-generate -Xclang -fprofile-instrument-path='${LLVM_PROFILE_FILE_PATTERN}'"
+ CMAKE_CXX_FLAGS
+ CMAKE_C_FLAGS
+ CMAKE_EXE_LINKER_FLAGS
+ CMAKE_SHARED_LINKER_FLAGS)
+
if(LLVM_ENABLE_LTO AND LLVM_ON_WIN32 AND NOT LINKER_IS_LLD_LINK)
message(FATAL_ERROR "When compiling for Windows, LLVM_ENABLE_LTO requires using lld as the linker (point CMAKE_LINKER at lld-link.exe)")
endif()
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -548,7 +548,8 @@
set(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION FALSE CACHE INTERNAL "For Visual Studio 2013, manually copy natvis files to Documents\\Visual Studio 2013\\Visualizers" FORCE)
endif()
-if (LLVM_BUILD_INSTRUMENTED OR LLVM_BUILD_INSTRUMENTED_COVERAGE)
+if (LLVM_BUILD_INSTRUMENTED OR LLVM_BUILD_INSTRUMENTED_COVERAGE OR
+ LLVM_ENABLE_IR_PGO)
if(NOT LLVM_PROFILE_MERGE_POOL_SIZE)
# A pool size of 1-2 is probably sufficient on a SSD. 3-4 should be fine
# for spining disks. Anything higher may only help on slower mediums.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38066.115938.patch
Type: text/x-patch
Size: 1522 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170920/ffbf3bd8/attachment.bin>
More information about the llvm-commits
mailing list