43 "Failed to create file %s: %s",
Path.data(),
44 EC.message().c_str());
45 OS.write(Buffer.
data(), Buffer.
size());
48 "Failed writing to file %s",
Path.data());
57Expected<StringRef> normalizePath(StringRef Path, StringSaver &Saver) {
61 SmallString<256> Expanded;
64 "Normalization failed for path %s: %s",
65 Path.str().c_str(),
EC.message().c_str());
66 return Saver.
save(Expanded.
str());
68 return Saver.
save(Path);
76SmallString<256> computeThinArchiveMemberPath(StringRef ArchivePath,
77 StringRef MemberName) {
78 assert(!ArchivePath.
empty() &&
"An archive file path must be non empty.");
79 SmallString<256> MemberPath;
84 MemberPath = MemberName;
93Expected<bool> lto::DTLTO::isThinArchive(
const StringRef ArchivePath) {
95 auto Cached = ArchiveIsThinCache.
find(ArchivePath);
96 if (Cached != ArchiveIsThinCache.end())
97 return Cached->second;
99 uint64_t FileSize = -1;
103 "Failed to get file size from archive %s: %s",
104 ArchivePath.
data(),
EC.message().c_str());
107 "Archive file size is too small %s",
115 "Failed to read from archive %s: %s",
116 ArchivePath.
data(),
EC.message().c_str());
118 StringRef Buf = (*MBOrErr)->getBuffer();
121 "Unknown format for archive %s",
127 ArchiveIsThinCache[ArchivePath] = IsThin;
133Expected<std::shared_ptr<lto::InputFile>>
138 InputFiles.emplace_back(InputPtr.release());
139 auto &
Input = InputFiles.back();
143 auto N = normalizePath(Path, Saver);
145 return N.takeError();
157 if (ArchivePath.
empty() && !
Input->isFatLTOObject()) {
159 if (
Error E = setIdFromPath(
Input->getName()))
169 Input->isFatLTOObject() ?
false : isThinArchive(ArchivePath);
172 if (*UseThinMember) {
175 computeThinArchiveMemberPath(ArchivePath,
Input->getMemberName());
176 if (
Error E = setIdFromPath(MemberPath))
182 Input->setSerializeForDistribution(
true);
185 if (LinkerOutputDir.empty()) {
186 auto N = normalizePath(
189 return N.takeError();
190 LinkerOutputDir = *
N;
198 std::to_string(InputFiles.size()) +
206Error lto::DTLTO::serializeLTOInputs() {
207 for (
auto &
Input : InputFiles) {
208 if (!
Input->isThinLTO() || !
Input->getSerializeForDistribution())
212 TimeTraceScope TimeScope(
"Serialize bitcode input for DTLTO", ModuleId);
218 addToCleanup(ModuleId);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Provides a library for accessing information about this process and other processes on the operating ...
This file defines the SmallString class.
Represents a module in a bitcode file.
void setModuleIdentifier(llvm::StringRef ModuleId)
std::error_code getError() const
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
StringRef getBuffer() const
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileSlice(const Twine &Filename, uint64_t MapSize, uint64_t Offset, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Map a subrange of the specified file as a MemoryBuffer.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
size_t find(char C, size_t From=0) const
find - Search for the first character C in the string.
StringRef str() const
Explicit conversion to StringRef.
Represent a constant reference to a string, i.e.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
Check if the string is empty.
constexpr size_t size() const
Get the string size.
constexpr const char * data() const
Get a pointer to the start of the string (which may not be null terminated).
StringRef save(const char *S)
The TimeTraceScope is a helper class to call the begin and end functions of the time trace profiler.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM_ABI Expected< std::shared_ptr< InputFile > > addInput(std::unique_ptr< InputFile > InputPtr) override
Add an input file and prepare it for distribution.
static LLVM_ABI Pid getProcessId()
Get the process's identifier.
const char ThinArchiveMagic[]
std::error_code file_size(const Twine &Path, uint64_t &Result)
Get file size.
LLVM_ABI bool remove_dots(SmallVectorImpl< char > &path, bool remove_dot_dot=false, Style style=Style::native)
Remove '.
LLVM_ABI StringRef parent_path(StringRef path LLVM_LIFETIME_BOUND, Style style=Style::native)
Get parent path.
LLVM_ABI bool is_relative(const Twine &path, Style style=Style::native)
Is path relative?
LLVM_ABI StringRef filename(StringRef path LLVM_LIFETIME_BOUND, Style style=Style::native)
Get filename.
LLVM_ABI void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
LLVM_ABI std::error_code makeLongFormPath(const Twine &Path8, llvm::SmallVectorImpl< char > &Result8)
Convert a UTF-8 path to a long form UTF-8 path expanding any short 8.3 form components.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI file_magic identify_magic(StringRef magic)
Identify the type of a binary file based on how magical it is.
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
std::string utohexstr(uint64_t X, bool LowerCase=false, unsigned Width=0)
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
@ archive
ar style archive file