mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
[lib/LTO] Try harder to reduce code duplication. NFCI.
llvm-svn: 281843
This commit is contained in:
parent
02f84f8e9d
commit
5be981977a
@ -41,6 +41,12 @@
|
||||
using namespace llvm;
|
||||
using namespace lto;
|
||||
|
||||
LLVM_ATTRIBUTE_NORETURN void reportOpenError(StringRef Path, Twine Msg) {
|
||||
errs() << "failed to open " << Path << ": " << Msg << '\n';
|
||||
errs().flush();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Error Config::addSaveTemps(std::string OutputFileName,
|
||||
bool UseInputModulePath) {
|
||||
ShouldDiscardValueNames = false;
|
||||
@ -71,13 +77,10 @@ Error Config::addSaveTemps(std::string OutputFileName,
|
||||
std::string Path = PathPrefix + "." + PathSuffix + ".bc";
|
||||
std::error_code EC;
|
||||
raw_fd_ostream OS(Path, EC, sys::fs::OpenFlags::F_None);
|
||||
if (EC) {
|
||||
// Because -save-temps is a debugging feature, we report the error
|
||||
// directly and exit.
|
||||
llvm::errs() << "failed to open " << Path << ": " << EC.message()
|
||||
<< '\n';
|
||||
exit(1);
|
||||
}
|
||||
if (EC)
|
||||
reportOpenError(Path, EC.message());
|
||||
WriteBitcodeToFile(&M, OS, /*ShouldPreserveUseListOrder=*/false);
|
||||
return true;
|
||||
};
|
||||
@ -94,12 +97,10 @@ Error Config::addSaveTemps(std::string OutputFileName,
|
||||
std::string Path = OutputFileName + "index.bc";
|
||||
std::error_code EC;
|
||||
raw_fd_ostream OS(Path, EC, sys::fs::OpenFlags::F_None);
|
||||
if (EC) {
|
||||
// Because -save-temps is a debugging feature, we report the error
|
||||
// directly and exit.
|
||||
llvm::errs() << "failed to open " << Path << ": " << EC.message() << '\n';
|
||||
exit(1);
|
||||
}
|
||||
if (EC)
|
||||
reportOpenError(Path, EC.message());
|
||||
WriteIndexToFile(Index, OS);
|
||||
return true;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user