[PATCH] D33360: Rewrite llvm-lto's codegen() using ThinCodeGenerator::run(). NFC-ish.
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 19 11:08:33 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303437: Rewrite llvm-lto's codegen() using ThinCodeGenerator::run(). NFC-ish. (authored by adrian).
Changed prior to commit:
https://reviews.llvm.org/D33360?vs=99579&id=99598#toc
Repository:
rL LLVM
https://reviews.llvm.org/D33360
Files:
llvm/trunk/tools/llvm-lto/llvm-lto.cpp
Index: llvm/trunk/tools/llvm-lto/llvm-lto.cpp
===================================================================
--- llvm/trunk/tools/llvm-lto/llvm-lto.cpp
+++ llvm/trunk/tools/llvm-lto/llvm-lto.cpp
@@ -669,24 +669,30 @@
if (!ThinLTOIndex.empty())
errs() << "Warning: -thinlto-index ignored for codegen stage";
+ std::vector<std::unique_ptr<MemoryBuffer>> InputBuffers;
for (auto &Filename : InputFilenames) {
LLVMContext Ctx;
- auto TheModule = loadModule(Filename, Ctx);
-
- auto Buffer = ThinGenerator.codegen(*TheModule);
+ auto InputOrErr = MemoryBuffer::getFile(Filename);
+ error(InputOrErr, "error " + CurrentActivity);
+ InputBuffers.push_back(std::move(*InputOrErr));
+ ThinGenerator.addModule(Filename, InputBuffers.back()->getBuffer());
+ }
+ ThinGenerator.setCodeGenOnly(true);
+ ThinGenerator.run();
+ for (auto BinName :
+ zip(ThinGenerator.getProducedBinaries(), InputFilenames)) {
std::string OutputName = OutputFilename;
- if (OutputName.empty()) {
- OutputName = Filename + ".thinlto.o";
- }
- if (OutputName == "-") {
- outs() << Buffer->getBuffer();
+ if (OutputName.empty())
+ OutputName = std::get<1>(BinName) + ".thinlto.o";
+ else if (OutputName == "-") {
+ outs() << std::get<0>(BinName)->getBuffer();
return;
}
std::error_code EC;
raw_fd_ostream OS(OutputName, EC, sys::fs::OpenFlags::F_None);
error(EC, "error opening the file '" + OutputName + "'");
- OS << Buffer->getBuffer();
+ OS << std::get<0>(BinName)->getBuffer();
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33360.99598.patch
Type: text/x-patch
Size: 1654 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170519/4e4c4b8d/attachment.bin>
More information about the llvm-commits
mailing list