OLD | NEW |
1 //===-- pnacl-bccompress.cpp - Bitcode (abbrev) compression ---------------===// | 1 //===-- pnacl-bccompress.cpp - Bitcode (abbrev) compression ---------------===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This tool may be invoked in the following manner: | 10 // This tool may be invoked in the following manner: |
(...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1408 | 1408 |
1409 // Parse the bitcode and copy. | 1409 // Parse the bitcode and copy. |
1410 while (!Stream.AtEndOfStream()) { | 1410 while (!Stream.AtEndOfStream()) { |
1411 if (Parser.Parse()) return true; | 1411 if (Parser.Parse()) return true; |
1412 } | 1412 } |
1413 | 1413 |
1414 // Write out the copied results. | 1414 // Write out the copied results. |
1415 std::string ErrorInfo; | 1415 std::string ErrorInfo; |
1416 OwningPtr<tool_output_file> OutFile( | 1416 OwningPtr<tool_output_file> OutFile( |
1417 new tool_output_file(OutputFilename.c_str(), ErrorInfo, | 1417 new tool_output_file(OutputFilename.c_str(), ErrorInfo, |
1418 raw_fd_ostream::F_Binary)); | 1418 sys::fs::F_Binary)); |
1419 if (!ErrorInfo.empty()) | 1419 if (!ErrorInfo.empty()) |
1420 return Error(ErrorInfo); | 1420 return Error(ErrorInfo); |
1421 | 1421 |
1422 // Write the generated bitstream to "Out". | 1422 // Write the generated bitstream to "Out". |
1423 OutFile->os().write((char*)&OutputBuffer.front(), | 1423 OutFile->os().write((char*)&OutputBuffer.front(), |
1424 OutputBuffer.size()); | 1424 OutputBuffer.size()); |
1425 OutFile->keep(); | 1425 OutFile->keep(); |
1426 | 1426 |
1427 return false; | 1427 return false; |
1428 } | 1428 } |
1429 | 1429 |
1430 } // namespace | 1430 } // namespace |
1431 | 1431 |
1432 int main(int argc, char **argv) { | 1432 int main(int argc, char **argv) { |
1433 // Print a stack trace if we signal out. | 1433 // Print a stack trace if we signal out. |
1434 sys::PrintStackTraceOnErrorSignal(); | 1434 sys::PrintStackTraceOnErrorSignal(); |
1435 PrettyStackTraceProgram X(argc, argv); | 1435 PrettyStackTraceProgram X(argc, argv); |
1436 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. | 1436 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. |
1437 cl::ParseCommandLineOptions(argc, argv, "pnacl-bccompress file analyzer\n"); | 1437 cl::ParseCommandLineOptions(argc, argv, "pnacl-bccompress file analyzer\n"); |
1438 | 1438 |
1439 OwningPtr<MemoryBuffer> MemBuf; | 1439 OwningPtr<MemoryBuffer> MemBuf; |
1440 if (ReadAndBuffer(MemBuf)) return 1; | 1440 if (ReadAndBuffer(MemBuf)) return 1; |
1441 BlockAbbrevsMapType BlockAbbrevsMap; | 1441 BlockAbbrevsMapType BlockAbbrevsMap; |
1442 if (AnalyzeBitcode(MemBuf, BlockAbbrevsMap)) return 1; | 1442 if (AnalyzeBitcode(MemBuf, BlockAbbrevsMap)) return 1; |
1443 if (CopyBitcode(MemBuf, BlockAbbrevsMap)) return 1; | 1443 if (CopyBitcode(MemBuf, BlockAbbrevsMap)) return 1; |
1444 return 0; | 1444 return 0; |
1445 } | 1445 } |
OLD | NEW |