llvm.org GIT mirror llvm / f2e292c
push bytecode decompressor out through APIs. Now the bytecode reader api's look like this: ModuleProvider *getBytecodeModuleProvider( const std::string &Filename, ///< Name of file to be read BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer, std::string* ErrMsg = 0, ///< Optional error message holder BytecodeHandler* H = 0 ///< Optional handler for reader events ); This is ugly, but allows a client to say: getBytecodeModuleProvider("foo", 0); If they do this, there is no dependency on the compression libraries, saving codesize. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34012 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 12 years ago
25 changed file(s) with 142 addition(s) and 108 deletion(s). Raw diff Collapse all Expand all
1919 #define LLVM_BYTECODE_ANALYZER_H
2020
2121 #include "llvm/Bytecode/Format.h"
22 #include "llvm/Bytecode/Reader.h"
2223 #include
2324 #include
24 #include <ostream>
25 #include <iosfwd>
2526
2627 namespace llvm {
2728
101102 Module* AnalyzeBytecodeFile(
102103 const std::string& Filename, ///< The name of the bytecode file to read
103104 BytecodeAnalysis& Results, ///< The results of the analysis
105 BCDecompressor_t *BCDC = 0, ///< Optional decompressor to use.
104106 std::string* ErrorStr = 0, ///< Errors, if any.
105107 std::ostream* output = 0 ///< Stream for dump output, if wanted
106108 );
107109
108 /// This function is an alternate entry point into the bytecode analysis
109 /// library. It allows you to provide an arbitrary memory buffer which is
110 /// assumed to contain a complete bytecode file. The \p Buffer is analyzed and
111 /// the \p Results are filled in.
112 /// @brief Analyze contents of a bytecode buffer.
113 Module* AnalyzeBytecodeBuffer(
114 const unsigned char* Buffer, ///< Pointer to start of bytecode buffer
115 unsigned BufferSize, ///< Size of the bytecode buffer
116 const std::string& ModuleID, ///< Identifier for the module
117 BytecodeAnalysis& Results, ///< The results of the analysis
118 std::string* ErrorStr = 0, ///< Errors, if any.
119 std::ostream* output = 0 ///< Stream for dump output, if wanted
120 );
121110
122111 /// This function prints the contents of rhe BytecodeAnalysis structure in
123112 /// a human legible form.
1919 #include "llvm/ADT/ilist"
2020 #include "llvm/System/Path.h"
2121 #include "llvm/System/MappedFile.h"
22 #include "llvm/Support/Compressor.h"
2223 #include
2324 #include
2425 #include
3031 class Module; // From VMCore
3132 class Archive; // Declared below
3233 class ArchiveMemberHeader; // Internal implementation class
34
35 typedef size_t BCDecompressor_t(const char *, size_t, char*&, std::string*);
36
3337
3438 /// This class is the main class manipulated by users of the Archive class. It
3539 /// holds information about one member of the Archive. It is also the element
222226 /// applications and the linkers. Consequently, the implementation of the class
223227 /// is optimized for reading.
224228 class Archive {
225
229
226230 /// @name Types
227231 /// @{
228232 public:
467471 protected:
468472 /// @brief Construct an Archive for \p filename and optionally map it
469473 /// into memory.
470 Archive(const sys::Path& filename);
474 Archive(const sys::Path& filename, BCDecompressor_t *BCDC =
475 Compressor::decompressToNewBuffer);
471476
472477 /// @param error Set to address of a std::string to get error messages
473478 /// @returns false on error
546551 unsigned firstFileOffset; ///< Offset to first normal file.
547552 ModuleMap modules; ///< The modules loaded via symbol lookup.
548553 ArchiveMember* foreignST; ///< This holds the foreign symbol table.
549
554 BCDecompressor_t *Decompressor; ///< Optional decompressor
550555 /// @}
551556 /// @name Hidden
552557 /// @{
1818 #ifndef LLVM_BYTECODE_READER_H
1919 #define LLVM_BYTECODE_READER_H
2020
21 #include "llvm/System/Path.h"
2221 #include "llvm/ModuleProvider.h"
2322 #include "llvm/Module.h"
24 #include
23 #include "llvm/Support/Compressor.h"
24 #include "llvm/System/Path.h"
2525
2626 namespace llvm {
2727
2828 // Forward declare the handler class
2929 class BytecodeHandler;
30
31 typedef size_t BCDecompressor_t(const char *, size_t, char*&, std::string*);
3032
3133 /// This function returns a ModuleProvider that can be used to do lazy
3234 /// function-at-a-time loading from a bytecode file.
3537 /// @brief Get a ModuleProvide for a bytecode file.
3638 ModuleProvider *getBytecodeModuleProvider(
3739 const std::string &Filename, ///< Name of file to be read
40 BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer,
3841 std::string* ErrMsg = 0, ///< Optional error message holder
3942 BytecodeHandler* H = 0 ///< Optional handler for reader events
4043 );
4851 const unsigned char *Buffer, ///< Start of buffer to parse
4952 unsigned BufferSize, ///< Size of the buffer
5053 const std::string &ModuleID, ///< Name to give the module
54 BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer,
5155 std::string* ErrMsg = 0, ///< Optional place to return an error message
5256 BytecodeHandler* H = 0 ///< Optional handler for reader events
5357 );
6064 /// @brief Parse the given bytecode file
6165 Module* ParseBytecodeFile(
6266 const std::string &Filename, ///< Name of file to parse
67 BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer,
6368 std::string *ErrMsg = 0 ///< Optional place to return an error message
6469 );
6570
7176 const unsigned char *Buffer, ///< Start of buffer to parse
7277 unsigned BufferSize, ///< Size of the buffer
7378 const std::string &ModuleID="", ///< Name to give the module
79 BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer,
7480 std::string *ErrMsg = 0 ///< Optional place to return an error message
7581 );
7682
8389 bool GetBytecodeDependentLibraries(
8490 const std::string &fileName, ///< File name to read bytecode from
8591 Module::LibraryListType& deplibs, ///< List of dependent libraries extracted
92 BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer,
8693 std::string* ErrMsg = 0 ///< Optional error message holder
8794 );
8895
95102 bool GetBytecodeSymbols(
96103 const sys::Path& fileName, ///< Filename to read bytecode from
97104 std::vector& syms, ///< Vector to return symbols in
105 BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer,
98106 std::string* ErrMsg = 0 ///< Optional error message holder
99107 );
100108
110118 unsigned Length, ///< The length of \p Buffer
111119 const std::string& ModuleID, ///< An identifier for the module
112120 std::vector& symbols, ///< The symbols defined in the module
121 BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer,
113122 std::string* ErrMsg = 0 ///< Optional error message holder
114123 );
115124
137137 // Archive constructor - this is the only constructor that gets used for the
138138 // Archive class. Everything else (default,copy) is deprecated. This just
139139 // initializes and maps the file into memory, if requested.
140 Archive::Archive(const sys::Path& filename)
140 Archive::Archive(const sys::Path& filename, BCDecompressor_t *BCDC)
141141 : archPath(filename), members(), mapfile(0), base(0), symTab(), strtab(),
142 symTabSize(0), firstFileOffset(0), modules(), foreignST(0)
143 {
142 symTabSize(0), firstFileOffset(0), modules(), foreignST(0),
143 Decompressor(BCDC) {
144144 }
145145
146146 bool
1212
1313 #include "ArchiveInternals.h"
1414 #include "llvm/Bytecode/Reader.h"
15 #include "llvm/Support/Compressor.h"
1516 #include
16
1717 using namespace llvm;
1818
1919 /// Read a variable-bit-rate encoded unsigned integer
350350 std::string FullMemberName = archPath.toString() +
351351 "(" + I->getPath().toString() + ")";
352352 Module* M = ParseBytecodeBuffer((const unsigned char*)I->getData(),
353 I->getSize(), FullMemberName, ErrMessage);
353 I->getSize(), FullMemberName,
354 Compressor::decompressToNewBuffer,
355 ErrMessage);
354356 if (!M)
355357 return true;
356358
485487 mbr->getPath().toString() + ")";
486488 ModuleProvider* mp = getBytecodeBufferModuleProvider(
487489 (const unsigned char*) mbr->getData(), mbr->getSize(),
488 FullMemberName, ErrMsg, 0);
490 FullMemberName, Decompressor, ErrMsg, 0);
489491 if (!mp)
490492 return 0;
491493
499501 bool
500502 Archive::findModulesDefiningSymbols(std::set& symbols,
501503 std::set& result,
502 std::string* error)
503 {
504 std::string* error) {
504505 if (!mapfile || !base) {
505506 if (error)
506507 *error = "Empty archive invalid for finding modules defining symbols";
532533 std::vector symbols;
533534 std::string FullMemberName = archPath.toString() + "(" +
534535 mbr->getPath().toString() + ")";
535 ModuleProvider* MP = GetBytecodeSymbols((const unsigned char*)At,
536 mbr->getSize(), FullMemberName, symbols, error);
536 ModuleProvider* MP =
537 GetBytecodeSymbols((const unsigned char*)At, mbr->getSize(),
538 FullMemberName, symbols,
539 Compressor::decompressToNewBuffer, error);
537540
538541 if (MP) {
539542 // Insert the module's symbols into the symbol table
224224 std::string FullMemberName = archPath.toString() + "(" +
225225 member.getPath().toString()
226226 + ")";
227 ModuleProvider* MP = GetBytecodeSymbols(
228 (const unsigned char*)data,fSize,FullMemberName, symbols, ErrMsg);
227 ModuleProvider* MP =
228 GetBytecodeSymbols((const unsigned char*)data,fSize,
229 FullMemberName, symbols,
230 Compressor::decompressToNewBuffer, ErrMsg);
229231
230232 // If the bytecode parsed successfully
231233 if ( MP ) {
137137 // Archive constructor - this is the only constructor that gets used for the
138138 // Archive class. Everything else (default,copy) is deprecated. This just
139139 // initializes and maps the file into memory, if requested.
140 Archive::Archive(const sys::Path& filename)
140 Archive::Archive(const sys::Path& filename, BCDecompressor_t *BCDC)
141141 : archPath(filename), members(), mapfile(0), base(0), symTab(), strtab(),
142 symTabSize(0), firstFileOffset(0), modules(), foreignST(0)
143 {
142 symTabSize(0), firstFileOffset(0), modules(), foreignST(0),
143 Decompressor(BCDC) {
144144 }
145145
146146 bool
1212
1313 #include "ArchiveInternals.h"
1414 #include "llvm/Bytecode/Reader.h"
15 #include "llvm/Support/Compressor.h"
1516 #include
16
1717 using namespace llvm;
1818
1919 /// Read a variable-bit-rate encoded unsigned integer
350350 std::string FullMemberName = archPath.toString() +
351351 "(" + I->getPath().toString() + ")";
352352 Module* M = ParseBytecodeBuffer((const unsigned char*)I->getData(),
353 I->getSize(), FullMemberName, ErrMessage);
353 I->getSize(), FullMemberName,
354 Compressor::decompressToNewBuffer,
355 ErrMessage);
354356 if (!M)
355357 return true;
356358
485487 mbr->getPath().toString() + ")";
486488 ModuleProvider* mp = getBytecodeBufferModuleProvider(
487489 (const unsigned char*) mbr->getData(), mbr->getSize(),
488 FullMemberName, ErrMsg, 0);
490 FullMemberName, Decompressor, ErrMsg, 0);
489491 if (!mp)
490492 return 0;
491493
499501 bool
500502 Archive::findModulesDefiningSymbols(std::set& symbols,
501503 std::set& result,
502 std::string* error)
503 {
504 std::string* error) {
504505 if (!mapfile || !base) {
505506 if (error)
506507 *error = "Empty archive invalid for finding modules defining symbols";
532533 std::vector symbols;
533534 std::string FullMemberName = archPath.toString() + "(" +
534535 mbr->getPath().toString() + ")";
535 ModuleProvider* MP = GetBytecodeSymbols((const unsigned char*)At,
536 mbr->getSize(), FullMemberName, symbols, error);
536 ModuleProvider* MP =
537 GetBytecodeSymbols((const unsigned char*)At, mbr->getSize(),
538 FullMemberName, symbols,
539 Compressor::decompressToNewBuffer, error);
537540
538541 if (MP) {
539542 // Insert the module's symbols into the symbol table
224224 std::string FullMemberName = archPath.toString() + "(" +
225225 member.getPath().toString()
226226 + ")";
227 ModuleProvider* MP = GetBytecodeSymbols(
228 (const unsigned char*)data,fSize,FullMemberName, symbols, ErrMsg);
227 ModuleProvider* MP =
228 GetBytecodeSymbols((const unsigned char*)data,fSize,
229 FullMemberName, symbols,
230 Compressor::decompressToNewBuffer, ErrMsg);
229231
230232 // If the bytecode parsed successfully
231233 if ( MP ) {
19801980 /// and \p Length parameters.
19811981 bool BytecodeReader::ParseBytecode(volatile BufPtr Buf, unsigned Length,
19821982 const std::string &ModuleID,
1983 Decompressor_t *Decompressor,
1983 BCDecompressor_t *Decompressor,
19841984 std::string* ErrMsg) {
19851985
19861986 /// We handle errors by
20152015
20162016 // If this is a compressed file
20172017 if (Sig == ('l' | ('l' << 8) | ('v' << 16) | ('c' << 24))) {
2018 if (!Decompressor) {
2019 error("Compressed bytecode found, but not decompressor available");
2020 }
20182021
20192022 // Invoke the decompression of the bytecode. Note that we have to skip the
20202023 // file's magic number which is not part of the compressed block. Hence,
139139 /// @name Methods
140140 /// @{
141141 public:
142
143 typedef size_t Decompressor_t(const char *, size_t, char*&, std::string*);
144
142 typedef size_t BCDecompressor_t(const char *, size_t, char*&, std::string*);
143
145144 /// @returns true if an error occurred
146145 /// @brief Main interface to parsing a bytecode buffer.
147146 bool ParseBytecode(
148147 volatile BufPtr Buf, ///< Beginning of the bytecode buffer
149148 unsigned Length, ///< Length of the bytecode buffer
150149 const std::string &ModuleID, ///< An identifier for the module constructed.
151 Decompressor_t *Decompressor = 0, ///< Optional decompressor.
150 BCDecompressor_t *Decompressor = 0, ///< Optional decompressor.
152151 std::string* ErrMsg = 0 ///< Optional place for error message
153152 );
154153
1717 #include "llvm/Module.h"
1818 #include "llvm/Instructions.h"
1919 #include "llvm/ADT/StringExtras.h"
20 #include "llvm/Support/Compressor.h"
2120 #include "llvm/System/MappedFile.h"
2221 #include "llvm/System/Program.h"
2322 #include
3433 class BytecodeFileReader : public BytecodeReader {
3534 private:
3635 std::string fileName;
36 BCDecompressor_t *Decompressor;
3737 sys::MappedFile mapFile;
3838
3939 BytecodeFileReader(const BytecodeFileReader&); // Do not implement
4040 void operator=(const BytecodeFileReader &BFR); // Do not implement
4141
4242 public:
43 BytecodeFileReader(const std::string &Filename, llvm::BytecodeHandler* H=0);
43 BytecodeFileReader(const std::string &Filename, BCDecompressor_t *BCDC,
44 llvm::BytecodeHandler* H=0);
4445 bool read(std::string* ErrMsg);
4546
4647 void freeState() {
5152 }
5253
5354 BytecodeFileReader::BytecodeFileReader(const std::string &Filename,
55 BCDecompressor_t *BCDC,
5456 llvm::BytecodeHandler* H)
55 : BytecodeReader(H), fileName(Filename) {
57 : BytecodeReader(H), fileName(Filename), Decompressor(BCDC) {
5658 }
5759
5860 bool BytecodeFileReader::read(std::string* ErrMsg) {
6466 }
6567 unsigned char* buffer = reinterpret_cast(mapFile.base());
6668 return ParseBytecode(buffer, mapFile.size(), fileName,
67 Compressor::decompressToNewBuffer, ErrMsg);
69 Decompressor, ErrMsg);
6870 }
6971
7072 //===----------------------------------------------------------------------===//
8082 const unsigned char *Buf;
8183 unsigned Length;
8284 std::string ModuleID;
85 BCDecompressor_t *Decompressor;
8386 bool MustDelete;
8487
8588 BytecodeBufferReader(const BytecodeBufferReader&); // Do not implement
8790
8891 public:
8992 BytecodeBufferReader(const unsigned char *Buf, unsigned Length,
90 const std::string &ModuleID,
93 const std::string &ModuleID, BCDecompressor_t *BCDC,
9194 llvm::BytecodeHandler* Handler = 0);
9295 ~BytecodeBufferReader();
9396
99102 BytecodeBufferReader::BytecodeBufferReader(const unsigned char *buf,
100103 unsigned len,
101104 const std::string &modID,
105 BCDecompressor_t *BCDC,
102106 llvm::BytecodeHandler *H)
103107 : BytecodeReader(H), Buffer(0), Buf(buf), Length(len), ModuleID(modID)
104 , MustDelete(false) {
108 , Decompressor(BCDC), MustDelete(false) {
105109 }
106110
107111 BytecodeBufferReader::~BytecodeBufferReader() {
123127 ParseBegin = Buffer = Buf;
124128 MustDelete = false;
125129 }
126 if (ParseBytecode(ParseBegin, Length, ModuleID,
127 Compressor::decompressToNewBuffer, ErrMsg)) {
130 if (ParseBytecode(ParseBegin, Length, ModuleID, Decompressor, ErrMsg)) {
128131 if (MustDelete) delete [] Buffer;
129132 return true;
130133 }
141144 class BytecodeStdinReader : public BytecodeReader {
142145 private:
143146 std::vector FileData;
147 BCDecompressor_t *Decompressor;
144148 unsigned char *FileBuf;
145149
146150 BytecodeStdinReader(const BytecodeStdinReader&); // Do not implement
147151 void operator=(const BytecodeStdinReader &BFR); // Do not implement
148152
149153 public:
150 BytecodeStdinReader( llvm::BytecodeHandler* H = 0 );
154 BytecodeStdinReader(BCDecompressor_t *BCDC, llvm::BytecodeHandler* H = 0);
151155 bool read(std::string* ErrMsg);
152156 };
153157 }
154158
155 BytecodeStdinReader::BytecodeStdinReader( BytecodeHandler* H )
156 : BytecodeReader(H)
157 {
158 }
159
160 bool
161 BytecodeStdinReader::read(std::string* ErrMsg)
162 {
159 BytecodeStdinReader::BytecodeStdinReader(BCDecompressor_t *BCDC,
160 BytecodeHandler* H)
161 : BytecodeReader(H), Decompressor(BCDC) {
162 }
163
164 bool BytecodeStdinReader::read(std::string* ErrMsg) {
163165 sys::Program::ChangeStdinToBinary();
164166 char Buffer[4096*4];
165167
179181 }
180182
181183 FileBuf = &FileData[0];
182 if (ParseBytecode(FileBuf, FileData.size(), "",
183 Compressor::decompressToNewBuffer, ErrMsg))
184 if (ParseBytecode(FileBuf, FileData.size(), "", Decompressor, ErrMsg))
184185 return true;
185186 return false;
186187 }
195196 llvm::getBytecodeBufferModuleProvider(const unsigned char *Buffer,
196197 unsigned Length,
197198 const std::string &ModuleID,
199 BCDecompressor_t *BCDC,
198200 std::string *ErrMsg,
199201 BytecodeHandler *H) {
200202 BytecodeBufferReader *rdr =
201 new BytecodeBufferReader(Buffer, Length, ModuleID, H);
203 new BytecodeBufferReader(Buffer, Length, ModuleID, BCDC, H);
202204 if (rdr->read(ErrMsg))
203205 return 0;
204206 return rdr;
208210 ///
209211 Module *llvm::ParseBytecodeBuffer(const unsigned char *Buffer, unsigned Length,
210212 const std::string &ModuleID,
213 BCDecompressor_t *BCDC,
211214 std::string *ErrMsg) {
212215 ModuleProvider *MP =
213 getBytecodeBufferModuleProvider(Buffer, Length, ModuleID, ErrMsg, 0);
216 getBytecodeBufferModuleProvider(Buffer, Length, ModuleID, BCDC, ErrMsg, 0);
214217 if (!MP) return 0;
215218 Module *M = MP->releaseModule(ErrMsg);
216219 delete MP;
221224 ///
222225 ModuleProvider *
223226 llvm::getBytecodeModuleProvider(const std::string &Filename,
227 BCDecompressor_t *BCDC,
224228 std::string* ErrMsg,
225229 BytecodeHandler* H) {
226230 // Read from a file
227231 if (Filename != std::string("-")) {
228 BytecodeFileReader *rdr = new BytecodeFileReader(Filename, H);
232 BytecodeFileReader *rdr = new BytecodeFileReader(Filename, BCDC, H);
229233 if (rdr->read(ErrMsg))
230234 return 0;
231235 return rdr;
232236 }
233237
234238 // Read from stdin
235 BytecodeStdinReader *rdr = new BytecodeStdinReader(H);
239 BytecodeStdinReader *rdr = new BytecodeStdinReader(BCDC, H);
236240 if (rdr->read(ErrMsg))
237241 return 0;
238242 return rdr;
241245 /// ParseBytecodeFile - Parse the given bytecode file
242246 ///
243247 Module *llvm::ParseBytecodeFile(const std::string &Filename,
248 BCDecompressor_t *BCDC,
244249 std::string *ErrMsg) {
245 ModuleProvider* MP = getBytecodeModuleProvider(Filename, ErrMsg);
250 ModuleProvider* MP = getBytecodeModuleProvider(Filename, BCDC, ErrMsg);
246251 if (!MP) return 0;
247252 Module *M = MP->releaseModule(ErrMsg);
248253 delete MP;
253258 Module* llvm::AnalyzeBytecodeFile(
254259 const std::string &Filename, ///< File to analyze
255260 BytecodeAnalysis& bca, ///< Statistical output
261 BCDecompressor_t *BCDC,
256262 std::string *ErrMsg, ///< Error output
257263 std::ostream* output ///< Dump output
258264 ) {
259265 BytecodeHandler* AH = createBytecodeAnalyzerHandler(bca,output);
260 ModuleProvider* MP = getBytecodeModuleProvider(Filename, ErrMsg, AH);
266 ModuleProvider* MP = getBytecodeModuleProvider(Filename, BCDC, ErrMsg, AH);
261267 if (!MP) return 0;
262268 Module *M = MP->releaseModule(ErrMsg);
263269 delete MP;
264270 return M;
265271 }
266272
267 // AnalyzeBytecodeBuffer - analyze a buffer
268 Module* llvm::AnalyzeBytecodeBuffer(
269 const unsigned char* Buffer, ///< Pointer to start of bytecode buffer
270 unsigned Length, ///< Size of the bytecode buffer
271 const std::string& ModuleID, ///< Identifier for the module
272 BytecodeAnalysis& bca, ///< The results of the analysis
273 std::string* ErrMsg, ///< Errors, if any.
274 std::ostream* output ///< Dump output, if any
275 )
276 {
277 BytecodeHandler* hdlr = createBytecodeAnalyzerHandler(bca, output);
278 ModuleProvider* MP =
279 getBytecodeBufferModuleProvider(Buffer, Length, ModuleID, ErrMsg, hdlr);
280 if (!MP) return 0;
281 Module *M = MP->releaseModule(ErrMsg);
282 delete MP;
283 return M;
284 }
285
286273 bool llvm::GetBytecodeDependentLibraries(const std::string &fname,
287274 Module::LibraryListType& deplibs,
275 BCDecompressor_t *BCDC,
288276 std::string* ErrMsg) {
289 ModuleProvider* MP = getBytecodeModuleProvider(fname, ErrMsg);
277 ModuleProvider* MP = getBytecodeModuleProvider(fname, BCDC, ErrMsg);
290278 if (!MP) {
291279 deplibs.clear();
292280 return true;
315303 // Get just the externally visible defined symbols from the bytecode
316304 bool llvm::GetBytecodeSymbols(const sys::Path& fName,
317305 std::vector& symbols,
306 BCDecompressor_t *BCDC,
318307 std::string* ErrMsg) {
319 ModuleProvider *MP = getBytecodeModuleProvider(fName.toString(), ErrMsg);
308 ModuleProvider *MP = getBytecodeModuleProvider(fName.toString(), BCDC,ErrMsg);
320309 if (!MP)
321310 return true;
322311
339328 llvm::GetBytecodeSymbols(const unsigned char*Buffer, unsigned Length,
340329 const std::string& ModuleID,
341330 std::vector& symbols,
331 BCDecompressor_t *BCDC,
342332 std::string* ErrMsg) {
343333 // Get the module provider
344334 ModuleProvider* MP =
345 getBytecodeBufferModuleProvider(Buffer, Length, ModuleID, ErrMsg, 0);
335 getBytecodeBufferModuleProvider(Buffer, Length, ModuleID, BCDC, ErrMsg, 0);
346336 if (!MP)
347337 return 0;
348338
1515 #include "llvm/Bytecode/Reader.h"
1616 #include "llvm/Config/config.h"
1717 #include "llvm/Support/Streams.h"
18 #include "llvm/Support/Compressor.h"
1819 using namespace llvm;
1920
2021 Linker::Linker(const std::string& progname, const std::string& modname, unsigned flags)
9899 std::auto_ptr
99100 Linker::LoadObject(const sys::Path &FN) {
100101 std::string ParseErrorMessage;
101 Module *Result = ParseBytecodeFile(FN.toString(), &ParseErrorMessage);
102 Module *Result = ParseBytecodeFile(FN.toString(),
103 Compressor::decompressToNewBuffer,
104 &ParseErrorMessage);
102105 if (Result)
103106 return std::auto_ptr(Result);
104107 Error = "Bytecode file '" + FN.toString() + "' could not be loaded";
2020 #include "llvm/Assembly/Parser.h"
2121 #include "llvm/Bytecode/Reader.h"
2222 #include "llvm/Support/CommandLine.h"
23 #include "llvm/Support/Compressor.h"
2324 #include "llvm/Support/FileUtilities.h"
2425 #include
2526 #include
7374 ///
7475 Module *llvm::ParseInputFile(const std::string &InputFilename) {
7576 ParseError Err;
76 Module *Result = ParseBytecodeFile(InputFilename);
77 Module *Result = ParseBytecodeFile(InputFilename,
78 Compressor::decompressToNewBuffer);
7779 if (!Result && !(Result = ParseAssemblyFile(InputFilename,&Err))) {
7880 std::cerr << "bugpoint: " << Err.getMessage() << "\n";
7981 Result = 0;
2323 #include "llvm/PassManager.h"
2424 #include "llvm/Pass.h"
2525 #include "llvm/Support/CommandLine.h"
26 #include "llvm/Support/Compressor.h"
2627 #include "llvm/Support/ManagedStatic.h"
2728 #include "llvm/Support/PluginLoader.h"
2829 #include "llvm/Support/FileUtilities.h"
174175 sys::PrintStackTraceOnErrorSignal();
175176
176177 // Load the module to be compiled...
177 std::auto_ptr M(ParseBytecodeFile(InputFilename));
178 std::auto_ptr M(ParseBytecodeFile(InputFilename,
179 Compressor::decompressToNewBuffer));
178180 if (M.get() == 0) {
179181 std::cerr << argv[0] << ": bytecode didn't read correctly.\n";
180182 return 1;
2121 #include "llvm/ExecutionEngine/Interpreter.h"
2222 #include "llvm/ExecutionEngine/GenericValue.h"
2323 #include "llvm/Support/CommandLine.h"
24 #include "llvm/Support/Compressor.h"
2425 #include "llvm/Support/ManagedStatic.h"
2526 #include "llvm/Support/PluginLoader.h"
2627 #include "llvm/System/Process.h"
6970 // Load the bytecode...
7071 std::string ErrorMsg;
7172 ModuleProvider *MP = 0;
72 MP = getBytecodeModuleProvider(InputFile, &ErrorMsg);
73 MP = getBytecodeModuleProvider(InputFile,
74 Compressor::decompressToNewBuffer,
75 &ErrorMsg);
7376 if (!MP) {
7477 std::cerr << "Error loading program '" << InputFile << "': "
7578 << ErrorMsg << "\n";
3131 #include "llvm/Analysis/Verifier.h"
3232 #include "llvm/Bytecode/Analyzer.h"
3333 #include "llvm/Support/CommandLine.h"
34 #include "llvm/Support/Compressor.h"
3435 #include "llvm/Support/ManagedStatic.h"
3536 #include "llvm/System/Signals.h"
3637 #include
6566 bca.progressiveVerify = Verify;
6667
6768 /// Analyze the bytecode file
68 Module* M = AnalyzeBytecodeFile(InputFilename, bca, &ErrorMessage, (Dump?Out:0));
69 Module* M = AnalyzeBytecodeFile(InputFilename, bca,
70 Compressor::decompressToNewBuffer,
71 &ErrorMessage, (Dump?Out:0));
6972
7073 // All that bcanalyzer does is write the gathered statistics to the output
7174 PrintBytecodeAnalysis(bca,*Out);
1919 #include "llvm/PassManager.h"
2020 #include "llvm/Bytecode/Reader.h"
2121 #include "llvm/Assembly/PrintModulePass.h"
22 #include "llvm/Support/Compressor.h"
2223 #include "llvm/Support/CommandLine.h"
2324 #include "llvm/Support/ManagedStatic.h"
2425 #include "llvm/Support/Streams.h"
5051 std::ostream *Out = &std::cout; // Default to printing to stdout.
5152 std::string ErrorMessage;
5253
53 std::auto_ptr M(ParseBytecodeFile(InputFilename, &ErrorMessage));
54 std::auto_ptr M(ParseBytecodeFile(InputFilename,
55 Compressor::decompressToNewBuffer,
56 &ErrorMessage));
5457 if (M.get() == 0) {
5558 cerr << argv[0] << ": ";
5659 if (ErrorMessage.size())
1818 #include "llvm/Transforms/IPO.h"
1919 #include "llvm/Target/TargetData.h"
2020 #include "llvm/Support/CommandLine.h"
21 #include "llvm/Support/Compressor.h"
2122 #include "llvm/Support/ManagedStatic.h"
2223 #include "llvm/Support/Streams.h"
2324 #include "llvm/System/Signals.h"
5657 cl::ParseCommandLineOptions(argc, argv, " llvm extractor\n");
5758 sys::PrintStackTraceOnErrorSignal();
5859
59 std::auto_ptr M(ParseBytecodeFile(InputFilename));
60 std::auto_ptr M(ParseBytecodeFile(InputFilename,
61 Compressor::decompressToNewBuffer));
6062 if (M.get() == 0) {
6163 cerr << argv[0] << ": bytecode didn't read correctly.\n";
6264 return 1;
5858 std::string ErrorMessage;
5959 if (Filename.exists()) {
6060 if (Verbose) cerr << "Loading '" << Filename.c_str() << "'\n";
61 Module* Result = ParseBytecodeFile(Filename.toString(), &ErrorMessage);
61 Module* Result = ParseBytecodeFile(Filename.toString(),
62 Compressor::decompressToNewBuffer,
63 &ErrorMessage);
6264 if (Result) return std::auto_ptr(Result); // Load successful!
6365
6466 if (Verbose) {
126126 }
127127 // Note: Currently we do not support reading an archive from stdin.
128128 if (Filename == "-" || aPath.isBytecodeFile()) {
129 Module *Result = ParseBytecodeFile(Filename, &ErrorMessage);
129 Module *Result = ParseBytecodeFile(Filename,
130 Compressor::decompressToNewBuffer,
131 &ErrorMessage);
130132 if (Result) {
131133 DumpSymbolNamesFromModule (Result);
132134 } else {
114114
115115 // Read in the bytecode file...
116116 std::string ErrorMessage;
117 Module *M = ParseBytecodeFile(BytecodeFile, &ErrorMessage);
117 Module *M = ParseBytecodeFile(BytecodeFile,
118 Compressor::decompressToNewBuffer,
119 &ErrorMessage);
118120 if (M == 0) {
119121 std::cerr << argv[0] << ": " << BytecodeFile << ": "
120122 << ErrorMessage << "\n";
4848 int exitCode = 0;
4949 std::ostream *Out = 0;
5050 std::string ErrorMessage;
51 std::auto_ptr M(ParseBytecodeFile(InputFilename, &ErrorMessage));
51 std::auto_ptr M(ParseBytecodeFile(InputFilename,
52 Compressor::decompressToNewBuffer,
53 &ErrorMessage));
5254 if (M.get() == 0) {
5355 std::cerr << argv[0] << ": ";
5456 if (ErrorMessage.size())
568568 if (fullpath.isBytecodeFile()) {
569569 // Process the dependent libraries recursively
570570 Module::LibraryListType modlibs;
571 if (GetBytecodeDependentLibraries(fullpath.toString(),modlibs,&err)) {
571 if (GetBytecodeDependentLibraries(fullpath.toString(),modlibs,
572 Compressor::decompressToNewBuffer,
573 &err)) {
572574 // Traverse the dependent libraries list
573575 Module::lib_iterator LI = modlibs.begin();
574576 Module::lib_iterator LE = modlibs.end();
253253 std::string ErrorMessage;
254254
255255 // Load the input module...
256 std::auto_ptr M(ParseBytecodeFile(InputFilename, &ErrorMessage));
256 std::auto_ptr M(ParseBytecodeFile(InputFilename,
257 Compressor::decompressToNewBuffer, &ErrorMessage));
257258 if (M.get() == 0) {
258259 cerr << argv[0] << ": ";
259260 if (ErrorMessage.size())