LLVM 23.0.0git
DTLTO.h
Go to the documentation of this file.
1//===- DTLTO.h - Distributed ThinLTO functions and classes ----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===---------------------------------------------------------------------===//
8
9#ifndef LLVM_DTLTO_H
10#define LLVM_DTLTO_H
11
12#include "llvm/LTO/LTO.h"
14
15namespace llvm {
16namespace lto {
17
18class DTLTO : public LTO {
19 using Base = LTO;
20
21public:
23 unsigned ParallelCodeGenParallelismLevel, LTOKind LTOMode,
24 StringRef LinkerOutputFile, bool SaveTemps)
25 : Base(std::move(Conf), Backend, ParallelCodeGenParallelismLevel,
26 LTOMode),
27 LinkerOutputFile(LinkerOutputFile), SaveTemps(SaveTemps) {
28 assert(!LinkerOutputFile.empty() && "expected a valid linker output file");
29 }
30
31 // Add an input file and prepare it for distribution.
33 addInput(std::unique_ptr<InputFile> InputPtr) override;
34
35protected:
37
38 LLVM_ABI void cleanup() override;
39
40private:
41 // Bump allocator for a purpose of saving updated module IDs.
42 BumpPtrAllocator PtrAlloc;
43 StringSaver Saver{PtrAlloc};
44
45 /// The output file to which this LTO invocation will contribute.
46 StringRef LinkerOutputFile;
47
48 /// Controls preservation of any created temporary files.
49 bool SaveTemps;
50
51 // Determines if a file at the given path is a thin archive file.
52 Expected<bool> isThinArchive(const StringRef ArchivePath);
53
54 // Write the archive member content to a file named after the module ID.
55 Error saveInputArchiveMember(lto::InputFile *Input);
56
57 // Iterates through all input files and saves their content
58 // to files if they are regular archive members.
59 Error saveInputArchiveMembers();
60
61 // Array of input bitcode files for LTO.
62 std::vector<std::shared_ptr<lto::InputFile>> InputFiles;
63
64 // A cache to avoid repeatedly reading the same archive file.
65 StringMap<bool> ArchiveFiles;
66};
67
68} // namespace lto
69} // namespace llvm
70
71#endif // LLVM_DTLTO_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_ABI
Definition Compiler.h:213
The Input class is used to parse a yaml document into in-memory structs and vectors.
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Tagged union holding either a T or a Error.
Definition Error.h:485
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition StringMap.h:133
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
Definition StringSaver.h:22
LLVM_ABI void cleanup() override
Definition DTLTO.cpp:217
LLVM_ABI llvm::Error handleArchiveInputs() override
Definition DTLTO.cpp:208
LLVM_ABI Expected< std::shared_ptr< InputFile > > addInput(std::unique_ptr< InputFile > InputPtr) override
Definition DTLTO.cpp:126
LLVM_ABI DTLTO(Config Conf, ThinBackend Backend, unsigned ParallelCodeGenParallelismLevel, LTOKind LTOMode, StringRef LinkerOutputFile, bool SaveTemps)
Definition DTLTO.h:22
An input file.
Definition LTO.h:114
LLVM_ABI LTO(Config Conf, ThinBackend Backend={}, unsigned ParallelCodeGenParallelismLevel=1, LTOKind LTOMode=LTOK_Default)
Create an LTO object.
Definition LTO.cpp:629
LTOKind
Unified LTO modes.
Definition LTO.h:419
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1915
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:383
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:870
LTO configuration.
Definition Config.h:42
This type defines the behavior following the thin-link phase during ThinLTO.
Definition LTO.h:317