LLVM 22.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 {
19public:
20 // Inherit contructors from LTO base class.
21 using LTO::LTO;
22 ~DTLTO() { removeTempFiles(); }
23
24private:
25 // Bump allocator for a purpose of saving updated module IDs.
26 BumpPtrAllocator PtrAlloc;
27 StringSaver Saver{PtrAlloc};
28
29 // Removes temporary files.
30 LLVM_ABI void removeTempFiles();
31
32 // Determines if a file at the given path is a thin archive file.
33 Expected<bool> isThinArchive(const StringRef ArchivePath);
34
35 // Write the archive member content to a file named after the module ID.
36 Error saveInputArchiveMember(lto::InputFile *Input);
37
38 // Iterates through all input files and saves their content
39 // to files if they are regular archive members.
40 Error saveInputArchiveMembers();
41
42 // Array of input bitcode files for LTO.
43 std::vector<std::shared_ptr<lto::InputFile>> InputFiles;
44
45 // A cache to avoid repeatedly reading the same archive file.
46 StringMap<bool> ArchiveFiles;
47
48public:
49 // Adds the input file to the LTO object's list of input files.
50 // For archive members, generates a new module ID which is a path to a real
51 // file on a filesystem.
53 addInput(std::unique_ptr<lto::InputFile> InputPtr) override;
54
55 // Entry point for DTLTO archives support.
56 LLVM_ABI virtual llvm::Error handleArchiveInputs() override;
57};
58} // namespace lto
59} // namespace llvm
60
61#endif // LLVM_DTLTO_H
#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 LTO(Config Conf, ThinBackend Backend={}, unsigned ParallelCodeGenParallelismLevel=1, LTOKind LTOMode=LTOK_Default)
Create an LTO object.
Definition LTO.cpp:622
virtual LLVM_ABI llvm::Error handleArchiveInputs() override
Definition DTLTO.cpp:206
virtual LLVM_ABI Expected< std::shared_ptr< lto::InputFile > > addInput(std::unique_ptr< lto::InputFile > InputPtr) override
Definition DTLTO.cpp:135
An input file.
Definition LTO.h:113
LLVM_ABI LTO(Config Conf, ThinBackend Backend={}, unsigned ParallelCodeGenParallelismLevel=1, LTOKind LTOMode=LTOK_Default)
Create an LTO object.
Definition LTO.cpp:622
This is an optimization pass for GlobalISel generic memory operations.
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:383