llvm.org GIT mirror llvm / a080536
[cmake] Add an option to build llvm with IR PGO This adds an LLVM_ENABLE_IR_PGO option to enable building llvm and its tools with IR PGO instrumentation. Usage: -DLLVM_BUILD_INSTRUMENTED=On -DLLVM_ENABLE_IR_PGO=On (both options must be enabled) Differential Revision: https://reviews.llvm.org/D38066 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313770 91177308-0d34-0410-b5e6-96231b3b80d8 Vedant Kumar 2 years ago
2 changed file(s) with 23 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
547547 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)
548548 endif()
549549
550 if (LLVM_BUILD_INSTRUMENTED OR LLVM_BUILD_INSTRUMENTED_COVERAGE)
550 if (LLVM_BUILD_INSTRUMENTED OR LLVM_BUILD_INSTRUMENTED_COVERAGE OR
551 LLVM_ENABLE_IR_PGO)
551552 if(NOT LLVM_PROFILE_MERGE_POOL_SIZE)
552553 # A pool size of 1-2 is probably sufficient on a SSD. 3-4 should be fine
553554 # for spining disks. Anything higher may only help on slower mediums.
555556 endif()
556557 if(NOT LLVM_PROFILE_FILE_PATTERN)
557558 if(NOT LLVM_PROFILE_DATA_DIR)
558 file(TO_NATIVE_PATH "${LLVM_BINARY_DIR}/profiles/%${LLVM_PROFILE_MERGE_POOL_SIZE}m.profraw" LLVM_PROFILE_FILE_PATTERN)
559 else()
560 file(TO_NATIVE_PATH "${LLVM_PROFILE_DATA_DIR}/%${LLVM_PROFILE_MERGE_POOL_SIZE}m.profraw" LLVM_PROFILE_FILE_PATTERN)
559 file(TO_NATIVE_PATH "${LLVM_BINARY_DIR}/profiles" LLVM_PROFILE_DATA_DIR)
561560 endif()
561 file(TO_NATIVE_PATH "${LLVM_PROFILE_DATA_DIR}/%${LLVM_PROFILE_MERGE_POOL_SIZE}m.profraw" LLVM_PROFILE_FILE_PATTERN)
562562 endif()
563563 endif()
564564
729729 message(FATAL_ERROR "Exception handling requires RTTI. You must set LLVM_ENABLE_RTTI to ON")
730730 endif()
731731
732 option(LLVM_ENABLE_IR_PGO "Build LLVM and tools with IR PGO instrumentation (experimental)" Off)
733 mark_as_advanced(LLVM_ENABLE_IR_PGO)
734
732735 option(LLVM_BUILD_INSTRUMENTED "Build LLVM and tools with PGO instrumentation" Off)
733736 mark_as_advanced(LLVM_BUILD_INSTRUMENTED)
734 append_if(LLVM_BUILD_INSTRUMENTED "-fprofile-instr-generate='${LLVM_PROFILE_FILE_PATTERN}'"
735 CMAKE_CXX_FLAGS
736 CMAKE_C_FLAGS
737 CMAKE_EXE_LINKER_FLAGS
738 CMAKE_SHARED_LINKER_FLAGS)
737
738 if (LLVM_BUILD_INSTRUMENTED)
739 if (LLVM_ENABLE_IR_PGO)
740 append("-fprofile-generate='${LLVM_PROFILE_DATA_DIR}'"
741 CMAKE_CXX_FLAGS
742 CMAKE_C_FLAGS
743 CMAKE_EXE_LINKER_FLAGS
744 CMAKE_SHARED_LINKER_FLAGS)
745 else()
746 append("-fprofile-instr-generate='${LLVM_PROFILE_FILE_PATTERN}'"
747 CMAKE_CXX_FLAGS
748 CMAKE_C_FLAGS
749 CMAKE_EXE_LINKER_FLAGS
750 CMAKE_SHARED_LINKER_FLAGS)
751 endif()
752 endif()
739753
740754 option(LLVM_BUILD_INSTRUMENTED_COVERAGE "Build LLVM and tools with Code Coverage instrumentation" Off)
741755 mark_as_advanced(LLVM_BUILD_INSTRUMENTED_COVERAGE)