summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2016-04-13 22:08:26 +0000
committerDavide Italiano <davide@freebsd.org>2016-04-13 22:08:26 +0000
commit1eea9bd86ce0c1f58dac675ee8c3db7b0c00006b (patch)
tree0b26716e66dfb9d76a90f72526906b48c7f458af /llvm/tools
parentaa165cf75966e8b208943a5e912a8893206d8935 (diff)
downloadbcm5719-llvm-1eea9bd86ce0c1f58dac675ee8c3db7b0c00006b.tar.gz
bcm5719-llvm-1eea9bd86ce0c1f58dac675ee8c3db7b0c00006b.zip
[llvm-lto] Uniform error handling. NFC.
llvm-svn: 266255
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llvm-lto/llvm-lto.cpp44
1 files changed, 14 insertions, 30 deletions
diff --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp
index bfc7464879e..22532f520dd 100644
--- a/llvm/tools/llvm-lto/llvm-lto.cpp
+++ b/llvm/tools/llvm-lto/llvm-lto.cpp
@@ -603,9 +603,7 @@ int main(int argc, char **argv) {
CodeGen.setModule(std::move(Module));
} else if (!CodeGen.addModule(Module.get())) {
// Print a message here so that we know addModule() did not abort.
- errs() << argv[0] << ": error adding file '" << InputFilenames[i]
- << "'\n";
- return 1;
+ error("error adding file '" + InputFilenames[i] + "'");
}
}
@@ -639,8 +637,7 @@ int main(int argc, char **argv) {
if (!CodeGen.optimize(DisableVerify, DisableInline, DisableGVNLoadPRE,
DisableLTOVectorization)) {
// Diagnostic messages should have been printed by the handler.
- errs() << argv[0] << ": error optimizing the code\n";
- return 1;
+ error("error optimizing the code");
}
if (SaveModuleFile) {
@@ -648,10 +645,8 @@ int main(int argc, char **argv) {
ModuleFilename += ".merged.bc";
std::string ErrMsg;
- if (!CodeGen.writeMergedModules(ModuleFilename.c_str())) {
- errs() << argv[0] << ": writing merged module failed.\n";
- return 1;
- }
+ if (!CodeGen.writeMergedModules(ModuleFilename.c_str()))
+ error("writing merged module failed.");
}
std::list<tool_output_file> OSs;
@@ -662,40 +657,29 @@ int main(int argc, char **argv) {
PartFilename += "." + utostr(I);
std::error_code EC;
OSs.emplace_back(PartFilename, EC, sys::fs::F_None);
- if (EC) {
- errs() << argv[0] << ": error opening the file '" << PartFilename
- << "': " << EC.message() << "\n";
- return 1;
- }
+ if (EC)
+ error("error opening the file '" + PartFilename + "': " + EC.message());
OSPtrs.push_back(&OSs.back().os());
}
- if (!CodeGen.compileOptimized(OSPtrs)) {
+ if (!CodeGen.compileOptimized(OSPtrs))
// Diagnostic messages should have been printed by the handler.
- errs() << argv[0] << ": error compiling the code\n";
- return 1;
- }
+ error("error compiling the code");
for (tool_output_file &OS : OSs)
OS.keep();
} else {
- if (Parallelism != 1) {
- errs() << argv[0] << ": -j must be specified together with -o\n";
- return 1;
- }
+ if (Parallelism != 1)
+ error("-j must be specified together with -o");
- if (SaveModuleFile) {
- errs() << argv[0] << ": -save-merged-module must be specified with -o\n";
- return 1;
- }
+ if (SaveModuleFile)
+ error(": -save-merged-module must be specified with -o");
const char *OutputName = nullptr;
if (!CodeGen.compile_to_file(&OutputName, DisableVerify, DisableInline,
- DisableGVNLoadPRE, DisableLTOVectorization)) {
+ DisableGVNLoadPRE, DisableLTOVectorization))
+ error("error compiling the code");
// Diagnostic messages should have been printed by the handler.
- errs() << argv[0] << ": error compiling the code\n";
- return 1;
- }
outs() << "Wrote native object file '" << OutputName << "'\n";
}
OpenPOWER on IntegriCloud