mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
Rewrite llvm-lto's codegen() using ThinCodeGenerator::run(). NFC-ish.
Differential Revision: https://reviews.llvm.org/D33360 llvm-svn: 303437
This commit is contained in:
parent
d0b8ae859d
commit
af6e8a6aed
@ -669,24 +669,30 @@ private:
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user