[PATCH] D62063: CMake changes to get Windows self-host with PGO working
Russell Gallop via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 17 06:40:09 PDT 2019
russell.gallop created this revision.
russell.gallop added reviewers: chandlerc, rnk, llvm-commits, xur.
russell.gallop added a project: LLVM.
Herald added a subscriber: mgorny.
This:
- Fixes quoting of profile arguments to work on Windows
- Suppresses adding profile arguments to linker flags when using lld-link
- Avoids -fprofile-instr-use being added to rc.exe flags
- Removes duplicated adding of -fprofile-instr-use to linker flags (since r355541)
- Move handling LLVM_PROFDATA_FILE to HandleLLVMOptions.cmake
Say if this should be split up further.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D62063
Files:
llvm/CMakeLists.txt
llvm/cmake/modules/HandleLLVMOptions.cmake
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -843,20 +843,30 @@
CMAKE_EXE_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS)
else()
- append("-fprofile-instr-generate='${LLVM_PROFILE_FILE_PATTERN}'"
+ append("-fprofile-instr-generate=\"${LLVM_PROFILE_FILE_PATTERN}\""
CMAKE_CXX_FLAGS
- CMAKE_C_FLAGS
- CMAKE_EXE_LINKER_FLAGS
- CMAKE_SHARED_LINKER_FLAGS)
+ CMAKE_C_FLAGS)
+ if(NOT LINKER_IS_LLD_LINK)
+ append("-fprofile-instr-generate=\"${LLVM_PROFILE_FILE_PATTERN}\""
+ CMAKE_EXE_LINKER_FLAGS
+ CMAKE_SHARED_LINKER_FLAGS)
+ endif()
endif()
endif()
-# Need to pass -fprofile-instr-use to linker for context-sensitive PGO
-# compilation.
if(LLVM_PROFDATA_FILE AND EXISTS ${LLVM_PROFDATA_FILE})
- append("-fprofile-instr-use='${LLVM_PROFDATA_FILE}'"
- CMAKE_EXE_LINKER_FLAGS
- CMAKE_SHARED_LINKER_FLAGS)
+ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
+ append("-fprofile-instr-use=\"${LLVM_PROFDATA_FILE}\""
+ CMAKE_CXX_FLAGS
+ CMAKE_C_FLAGS)
+ if(NOT LINKER_IS_LLD_LINK)
+ append("-fprofile-instr-use=\"${LLVM_PROFDATA_FILE}\""
+ CMAKE_EXE_LINKER_FLAGS
+ CMAKE_SHARED_LINKER_FLAGS)
+ endif()
+ else()
+ message(FATAL_ERROR "LLVM_PROFDATA_FILE can only be specified when compiling with clang")
+ endif()
endif()
option(LLVM_BUILD_INSTRUMENTED_COVERAGE "Build LLVM and tools with Code Coverage instrumentation" Off)
Index: llvm/CMakeLists.txt
===================================================================
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -648,6 +648,9 @@
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR OFF CACHE BOOL
"Enable per-target runtimes directory")
+set(LLVM_PROFDATA_FILE "" CACHE FILEPATH
+ "Profiling data file to use when compiling in order to improve runtime performance.")
+
# All options referred to from HandleLLVMOptions have to be specified
# BEFORE this include, otherwise options will not be correctly set on
# first cmake run
@@ -890,17 +893,6 @@
# use export_executable_symbols(target).
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
-set(LLVM_PROFDATA_FILE "" CACHE FILEPATH
- "Profiling data file to use when compiling in order to improve runtime performance.")
-
-if(LLVM_PROFDATA_FILE AND EXISTS ${LLVM_PROFDATA_FILE})
- if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
- add_definitions("-fprofile-instr-use=${LLVM_PROFDATA_FILE}")
- else()
- message(FATAL_ERROR "LLVM_PROFDATA_FILE can only be specified when compiling with clang")
- endif()
-endif()
-
include(AddLLVM)
include(TableGen)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62063.200032.patch
Type: text/x-patch
Size: 2760 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190517/4dcc1845/attachment.bin>
More information about the llvm-commits
mailing list