Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp

Issue 8393017: Bitcode streaming (Closed)
Patch Set: put destructors back, fix trailing whitespace Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/llc/llc.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===-- llvm-bcanalyzer.cpp - Bitcode Analyzer --------------------------===// 1 //===-- llvm-bcanalyzer.cpp - Bitcode Analyzer --------------------------===//
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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 // Read the input file. 469 // Read the input file.
470 OwningPtr<MemoryBuffer> MemBuf; 470 OwningPtr<MemoryBuffer> MemBuf;
471 471
472 if (error_code ec = 472 if (error_code ec =
473 MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), MemBuf)) 473 MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), MemBuf))
474 return Error("Error reading '" + InputFilename + "': " + ec.message()); 474 return Error("Error reading '" + InputFilename + "': " + ec.message());
475 475
476 if (MemBuf->getBufferSize() & 3) 476 if (MemBuf->getBufferSize() & 3)
477 return Error("Bitcode stream should be a multiple of 4 bytes in length"); 477 return Error("Bitcode stream should be a multiple of 4 bytes in length");
478 478
479 unsigned char *BufPtr = (unsigned char *)MemBuf->getBufferStart(); 479 const unsigned char *BufPtr = (unsigned char *)MemBuf->getBufferStart();
480 unsigned char *EndBufPtr = BufPtr+MemBuf->getBufferSize(); 480 const unsigned char *EndBufPtr = BufPtr+MemBuf->getBufferSize();
481 481
482 // If we have a wrapper header, parse it and ignore the non-bc file contents. 482 // If we have a wrapper header, parse it and ignore the non-bc file contents.
483 // The magic number is 0x0B17C0DE stored in little endian. 483 // The magic number is 0x0B17C0DE stored in little endian.
484 if (isBitcodeWrapper(BufPtr, EndBufPtr)) 484 if (isBitcodeWrapper(BufPtr, EndBufPtr))
485 if (SkipBitcodeWrapperHeader(BufPtr, EndBufPtr)) 485 if (SkipBitcodeWrapperHeader(BufPtr, EndBufPtr, true))
486 return Error("Invalid bitcode wrapper header"); 486 return Error("Invalid bitcode wrapper header");
487 487
488 BitstreamReader StreamFile(BufPtr, EndBufPtr); 488 BitstreamReader StreamFile(BufPtr, EndBufPtr);
489 BitstreamCursor Stream(StreamFile); 489 BitstreamCursor Stream(StreamFile);
490 StreamFile.CollectBlockInfoNames(); 490 StreamFile.CollectBlockInfoNames();
491 491
492 // Read the stream signature. 492 // Read the stream signature.
493 char Signature[6]; 493 char Signature[6];
494 Signature[0] = Stream.Read(8); 494 Signature[0] = Stream.Read(8);
495 Signature[1] = Stream.Read(8); 495 Signature[1] = Stream.Read(8);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 611
612 int main(int argc, char **argv) { 612 int main(int argc, char **argv) {
613 // Print a stack trace if we signal out. 613 // Print a stack trace if we signal out.
614 sys::PrintStackTraceOnErrorSignal(); 614 sys::PrintStackTraceOnErrorSignal();
615 PrettyStackTraceProgram X(argc, argv); 615 PrettyStackTraceProgram X(argc, argv);
616 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. 616 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
617 cl::ParseCommandLineOptions(argc, argv, "llvm-bcanalyzer file analyzer\n"); 617 cl::ParseCommandLineOptions(argc, argv, "llvm-bcanalyzer file analyzer\n");
618 618
619 return AnalyzeBitcode(); 619 return AnalyzeBitcode();
620 } 620 }
OLDNEW
« no previous file with comments | « tools/llc/llc.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698