diff options
author | Derek Schuff <dschuff@google.com> | 2012-02-06 22:30:29 +0000 |
---|---|---|
committer | Derek Schuff <dschuff@google.com> | 2012-02-06 22:30:29 +0000 |
commit | 2ea93875b2f2900b9d244dfd7649c9ed02a34cd7 (patch) | |
tree | 3e2851a6033c574bbd73e97aa7fcad8501759a76 /tools | |
parent | 06d7e1b52b412bd1ad307606496d7a4dc66ab751 (diff) |
Enable streaming of bitcode
This CL delays reading of function bodies from initial parse until
materialization, allowing overlap of compilation with bitcode download.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149918 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp | 6 | ||||
-rw-r--r-- | tools/llvm-dis/llvm-dis.cpp | 19 | ||||
-rw-r--r-- | tools/llvm-mc/Disassembler.cpp | 4 | ||||
-rw-r--r-- | tools/llvm-objdump/MCFunction.cpp | 2 | ||||
-rw-r--r-- | tools/llvm-objdump/MCFunction.h | 2 | ||||
-rw-r--r-- | tools/llvm-objdump/llvm-objdump.h | 4 |
6 files changed, 22 insertions, 15 deletions
diff --git a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp index cda0ae0760..bf068c4421 100644 --- a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp +++ b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp @@ -483,13 +483,13 @@ static int AnalyzeBitcode() { if (MemBuf->getBufferSize() & 3) return Error("Bitcode stream should be a multiple of 4 bytes in length"); - unsigned char *BufPtr = (unsigned char *)MemBuf->getBufferStart(); - unsigned char *EndBufPtr = BufPtr+MemBuf->getBufferSize(); + const unsigned char *BufPtr = (unsigned char *)MemBuf->getBufferStart(); + const unsigned char *EndBufPtr = BufPtr+MemBuf->getBufferSize(); // If we have a wrapper header, parse it and ignore the non-bc file contents. // The magic number is 0x0B17C0DE stored in little endian. if (isBitcodeWrapper(BufPtr, EndBufPtr)) - if (SkipBitcodeWrapperHeader(BufPtr, EndBufPtr)) + if (SkipBitcodeWrapperHeader(BufPtr, EndBufPtr, true)) return Error("Invalid bitcode wrapper header"); BitstreamReader StreamFile(BufPtr, EndBufPtr); diff --git a/tools/llvm-dis/llvm-dis.cpp b/tools/llvm-dis/llvm-dis.cpp index 9020a52786..6450ea6ac7 100644 --- a/tools/llvm-dis/llvm-dis.cpp +++ b/tools/llvm-dis/llvm-dis.cpp @@ -24,6 +24,7 @@ #include "llvm/Analysis/DebugInfo.h" #include "llvm/Assembly/AssemblyAnnotationWriter.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/DataStream.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MemoryBuffer.h" @@ -126,12 +127,19 @@ int main(int argc, char **argv) { std::string ErrorMessage; std::auto_ptr<Module> M; - { - OwningPtr<MemoryBuffer> BufferPtr; - if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFilename, BufferPtr)) - ErrorMessage = ec.message(); + // Use the bitcode streaming interface + DataStreamer *streamer = getDataFileStreamer(InputFilename, &ErrorMessage); + if (streamer) { + std::string DisplayFilename; + if (InputFilename == "-") + DisplayFilename = "<stdin>"; else - M.reset(ParseBitcodeFile(BufferPtr.get(), Context, &ErrorMessage)); + DisplayFilename = InputFilename; + M.reset(getStreamedBitcodeModule(DisplayFilename, streamer, Context, + &ErrorMessage)); + if(M.get() != 0 && M->MaterializeAllPermanently(&ErrorMessage)) { + M.reset(); + } } if (M.get() == 0) { @@ -183,4 +191,3 @@ int main(int argc, char **argv) { return 0; } - diff --git a/tools/llvm-mc/Disassembler.cpp b/tools/llvm-mc/Disassembler.cpp index 03956b426e..32fc2ba57d 100644 --- a/tools/llvm-mc/Disassembler.cpp +++ b/tools/llvm-mc/Disassembler.cpp @@ -42,9 +42,9 @@ public: VectorMemoryObject(const ByteArrayTy &bytes) : Bytes(bytes) {} uint64_t getBase() const { return 0; } - uint64_t getExtent() const { return Bytes.size(); } + uint64_t getExtent() { return Bytes.size(); } - int readByte(uint64_t Addr, uint8_t *Byte) const { + int readByte(uint64_t Addr, uint8_t *Byte) { if (Addr >= getExtent()) return -1; *Byte = Bytes[Addr].first; diff --git a/tools/llvm-objdump/MCFunction.cpp b/tools/llvm-objdump/MCFunction.cpp index 5c67f1b70a..9a9edda753 100644 --- a/tools/llvm-objdump/MCFunction.cpp +++ b/tools/llvm-objdump/MCFunction.cpp @@ -28,7 +28,7 @@ using namespace llvm; MCFunction MCFunction::createFunctionFromMC(StringRef Name, const MCDisassembler *DisAsm, - const MemoryObject &Region, uint64_t Start, + MemoryObject &Region, uint64_t Start, uint64_t End, const MCInstrAnalysis *Ana, raw_ostream &DebugOut, SmallVectorImpl<uint64_t> &Calls) { diff --git a/tools/llvm-objdump/MCFunction.h b/tools/llvm-objdump/MCFunction.h index 6d3a548d48..c0362d3a43 100644 --- a/tools/llvm-objdump/MCFunction.h +++ b/tools/llvm-objdump/MCFunction.h @@ -79,7 +79,7 @@ public: // Create an MCFunction from a region of binary machine code. static MCFunction createFunctionFromMC(StringRef Name, const MCDisassembler *DisAsm, - const MemoryObject &Region, uint64_t Start, uint64_t End, + MemoryObject &Region, uint64_t Start, uint64_t End, const MCInstrAnalysis *Ana, raw_ostream &DebugOut, SmallVectorImpl<uint64_t> &Calls); diff --git a/tools/llvm-objdump/llvm-objdump.h b/tools/llvm-objdump/llvm-objdump.h index aa71b77c8a..1611516ab7 100644 --- a/tools/llvm-objdump/llvm-objdump.h +++ b/tools/llvm-objdump/llvm-objdump.h @@ -31,9 +31,9 @@ public: StringRefMemoryObject(StringRef bytes) : Bytes(bytes) {} uint64_t getBase() const { return 0; } - uint64_t getExtent() const { return Bytes.size(); } + uint64_t getExtent() { return Bytes.size(); } - int readByte(uint64_t Addr, uint8_t *Byte) const { + int readByte(uint64_t Addr, uint8_t *Byte) { if (Addr >= getExtent()) return -1; *Byte = Bytes[Addr]; |