[PATCH] D151891: Allow configuring BOLT runtime instrumentation library max. allocation size
Jakub Beránek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 1 07:42:18 PDT 2023
Kobzol created this revision.
Kobzol added a reviewer: rafaelauler.
Herald added subscribers: ayermolo, JDevlieghere.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
Kobzol requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.
The BOLT instrumentation runtime uses a bump allocator that has a fixed amount of maximum memory. In some cases, this memory limit is not large enough (https://github.com/llvm/llvm-project/issues/59174). We are hitting this limit when instrumenting the Rust compiler with BOLT.
This change adds the option to configure the maximum allocation size using a CMake variable. I wasn't sure what's the best way how to parametrize this value, this approach is probably a bit convoluted. The BOLT runtime is a separate CMake project that is added as an external project, therefore propagating the configuration variable is also a bit complicated.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151891
Files:
bolt/CMakeLists.txt
bolt/runtime/CMakeLists.txt
bolt/runtime/instr.cpp
Index: bolt/runtime/instr.cpp
===================================================================
--- bolt/runtime/instr.cpp
+++ bolt/runtime/instr.cpp
@@ -206,7 +206,7 @@
private:
static constexpr uint64_t Magic = 0x1122334455667788ull;
- uint64_t MaxSize = 0xa00000;
+ uint64_t MaxSize = RUNTIME_MAX_MEMORY;
uint8_t *StackBase{nullptr};
uint64_t StackSize{0};
bool Shared{false};
Index: bolt/runtime/CMakeLists.txt
===================================================================
--- bolt/runtime/CMakeLists.txt
+++ bolt/runtime/CMakeLists.txt
@@ -14,6 +14,9 @@
instr.cpp
${CMAKE_CURRENT_BINARY_DIR}/config.h
)
+option(BOLT_RT_MAX_MEM "Maximum memory for runtime allocations.")
+target_compile_definitions(bolt_rt_instr PRIVATE RUNTIME_MAX_MEMORY=${BOLT_RT_MAX_MEM})
+
add_library(bolt_rt_hugify STATIC
hugify.cpp
${CMAKE_CURRENT_BINARY_DIR}/config.h
Index: bolt/CMakeLists.txt
===================================================================
--- bolt/CMakeLists.txt
+++ bolt/CMakeLists.txt
@@ -44,6 +44,8 @@
endif()
endif()
+option(BOLT_RT_MAX_MEM "Maximum memory for runtime allocations." 0xa00000)
+
if (BOLT_ENABLE_RUNTIME)
message(STATUS "Building BOLT runtime libraries for X86")
ExternalProject_Add(bolt_rt
@@ -55,7 +57,8 @@
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-DCMAKE_INSTALL_PREFIX=${LLVM_BINARY_DIR}
- BUILD_ALWAYS True
+ -DBOLT_RT_MAX_MEM=${BOLT_RT_MAX_MEM}
+ BUILD_ALWAYS True
)
install(CODE "execute_process\(COMMAND \${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX} -P ${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-bins/cmake_install.cmake \)"
COMPONENT bolt)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151891.527417.patch
Type: text/x-patch
Size: 1755 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230601/6e4cc05b/attachment.bin>
More information about the llvm-commits
mailing list