summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2016-09-17 22:32:42 +0000
committerDavide Italiano <davide@freebsd.org>2016-09-17 22:32:42 +0000
commita416d11357983f07a9ee002f1f8c825287f6b324 (patch)
treecce85a83ac00b83fe824b32511f330f87814b64a
parentaeb764a7b7bfbd856195f89edf7374cdc78f0eea (diff)
downloadbcm5719-llvm-a416d11357983f07a9ee002f1f8c825287f6b324.tar.gz
bcm5719-llvm-a416d11357983f07a9ee002f1f8c825287f6b324.zip
[lib/LTO] Try harder to reduce code duplication. NFCI.
llvm-svn: 281843
-rw-r--r--llvm/lib/LTO/LTOBackend.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index 9e53972a9d4..d83b65de4cc 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -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);
- }
+ // Because -save-temps is a debugging feature, we report the error
+ // directly and exit.
+ 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);
- }
+ // Because -save-temps is a debugging feature, we report the error
+ // directly and exit.
+ if (EC)
+ reportOpenError(Path, EC.message());
WriteIndexToFile(Index, OS);
return true;
};
OpenPOWER on IntegriCloud