[llvm-commits] CVS: llvm/lib/Bytecode/Archive/Archive.cpp ArchiveInternals.h ArchiveReader.cpp ArchiveWriter.cpp
Chris Lattner
sabre at nondot.org
Sun May 6 02:28:52 PDT 2007
Changes in directory llvm/lib/Bytecode/Archive:
Archive.cpp updated: 1.22 -> 1.23
ArchiveInternals.h updated: 1.6 -> 1.7
ArchiveReader.cpp updated: 1.51 -> 1.52
ArchiveWriter.cpp updated: 1.38 -> 1.39
---
Log message:
Switch this over to bitcode instead of bytecode.
---
Diffs of the changes: (+40 -60)
Archive.cpp | 28 +++++++++++++++---------
ArchiveInternals.h | 5 +---
ArchiveReader.cpp | 61 +++++++++++++++--------------------------------------
ArchiveWriter.cpp | 6 +----
4 files changed, 40 insertions(+), 60 deletions(-)
Index: llvm/lib/Bytecode/Archive/Archive.cpp
diff -u llvm/lib/Bytecode/Archive/Archive.cpp:1.22 llvm/lib/Bytecode/Archive/Archive.cpp:1.23
--- llvm/lib/Bytecode/Archive/Archive.cpp:1.22 Sat Apr 7 14:51:45 2007
+++ llvm/lib/Bytecode/Archive/Archive.cpp Sun May 6 04:28:33 2007
@@ -13,9 +13,10 @@
//===----------------------------------------------------------------------===//
#include "ArchiveInternals.h"
+#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/ModuleProvider.h"
#include "llvm/Module.h"
-#include "llvm/Bytecode/Reader.h"
+#include "llvm/Support/MemoryBuffer.h"
#include "llvm/System/Process.h"
using namespace llvm;
@@ -142,10 +143,9 @@
// Archive constructor - this is the only constructor that gets used for the
// Archive class. Everything else (default,copy) is deprecated. This just
// initializes and maps the file into memory, if requested.
-Archive::Archive(const sys::Path& filename, BCDecompressor_t *BCDC)
+Archive::Archive(const sys::Path& filename)
: archPath(filename), members(), mapfile(0), base(0), symTab(), strtab(),
- symTabSize(0), firstFileOffset(0), modules(), foreignST(0),
- Decompressor(BCDC) {
+ symTabSize(0), firstFileOffset(0), modules(), foreignST(0) {
}
bool
@@ -213,9 +213,16 @@
// Get just the externally visible defined symbols from the bytecode
bool llvm::GetBytecodeSymbols(const sys::Path& fName,
std::vector<std::string>& symbols,
- BCDecompressor_t *BCDC,
std::string* ErrMsg) {
- ModuleProvider *MP = getBytecodeModuleProvider(fName.toString(), BCDC,ErrMsg);
+ std::auto_ptr<MemoryBuffer> Buffer(
+ MemoryBuffer::getFileOrSTDIN(&fName.toString()[0],
+ fName.toString().size()));
+ if (!Buffer.get()) {
+ if (ErrMsg) *ErrMsg = "Could not open file '" + fName.toString() + "'";
+ return true;
+ }
+
+ ModuleProvider *MP = getBitcodeModuleProvider(Buffer.get(), ErrMsg);
if (!MP)
return true;
@@ -235,14 +242,15 @@
}
ModuleProvider*
-llvm::GetBytecodeSymbols(const unsigned char*Buffer, unsigned Length,
+llvm::GetBytecodeSymbols(const unsigned char *BufPtr, unsigned Length,
const std::string& ModuleID,
std::vector<std::string>& symbols,
- BCDecompressor_t *BCDC,
std::string* ErrMsg) {
// Get the module provider
- ModuleProvider* MP =
- getBytecodeBufferModuleProvider(Buffer, Length, ModuleID, BCDC, ErrMsg, 0);
+ MemoryBuffer *Buffer =MemoryBuffer::getNewMemBuffer(Length, ModuleID.c_str());
+ memcpy((char*)Buffer->getBufferStart(), BufPtr, Length);
+
+ ModuleProvider *MP = getBitcodeModuleProvider(Buffer, ErrMsg);
if (!MP)
return 0;
Index: llvm/lib/Bytecode/Archive/ArchiveInternals.h
diff -u llvm/lib/Bytecode/Archive/ArchiveInternals.h:1.6 llvm/lib/Bytecode/Archive/ArchiveInternals.h:1.7
--- llvm/lib/Bytecode/Archive/ArchiveInternals.h:1.6 Wed Feb 7 17:53:17 2007
+++ llvm/lib/Bytecode/Archive/ArchiveInternals.h Sun May 6 04:28:33 2007
@@ -14,7 +14,7 @@
#ifndef LIB_BYTECODE_ARCHIVEINTERNALS_H
#define LIB_BYTECODE_ARCHIVEINTERNALS_H
-#include "llvm/Bytecode/Archive.h"
+#include "llvm/Bitcode/Archive.h"
#include "llvm/System/TimeValue.h"
#include "llvm/ADT/StringExtras.h"
@@ -70,12 +70,11 @@
// Get just the externally visible defined symbols from the bytecode
bool GetBytecodeSymbols(const sys::Path& fName,
std::vector<std::string>& symbols,
- BCDecompressor_t *BCDC, std::string* ErrMsg);
+ std::string* ErrMsg);
ModuleProvider* GetBytecodeSymbols(const unsigned char*Buffer,unsigned Length,
const std::string& ModuleID,
std::vector<std::string>& symbols,
- BCDecompressor_t *BCDC,
std::string* ErrMsg);
}
Index: llvm/lib/Bytecode/Archive/ArchiveReader.cpp
diff -u llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.51 llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.52
--- llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.51 Sun May 6 01:18:07 2007
+++ llvm/lib/Bytecode/Archive/ArchiveReader.cpp Sun May 6 04:28:33 2007
@@ -12,15 +12,12 @@
//===----------------------------------------------------------------------===//
#include "ArchiveInternals.h"
-#include "llvm/Bytecode/Reader.h"
#include "llvm/Bitcode/ReaderWriter.h"
-#include "llvm/Support/Compressor.h"
#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Module.h"
#include <memory>
using namespace llvm;
-static bool Bitcode = false;
-
/// Read a variable-bit-rate encoded unsigned integer
inline unsigned readInteger(const char*&At, const char*End){
unsigned Shift = 0;
@@ -355,21 +352,12 @@
if (I->isBytecode() || I->isCompressedBytecode()) {
std::string FullMemberName = archPath.toString() +
"(" + I->getPath().toString() + ")";
- Module *M;
+ MemoryBuffer *Buffer =
+ MemoryBuffer::getNewMemBuffer(I->getSize(), FullMemberName.c_str());
+ memcpy((char*)Buffer->getBufferStart(), I->getData(), I->getSize());
- if (Bitcode) {
- MemoryBuffer *Buffer =
- MemoryBuffer::getNewMemBuffer(I->getSize(), FullMemberName.c_str());
- memcpy((char*)Buffer->getBufferStart(), I->getData(), I->getSize());
-
- M = ParseBitcodeFile(Buffer, ErrMessage);
- delete Buffer;
- } else {
- M = ParseBytecodeBuffer((const unsigned char*)I->getData(),
- I->getSize(), FullMemberName,
- Compressor::decompressToNewBuffer,
- ErrMessage);
- }
+ Module *M = ParseBitcodeFile(Buffer, ErrMessage);
+ delete Buffer;
if (!M)
return true;
@@ -502,17 +490,11 @@
// Now, load the bytecode module to get the ModuleProvider
std::string FullMemberName = archPath.toString() + "(" +
mbr->getPath().toString() + ")";
- ModuleProvider* mp;
- if (Bitcode) {
- MemoryBuffer *Buffer =MemoryBuffer::getNewMemBuffer(mbr->getSize(),
- FullMemberName.c_str());
- memcpy((char*)Buffer->getBufferStart(), mbr->getData(), mbr->getSize());
-
- mp = getBitcodeModuleProvider(Buffer, ErrMsg);
- } else
- mp = getBytecodeBufferModuleProvider(
- (const unsigned char*) mbr->getData(), mbr->getSize(),
- FullMemberName, Decompressor, ErrMsg, 0);
+ MemoryBuffer *Buffer =MemoryBuffer::getNewMemBuffer(mbr->getSize(),
+ FullMemberName.c_str());
+ memcpy((char*)Buffer->getBufferStart(), mbr->getData(), mbr->getSize());
+
+ ModuleProvider *mp = getBitcodeModuleProvider(Buffer, ErrMsg);
if (!mp)
return 0;
@@ -560,8 +542,7 @@
mbr->getPath().toString() + ")";
ModuleProvider* MP =
GetBytecodeSymbols((const unsigned char*)At, mbr->getSize(),
- FullMemberName, symbols,
- Compressor::decompressToNewBuffer, error);
+ FullMemberName, symbols, error);
if (MP) {
// Insert the module's symbols into the symbol table
@@ -636,18 +617,12 @@
std::string FullMemberName =
archPath.toString() + "(" + I->getPath().toString() + ")";
- Module *M;
-
- if (Bitcode) {
- MemoryBuffer *Buffer =
- MemoryBuffer::getNewMemBuffer(I->getSize(), FullMemberName.c_str());
- memcpy((char*)Buffer->getBufferStart(), I->getData(), I->getSize());
- M = ParseBitcodeFile(Buffer);
- delete Buffer;
- } else {
- M = ParseBytecodeBuffer((const unsigned char*)I->getData(),
- I->getSize(), FullMemberName);
- }
+
+ MemoryBuffer *Buffer =
+ MemoryBuffer::getNewMemBuffer(I->getSize(), FullMemberName.c_str());
+ memcpy((char*)Buffer->getBufferStart(), I->getData(), I->getSize());
+ Module *M = ParseBitcodeFile(Buffer);
+ delete Buffer;
if (!M)
return false; // Couldn't parse bytecode, not a bytecode archive.
delete M;
Index: llvm/lib/Bytecode/Archive/ArchiveWriter.cpp
diff -u llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.38 llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.39
--- llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.38 Sun May 6 01:18:07 2007
+++ llvm/lib/Bytecode/Archive/ArchiveWriter.cpp Sun May 6 04:28:33 2007
@@ -12,11 +12,10 @@
//===----------------------------------------------------------------------===//
#include "ArchiveInternals.h"
-#include "llvm/Bytecode/Reader.h"
#include "llvm/Bitcode/ReaderWriter.h"
-#include "llvm/Support/Compressor.h"
#include "llvm/System/Signals.h"
#include "llvm/System/Process.h"
+#include "llvm/ModuleProvider.h"
#include <fstream>
#include <ostream>
#include <iomanip>
@@ -232,8 +231,7 @@
+ ")";
ModuleProvider* MP =
GetBytecodeSymbols((const unsigned char*)data,fSize,
- FullMemberName, symbols,
- Compressor::decompressToNewBuffer, ErrMsg);
+ FullMemberName, symbols, ErrMsg);
// If the bytecode parsed successfully
if ( MP ) {
More information about the llvm-commits
mailing list