aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/LTO/LTOBackend.cpp
diff options
context:
space:
mode:
authorPierre van Houtryve <pierre.vanhoutryve@amd.com>2024-04-22 08:59:18 +0200
committerGitHub <noreply@github.com>2024-04-22 08:59:18 +0200
commite86ebe4ff8705ef30b332e2104ed1c84fc729966 (patch)
treeb72757aa7482dd7e2c8e7cd47845c3c7a939251a /llvm/lib/LTO/LTOBackend.cpp
parent2a47ee070145438424b065a35c4a680ea0cb0c1f (diff)
downloadllvm-e86ebe4ff8705ef30b332e2104ed1c84fc729966.zip
llvm-e86ebe4ff8705ef30b332e2104ed1c84fc729966.tar.gz
llvm-e86ebe4ff8705ef30b332e2104ed1c84fc729966.tar.bz2
[LTO] Allow target-specific module splittting (#83128)
Allow targets to implement custom module splitting logic for --lto-partitions, see #89245 https://discourse.llvm.org/t/rfc-lto-target-specific-module-splittting/77252
Diffstat (limited to 'llvm/lib/LTO/LTOBackend.cpp')
-rw-r--r--llvm/lib/LTO/LTOBackend.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index 71e8849..d4b89ed 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -436,8 +436,7 @@ static void splitCodeGen(const Config &C, TargetMachine *TM,
unsigned ThreadCount = 0;
const Target *T = &TM->getTarget();
- SplitModule(
- Mod, ParallelCodeGenParallelismLevel,
+ const auto HandleModulePartition =
[&](std::unique_ptr<Module> MPart) {
// We want to clone the module in a new context to multi-thread the
// codegen. We do it by serializing partition modules to bitcode
@@ -469,8 +468,14 @@ static void splitCodeGen(const Config &C, TargetMachine *TM,
// Pass BC using std::move to ensure that it get moved rather than
// copied into the thread's context.
std::move(BC), ThreadCount++);
- },
- false);
+ };
+
+ // Try target-specific module splitting first, then fallback to the default.
+ if (!TM->splitModule(Mod, ParallelCodeGenParallelismLevel,
+ HandleModulePartition)) {
+ SplitModule(Mod, ParallelCodeGenParallelismLevel, HandleModulePartition,
+ false);
+ }
// Because the inner lambda (which runs in a worker thread) captures our local
// variables, we need to wait for the worker threads to terminate before we