From a4a8865fc226d068cf4fa8c51caf15dd0403c882 Mon Sep 17 00:00:00 2001 From: Hiroshi Yamauchi Date: Wed, 9 Dec 2020 15:04:55 -0800 Subject: [PATCH] [PGO] Adjust -vp-counters-per-site under dynamic linking. Addressing clang bootstrap under the dynamic linking mode running out of static allocation of value profile nodes, reported in D81682. Differential Revision: https://reviews.llvm.org/D92669 --- cmake/modules/HandleLLVMOptions.cmake | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake index 78ed1c06ac9..f313492ba97 100644 --- a/cmake/modules/HandleLLVMOptions.cmake +++ b/cmake/modules/HandleLLVMOptions.cmake @@ -917,6 +917,15 @@ if (LLVM_BUILD_INSTRUMENTED) CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) endif() + # Set this to avoid running out of the value profile node section + # under clang in dynamic linking mode. + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND + CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 11 AND + LLVM_LINK_LLVM_DYLIB) + append("-Xclang -mllvm -Xclang -vp-counters-per-site=1.5" + CMAKE_CXX_FLAGS + CMAKE_C_FLAGS) + endif() elseif(uppercase_LLVM_BUILD_INSTRUMENTED STREQUAL "CSIR") append("-fcs-profile-generate=\"${LLVM_CSPROFILE_DATA_DIR}\"" CMAKE_CXX_FLAGS