diff options
Diffstat (limited to 'llvm/tools')
-rw-r--r-- | llvm/tools/gold/gold-plugin.cpp | 8 | ||||
-rw-r--r-- | llvm/tools/llvm-lto2/llvm-lto2.cpp | 11 |
2 files changed, 9 insertions, 10 deletions
diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp index 123d90df890..38674d20717 100644 --- a/llvm/tools/gold/gold-plugin.cpp +++ b/llvm/tools/gold/gold-plugin.cpp @@ -831,11 +831,15 @@ static ld_plugin_status allSymbolsReadHook() { llvm::make_unique<llvm::raw_fd_ostream>(FD, true)); }; - auto AddFile = [&](size_t Task, StringRef Path) { Filenames[Task] = Path; }; + auto AddBuffer = [&](size_t Task, std::unique_ptr<MemoryBuffer> MB) { + // Note that this requires that the memory buffers provided to AddBuffer are + // backed by a file. + Filenames[Task] = MB->getBufferIdentifier(); + }; NativeObjectCache Cache; if (!options::cache_dir.empty()) - Cache = check(localCache(options::cache_dir, AddFile)); + Cache = check(localCache(options::cache_dir, AddBuffer)); check(Lto->run(AddStream, Cache)); diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp b/llvm/tools/llvm-lto2/llvm-lto2.cpp index 3fe0487476f..ce0f4b98425 100644 --- a/llvm/tools/llvm-lto2/llvm-lto2.cpp +++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp @@ -275,18 +275,13 @@ int main(int argc, char **argv) { return llvm::make_unique<lto::NativeObjectStream>(std::move(S)); }; - auto AddFile = [&](size_t Task, StringRef Path) { - auto ReloadedBufferOrErr = MemoryBuffer::getFile(Path); - if (auto EC = ReloadedBufferOrErr.getError()) - report_fatal_error(Twine("Can't reload cached file '") + Path + "': " + - EC.message() + "\n"); - - *AddStream(Task)->OS << (*ReloadedBufferOrErr)->getBuffer(); + auto AddBuffer = [&](size_t Task, std::unique_ptr<MemoryBuffer> MB) { + *AddStream(Task)->OS << MB->getBuffer(); }; NativeObjectCache Cache; if (!CacheDir.empty()) - Cache = check(localCache(CacheDir, AddFile), "failed to create cache"); + Cache = check(localCache(CacheDir, AddBuffer), "failed to create cache"); check(Lto.run(AddStream, Cache), "LTO::run failed"); } |