diff options
author | Pierre van Houtryve <pierre.vanhoutryve@amd.com> | 2024-06-19 09:07:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-19 09:07:11 +0200 |
commit | cb20d4d2054e72a2564572a74f34ca01cb791cbf (patch) | |
tree | cf1cc8a524a849c05a543592357d75fd96363d39 | |
parent | dadf960607bb429baebd3f523ce5b93260a154d2 (diff) | |
download | llvm-cb20d4d2054e72a2564572a74f34ca01cb791cbf.zip llvm-cb20d4d2054e72a2564572a74f34ca01cb791cbf.tar.gz llvm-cb20d4d2054e72a2564572a74f34ca01cb791cbf.tar.bz2 |
[NFC][CodeGen] Remove dead ParallelCG.h/.cpp API (#95770)
LTOBackend inlined it a while ago and now uses a static copy. This API
was unused.
We can always restore it at some point if it's needed, but right now
it's just bloat.
-rw-r--r-- | llvm/include/llvm/CodeGen/ParallelCG.h | 44 | ||||
-rw-r--r-- | llvm/lib/CodeGen/CMakeLists.txt | 1 | ||||
-rw-r--r-- | llvm/lib/CodeGen/ParallelCG.cpp | 95 | ||||
-rw-r--r-- | llvm/lib/LTO/LTOCodeGenerator.cpp | 1 | ||||
-rw-r--r-- | llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn | 1 |
5 files changed, 0 insertions, 142 deletions
diff --git a/llvm/include/llvm/CodeGen/ParallelCG.h b/llvm/include/llvm/CodeGen/ParallelCG.h deleted file mode 100644 index fc50dc1..0000000 --- a/llvm/include/llvm/CodeGen/ParallelCG.h +++ /dev/null @@ -1,44 +0,0 @@ -//===-- llvm/CodeGen/ParallelCG.h - Parallel code generation ----*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This header declares functions that can be used for parallel code generation. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CODEGEN_PARALLELCG_H -#define LLVM_CODEGEN_PARALLELCG_H - -#include "llvm/Support/CodeGen.h" -#include <functional> -#include <memory> - -namespace llvm { - -template <typename T> class ArrayRef; -class Module; -class TargetMachine; -class raw_pwrite_stream; - -/// Split M into OSs.size() partitions, and generate code for each. Takes a -/// factory function for the TargetMachine TMFactory. Writes OSs.size() output -/// files to the output streams in OSs. The resulting output files if linked -/// together are intended to be equivalent to the single output file that would -/// have been code generated from M. -/// -/// Writes bitcode for individual partitions into output streams in BCOSs, if -/// BCOSs is not empty. -void splitCodeGen( - Module &M, ArrayRef<raw_pwrite_stream *> OSs, - ArrayRef<llvm::raw_pwrite_stream *> BCOSs, - const std::function<std::unique_ptr<TargetMachine>()> &TMFactory, - CodeGenFileType FileType = CodeGenFileType::ObjectFile, - bool PreserveLocals = false); - -} // namespace llvm - -#endif diff --git a/llvm/lib/CodeGen/CMakeLists.txt b/llvm/lib/CodeGen/CMakeLists.txt index 1f5556e..41fc555 100644 --- a/llvm/lib/CodeGen/CMakeLists.txt +++ b/llvm/lib/CodeGen/CMakeLists.txt @@ -163,7 +163,6 @@ add_llvm_component_library(LLVMCodeGen MacroFusion.cpp NonRelocatableStringpool.cpp OptimizePHIs.cpp - ParallelCG.cpp PeepholeOptimizer.cpp PHIElimination.cpp PHIEliminationUtils.cpp diff --git a/llvm/lib/CodeGen/ParallelCG.cpp b/llvm/lib/CodeGen/ParallelCG.cpp deleted file mode 100644 index 8ab64f8..0000000 --- a/llvm/lib/CodeGen/ParallelCG.cpp +++ /dev/null @@ -1,95 +0,0 @@ -//===-- ParallelCG.cpp ----------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This file defines functions that can be used for parallel code generation. -// -//===----------------------------------------------------------------------===// - -#include "llvm/CodeGen/ParallelCG.h" -#include "llvm/Bitcode/BitcodeReader.h" -#include "llvm/Bitcode/BitcodeWriter.h" -#include "llvm/IR/LLVMContext.h" -#include "llvm/IR/LegacyPassManager.h" -#include "llvm/IR/Module.h" -#include "llvm/Support/MemoryBufferRef.h" -#include "llvm/Support/ThreadPool.h" -#include "llvm/Target/TargetMachine.h" -#include "llvm/Transforms/Utils/SplitModule.h" - -using namespace llvm; - -static void codegen(Module *M, llvm::raw_pwrite_stream &OS, - function_ref<std::unique_ptr<TargetMachine>()> TMFactory, - CodeGenFileType FileType) { - std::unique_ptr<TargetMachine> TM = TMFactory(); - assert(TM && "Failed to create target machine!"); - - legacy::PassManager CodeGenPasses; - if (TM->addPassesToEmitFile(CodeGenPasses, OS, nullptr, FileType)) - report_fatal_error("Failed to setup codegen"); - CodeGenPasses.run(*M); -} - -void llvm::splitCodeGen( - Module &M, ArrayRef<llvm::raw_pwrite_stream *> OSs, - ArrayRef<llvm::raw_pwrite_stream *> BCOSs, - const std::function<std::unique_ptr<TargetMachine>()> &TMFactory, - CodeGenFileType FileType, bool PreserveLocals) { - assert(BCOSs.empty() || BCOSs.size() == OSs.size()); - - if (OSs.size() == 1) { - if (!BCOSs.empty()) - WriteBitcodeToFile(M, *BCOSs[0]); - codegen(&M, *OSs[0], TMFactory, FileType); - return; - } - - // Create ThreadPool in nested scope so that threads will be joined - // on destruction. - { - DefaultThreadPool CodegenThreadPool(hardware_concurrency(OSs.size())); - int ThreadCount = 0; - - SplitModule( - M, OSs.size(), - [&](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 - // (while still on the main thread, in order to avoid data races) and - // spinning up new threads which deserialize the partitions into - // separate contexts. - // FIXME: Provide a more direct way to do this in LLVM. - SmallString<0> BC; - raw_svector_ostream BCOS(BC); - WriteBitcodeToFile(*MPart, BCOS); - - if (!BCOSs.empty()) { - BCOSs[ThreadCount]->write(BC.begin(), BC.size()); - BCOSs[ThreadCount]->flush(); - } - - llvm::raw_pwrite_stream *ThreadOS = OSs[ThreadCount++]; - // Enqueue the task - CodegenThreadPool.async( - [TMFactory, FileType, ThreadOS](const SmallString<0> &BC) { - LLVMContext Ctx; - Expected<std::unique_ptr<Module>> MOrErr = parseBitcodeFile( - MemoryBufferRef(BC.str(), "<split-module>"), Ctx); - if (!MOrErr) - report_fatal_error("Failed to read bitcode"); - std::unique_ptr<Module> MPartInCtx = std::move(MOrErr.get()); - - codegen(MPartInCtx.get(), *ThreadOS, TMFactory, FileType); - }, - // Pass BC using std::move to ensure that it get moved rather than - // copied into the thread's context. - std::move(BC)); - }, - PreserveLocals); - } -} diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp index 0611099..34aacb6 100644 --- a/llvm/lib/LTO/LTOCodeGenerator.cpp +++ b/llvm/lib/LTO/LTOCodeGenerator.cpp @@ -20,7 +20,6 @@ #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/Bitcode/BitcodeWriter.h" #include "llvm/CodeGen/CommandFlags.h" -#include "llvm/CodeGen/ParallelCG.h" #include "llvm/CodeGen/TargetSubtargetInfo.h" #include "llvm/Config/config.h" #include "llvm/IR/Constants.h" diff --git a/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn index 9068fa2..b3882fe 100644 --- a/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn +++ b/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn @@ -170,7 +170,6 @@ static_library("CodeGen") { "OptimizePHIs.cpp", "PHIElimination.cpp", "PHIEliminationUtils.cpp", - "ParallelCG.cpp", "PatchableFunction.cpp", "PeepholeOptimizer.cpp", "PostRAHazardRecognizer.cpp", |