summaryrefslogtreecommitdiff
path: root/tools/bugpoint
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-08-20 16:59:15 +0000
committerDan Gohman <gohman@apple.com>2010-08-20 16:59:15 +0000
commitf29140106f74d15ba357aa0a7f109adc939c3104 (patch)
tree770be753408ca9fefa28ec3a13ef8f45e00cba3a /tools/bugpoint
parente7b67d0e94df497791207618194e1db545ac3721 (diff)
downloadllvm-f29140106f74d15ba357aa0a7f109adc939c3104.tar.gz
llvm-f29140106f74d15ba357aa0a7f109adc939c3104.tar.bz2
llvm-f29140106f74d15ba357aa0a7f109adc939c3104.tar.xz
Convert tools to use tool_output_file, and introduce error
checking to places which previously lacked it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111651 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/bugpoint')
-rw-r--r--tools/bugpoint/ExtractFunction.cpp10
-rw-r--r--tools/bugpoint/OptimizerDriver.cpp28
2 files changed, 29 insertions, 9 deletions
diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp
index 7d3040255a..e9cae15ef5 100644
--- a/tools/bugpoint/ExtractFunction.cpp
+++ b/tools/bugpoint/ExtractFunction.cpp
@@ -325,7 +325,7 @@ Module *BugDriver::ExtractMappedBlocksFromModule(const
sys::RemoveFileOnSignal(uniqueFilename);
std::string ErrorInfo;
- raw_fd_ostream BlocksToNotExtractFile(uniqueFilename.c_str(), ErrorInfo);
+ tool_output_file BlocksToNotExtractFile(uniqueFilename.c_str(), ErrorInfo);
if (!ErrorInfo.empty()) {
outs() << "*** Basic Block extraction failed!\n";
errs() << "Error writing list of blocks to not extract: " << ErrorInfo
@@ -343,6 +343,14 @@ Module *BugDriver::ExtractMappedBlocksFromModule(const
<< BB->getName() << "\n";
}
BlocksToNotExtractFile.close();
+ if (BlocksToNotExtractFile.has_error()) {
+ errs() << "Error writing list of blocks to not extract: " << ErrorInfo
+ << "\n";
+ EmitProgressBitcode(M, "basicblockextractfail", true);
+ BlocksToNotExtractFile.clear_error();
+ return 0;
+ }
+ BlocksToNotExtractFile.keep();
std::string uniqueFN = "--extract-blocks-file=" + uniqueFilename.str();
const char *ExtraArg = uniqueFN.c_str();
diff --git a/tools/bugpoint/OptimizerDriver.cpp b/tools/bugpoint/OptimizerDriver.cpp
index ffd40997fc..6d37761bcd 100644
--- a/tools/bugpoint/OptimizerDriver.cpp
+++ b/tools/bugpoint/OptimizerDriver.cpp
@@ -54,12 +54,18 @@ namespace {
bool BugDriver::writeProgramToFile(const std::string &Filename,
const Module *M) const {
std::string ErrInfo;
- raw_fd_ostream Out(Filename.c_str(), ErrInfo,
- raw_fd_ostream::F_Binary);
- if (!ErrInfo.empty()) return true;
-
- WriteBitcodeToFile(M, Out);
- return false;
+ tool_output_file Out(Filename.c_str(), ErrInfo,
+ raw_fd_ostream::F_Binary);
+ if (ErrInfo.empty()) {
+ WriteBitcodeToFile(M, Out);
+ Out.close();
+ if (!Out.has_error()) {
+ Out.keep();
+ return false;
+ }
+ }
+ Out.clear_error();
+ return true;
}
@@ -125,8 +131,8 @@ bool BugDriver::runPasses(Module *Program,
}
std::string ErrInfo;
- raw_fd_ostream InFile(inputFilename.c_str(), ErrInfo,
- raw_fd_ostream::F_Binary);
+ tool_output_file InFile(inputFilename.c_str(), ErrInfo,
+ raw_fd_ostream::F_Binary);
if (!ErrInfo.empty()) {
@@ -135,6 +141,12 @@ bool BugDriver::runPasses(Module *Program,
}
WriteBitcodeToFile(Program, InFile);
InFile.close();
+ if (InFile.has_error()) {
+ errs() << "Error writing bitcode file: " << inputFilename.str() << "\n";
+ InFile.clear_error();
+ return 1;
+ }
+ InFile.keep();
// setup the child process' arguments
SmallVector<const char*, 8> Args;