diff options
author | Pierre van Houtryve <pierre.vanhoutryve@amd.com> | 2024-04-22 08:59:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-22 08:59:18 +0200 |
commit | e86ebe4ff8705ef30b332e2104ed1c84fc729966 (patch) | |
tree | b72757aa7482dd7e2c8e7cd47845c3c7a939251a /llvm/lib/LTO/LTOBackend.cpp | |
parent | 2a47ee070145438424b065a35c4a680ea0cb0c1f (diff) | |
download | llvm-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.cpp | 13 |
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 |