[llvm-commits] CVS: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp
Changes in directory llvm/lib/Bytecode/Reader: ReaderWrappers.cpp updated: 1.66 -> 1.67 --- Log message: move archive-specific stuff out of bcreader into archive library. --- Diffs of the changes: (+0 -67) ReaderWrappers.cpp | 67 - 1 files changed, 67 deletions(-) Index: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp diff -u llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.66 llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.67 --- llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.66Wed Feb 7 17:48:32 2007 +++ llvm/lib/Bytecode/Reader/ReaderWrappers.cpp Wed Feb 7 17:53:17 2007 @@ -254,70 +254,3 @@ delete MP; return M; } - - -static void getSymbols(Module*M, std::vector& symbols) { - // Loop over global variables - for (Module::global_iterator GI = M->global_begin(), GE=M->global_end(); GI != GE; ++GI) -if (!GI->isDeclaration() && !GI->hasInternalLinkage()) - if (!GI->getName().empty()) -symbols.push_back(GI->getName()); - - // Loop over functions. - for (Module::iterator FI = M->begin(), FE = M->end(); FI != FE; ++FI) -if (!FI->isDeclaration() && !FI->hasInternalLinkage()) - if (!FI->getName().empty()) -symbols.push_back(FI->getName()); -} - -// Get just the externally visible defined symbols from the bytecode -bool llvm::GetBytecodeSymbols(const sys::Path& fName, - std::vector& symbols, - BCDecompressor_t *BCDC, - std::string* ErrMsg) { - ModuleProvider *MP = getBytecodeModuleProvider(fName.toString(), BCDC,ErrMsg); - if (!MP) -return true; - - // Get the module from the provider - Module* M = MP->materializeModule(); - if (M == 0) { -delete MP; -return true; - } - - // Get the symbols - getSymbols(M, symbols); - - // Done with the module. - delete MP; - return true; -} - -ModuleProvider* -llvm::GetBytecodeSymbols(const unsigned char*Buffer, unsigned Length, - const std::string& ModuleID, - std::vector& symbols, - BCDecompressor_t *BCDC, - std::string* ErrMsg) { - // Get the module provider - ModuleProvider* MP = -getBytecodeBufferModuleProvider(Buffer, Length, ModuleID, BCDC, ErrMsg, 0); - if (!MP) -return 0; - - // Get the module from the provider - Module* M = MP->materializeModule(); - if (M == 0) { -delete MP; -return 0; - } - - // Get the symbols - getSymbols(M, symbols); - - // Done with the module. Note that ModuleProvider will delete the - // Module when it is deleted. Also note that its the caller's responsibility - // to delete the ModuleProvider. - return MP; -} ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp
Changes in directory llvm/lib/Bytecode/Reader: ReaderWrappers.cpp updated: 1.65 -> 1.66 --- Log message: move an llvmc-specific function out of the bcreader into llvmc. --- Diffs of the changes: (+0 -16) ReaderWrappers.cpp | 16 1 files changed, 16 deletions(-) Index: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp diff -u llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.65 llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.66 --- llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.65Wed Feb 7 17:46:55 2007 +++ llvm/lib/Bytecode/Reader/ReaderWrappers.cpp Wed Feb 7 17:48:32 2007 @@ -256,22 +256,6 @@ } -bool llvm::GetBytecodeDependentLibraries(const std::string &fname, - Module::LibraryListType& deplibs, - BCDecompressor_t *BCDC, - std::string* ErrMsg) { - ModuleProvider* MP = getBytecodeModuleProvider(fname, BCDC, ErrMsg); - if (!MP) { -deplibs.clear(); -return true; - } - Module* M = MP->releaseModule(ErrMsg); - deplibs = M->getLibraries(); - delete M; - delete MP; - return false; -} - static void getSymbols(Module*M, std::vector& symbols) { // Loop over global variables for (Module::global_iterator GI = M->global_begin(), GE=M->global_end(); GI != GE; ++GI) ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp
Changes in directory llvm/lib/Bytecode/Reader: ReaderWrappers.cpp updated: 1.61 -> 1.62 --- Log message: For PR1136: http://llvm.org/PR1136 : Rename GlobalVariable::isExternal as isDeclaration to avoid confusion with external linkage types. --- Diffs of the changes: (+2 -2) ReaderWrappers.cpp |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp diff -u llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.61 llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.62 --- llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.61Sun Jan 7 00:45:57 2007 +++ llvm/lib/Bytecode/Reader/ReaderWrappers.cpp Tue Jan 30 14:08:37 2007 @@ -298,13 +298,13 @@ static void getSymbols(Module*M, std::vector& symbols) { // Loop over global variables for (Module::global_iterator GI = M->global_begin(), GE=M->global_end(); GI != GE; ++GI) -if (!GI->isExternal() && !GI->hasInternalLinkage()) +if (!GI->isDeclaration() && !GI->hasInternalLinkage()) if (!GI->getName().empty()) symbols.push_back(GI->getName()); // Loop over functions. for (Module::iterator FI = M->begin(), FE = M->end(); FI != FE; ++FI) -if (!FI->isExternal() && !FI->hasInternalLinkage()) +if (!FI->isDeclaration() && !FI->hasInternalLinkage()) if (!FI->getName().empty()) symbols.push_back(FI->getName()); } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp
Changes in directory llvm/lib/Bytecode/Reader: ReaderWrappers.cpp updated: 1.60 -> 1.61 --- Log message: remove support for old-style varargs upgrading --- Diffs of the changes: (+6 -106) ReaderWrappers.cpp | 112 ++--- 1 files changed, 6 insertions(+), 106 deletions(-) Index: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp diff -u llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.60 llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.61 --- llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.60Fri Dec 15 13:49:23 2006 +++ llvm/lib/Bytecode/Reader/ReaderWrappers.cpp Sun Jan 7 00:45:57 2007 @@ -183,106 +183,6 @@ } //===--===// -// Varargs transmogrification code... -// - -// CheckVarargs - This is used to automatically translate old-style varargs to -// new style varargs for backwards compatibility. -static ModuleProvider* CheckVarargs(ModuleProvider* MP) { - Module* M = MP->getModule(); - - // check to see if va_start takes arguements... - Function* F = M->getNamedFunction("llvm.va_start"); - if(F == 0) return MP; //No varargs use, just return. - - if (F->getFunctionType()->getNumParams() == 1) -return MP; // Modern varargs processing, just return. - - // If we get to this point, we know that we have an old-style module. - // Materialize the whole thing to perform the rewriting. - if (MP->materializeModule() == 0) -return 0; - - if(Function* F = M->getNamedFunction("llvm.va_start")) { -assert(F->arg_size() == 0 && "Obsolete va_start takes 0 argument!"); - -//foo = va_start() -// -> -//bar = alloca typeof(foo) -//va_start(bar) -//foo = load bar - -const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); -const Type* ArgTy = F->getFunctionType()->getReturnType(); -const Type* ArgTyPtr = PointerType::get(ArgTy); -Function* NF = M->getOrInsertFunction("llvm.va_start", - RetTy, ArgTyPtr, (Type *)0); - -for(Value::use_iterator I = F->use_begin(), E = F->use_end(); I != E;) - if (CallInst* CI = dyn_cast(*I++)) { -AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI); -new CallInst(NF, bar, "", CI); -Value* foo = new LoadInst(bar, "vastart.fix.2", CI); -CI->replaceAllUsesWith(foo); -CI->getParent()->getInstList().erase(CI); - } -F->setName(""); - } - - if(Function* F = M->getNamedFunction("llvm.va_end")) { -assert(F->arg_size() == 1 && "Obsolete va_end takes 1 argument!"); -//vaend foo -// -> -//bar = alloca 1 of typeof(foo) -//vaend bar -const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); -const Type* ArgTy = F->getFunctionType()->getParamType(0); -const Type* ArgTyPtr = PointerType::get(ArgTy); -Function* NF = M->getOrInsertFunction("llvm.va_end", - RetTy, ArgTyPtr, (Type *)0); - -for(Value::use_iterator I = F->use_begin(), E = F->use_end(); I != E;) - if (CallInst* CI = dyn_cast(*I++)) { -AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI); -new StoreInst(CI->getOperand(1), bar, CI); -new CallInst(NF, bar, "", CI); -CI->getParent()->getInstList().erase(CI); - } -F->setName(""); - } - - if(Function* F = M->getNamedFunction("llvm.va_copy")) { -assert(F->arg_size() == 1 && "Obsolete va_copy takes 1 argument!"); -//foo = vacopy(bar) -// -> -//a = alloca 1 of typeof(foo) -//b = alloca 1 of typeof(foo) -//store bar -> b -//vacopy(a, b) -//foo = load a - -const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); -const Type* ArgTy = F->getFunctionType()->getReturnType(); -const Type* ArgTyPtr = PointerType::get(ArgTy); -Function* NF = M->getOrInsertFunction("llvm.va_copy", - RetTy, ArgTyPtr, ArgTyPtr, (Type *)0); - -for(Value::use_iterator I = F->use_begin(), E = F->use_end(); I != E;) - if (CallInst* CI = dyn_cast(*I++)) { -AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI); -AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI); -new StoreInst(CI->getOperand(1), b, CI); -new CallInst(NF, a, b, "", CI); -Value* foo = new LoadInst(a, "vacopy.fix.3", CI); -CI->replaceAllUsesWith(foo); -CI->getParent()->getInstList().erase(CI); - } -F->setName(""); - } - return MP; -} - -//===--===// // Wrapper functions //===--===// @@ -294,11 +194,11 @@ const std::string &ModuleID, std::string *ErrMsg, BytecodeHandler *H) { - BytecodeBufferReader* rdr = + BytecodeBuff
[llvm-commits] CVS: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp
Changes in directory llvm/lib/Bytecode/Reader: ReaderWrappers.cpp updated: 1.58 -> 1.59 --- Log message: Removed more includes --- Diffs of the changes: (+3 -5) ReaderWrappers.cpp |8 +++- 1 files changed, 3 insertions(+), 5 deletions(-) Index: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp diff -u llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.58 llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.59 --- llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.58Thu Oct 12 13:32:30 2006 +++ llvm/lib/Bytecode/Reader/ReaderWrappers.cpp Thu Dec 7 14:28:15 2006 @@ -21,9 +21,7 @@ #include "llvm/System/MappedFile.h" #include "llvm/System/Program.h" #include -#include #include - using namespace llvm; //===--===// @@ -164,9 +162,9 @@ char Buffer[4096*4]; // Read in all of the data from stdin, we cannot mmap stdin... - while (std::cin.good()) { -std::cin.read(Buffer, 4096*4); -int BlockSize = std::cin.gcount(); + while (cin.stream()->good()) { +cin.stream()->read(Buffer, 4096*4); +int BlockSize = cin.stream()->gcount(); if (0 >= BlockSize) break; FileData.insert(FileData.end(), Buffer, Buffer+BlockSize); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp
Changes in directory llvm/lib/Bytecode/Reader: ReaderWrappers.cpp updated: 1.56 -> 1.57 --- Log message: For PR797: http://llvm.org/PR797 : Remove exception throwing/handling from lib/Bytecode, and adjust its users to compensate for changes in the interface. --- Diffs of the changes: (+134 -103) ReaderWrappers.cpp | 237 + 1 files changed, 134 insertions(+), 103 deletions(-) Index: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp diff -u llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.56 llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.57 --- llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.56Tue Aug 22 11:10:12 2006 +++ llvm/lib/Bytecode/Reader/ReaderWrappers.cpp Fri Aug 25 12:43:11 2006 @@ -35,6 +35,7 @@ /// class BytecodeFileReader : public BytecodeReader { private: +std::string fileName; sys::MappedFile mapFile; BytecodeFileReader(const BytecodeFileReader&); // Do not implement @@ -42,23 +43,30 @@ public: BytecodeFileReader(const std::string &Filename, llvm::BytecodeHandler* H=0); +bool read(std::string* ErrMsg); }; } BytecodeFileReader::BytecodeFileReader(const std::string &Filename, llvm::BytecodeHandler* H ) : BytecodeReader(H) + , fileName(Filename) , mapFile() { - std::string ErrMsg; - if (mapFile.open(sys::Path(Filename), sys::MappedFile::READ_ACCESS, &ErrMsg)) -throw ErrMsg; - if (!mapFile.map(&ErrMsg)) -throw ErrMsg; +} + +bool BytecodeFileReader::read(std::string* ErrMsg) { + if (mapFile.open(sys::Path(fileName), sys::MappedFile::READ_ACCESS, ErrMsg)) +return true; + if (!mapFile.map(ErrMsg)) { +mapFile.close(); +return true; + } unsigned char* buffer = reinterpret_cast(mapFile.base()); - if (ParseBytecode(buffer, mapFile.size(), Filename, &ErrMsg)) { -throw ErrMsg; + if (ParseBytecode(buffer, mapFile.size(), fileName, ErrMsg)) { +return true; } + return false; } //===--===// @@ -71,6 +79,9 @@ class BytecodeBufferReader : public BytecodeReader { private: const unsigned char *Buffer; +const unsigned char *Buf; +unsigned Length; +std::string ModuleID; bool MustDelete; BytecodeBufferReader(const BytecodeBufferReader&); // Do not implement @@ -82,15 +93,30 @@ llvm::BytecodeHandler* Handler = 0); ~BytecodeBufferReader(); +bool read(std::string* ErrMsg); + }; } -BytecodeBufferReader::BytecodeBufferReader(const unsigned char *Buf, - unsigned Length, - const std::string &ModuleID, - llvm::BytecodeHandler* H ) +BytecodeBufferReader::BytecodeBufferReader(const unsigned char *buf, + unsigned len, + const std::string &modID, + llvm::BytecodeHandler* H) : BytecodeReader(H) + , Buffer(0) + , Buf(buf) + , Length(len) + , ModuleID(modID) + , MustDelete(false) { +} + +BytecodeBufferReader::~BytecodeBufferReader() { + if (MustDelete) delete [] Buffer; +} + +bool +BytecodeBufferReader::read(std::string* ErrMsg) { // If not aligned, allocate a new buffer to hold the bytecode... const unsigned char *ParseBegin = 0; if (reinterpret_cast(Buf) & 3) { @@ -104,15 +130,11 @@ ParseBegin = Buffer = Buf; MustDelete = false; } - std::string ErrMsg; - if (ParseBytecode(ParseBegin, Length, ModuleID, &ErrMsg)) { + if (ParseBytecode(ParseBegin, Length, ModuleID, ErrMsg)) { if (MustDelete) delete [] Buffer; -throw ErrMsg; +return true; } -} - -BytecodeBufferReader::~BytecodeBufferReader() { - if (MustDelete) delete [] Buffer; + return false; } //===--===// @@ -132,12 +154,18 @@ public: BytecodeStdinReader( llvm::BytecodeHandler* H = 0 ); +bool read(std::string* ErrMsg); }; } BytecodeStdinReader::BytecodeStdinReader( BytecodeHandler* H ) : BytecodeReader(H) { +} + +bool +BytecodeStdinReader::read(std::string* ErrMsg) +{ sys::Program::ChangeStdinToBinary(); char Buffer[4096*4]; @@ -150,14 +178,16 @@ FileData.insert(FileData.end(), Buffer, Buffer+BlockSize); } - if (FileData.empty()) -throw std::string("Standard Input empty!"); + if (FileData.empty()) { +if (ErrMsg) + *ErrMsg = "Standard Input is empty!"; +return true; + } FileBuf = &FileData[0]; - std::string ErrMsg; - if (ParseBytecode(FileBuf, FileData.size(), "", &ErrMsg)) { -throw ErrMsg; - } + if (ParseBytecode(FileBuf, FileData.size(), "", ErrMsg)) +return true; + return false; } //===--===// @@ -270,66 +300,71 @@
[llvm-commits] CVS: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp
Changes in directory llvm/lib/Bytecode/Reader: ReaderWrappers.cpp updated: 1.55 -> 1.56 --- Log message: For PR797: http://llvm.org/PR797 : Adjust the use of MappedFile to its new non-throwing interface. We just propagate the exceptions if an error occurs. This will get cleaned up later, incrementally. --- Diffs of the changes: (+16 -8) ReaderWrappers.cpp | 24 1 files changed, 16 insertions(+), 8 deletions(-) Index: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp diff -u llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.55 llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.56 --- llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.55Thu Jul 6 16:35:01 2006 +++ llvm/lib/Bytecode/Reader/ReaderWrappers.cpp Tue Aug 22 11:10:12 2006 @@ -48,11 +48,17 @@ BytecodeFileReader::BytecodeFileReader(const std::string &Filename, llvm::BytecodeHandler* H ) : BytecodeReader(H) - , mapFile( sys::Path(Filename)) + , mapFile() { - mapFile.map(); + std::string ErrMsg; + if (mapFile.open(sys::Path(Filename), sys::MappedFile::READ_ACCESS, &ErrMsg)) +throw ErrMsg; + if (!mapFile.map(&ErrMsg)) +throw ErrMsg; unsigned char* buffer = reinterpret_cast(mapFile.base()); - ParseBytecode(buffer, mapFile.size(), Filename); + if (ParseBytecode(buffer, mapFile.size(), Filename, &ErrMsg)) { +throw ErrMsg; + } } //===--===// @@ -98,11 +104,10 @@ ParseBegin = Buffer = Buf; MustDelete = false; } - try { -ParseBytecode(ParseBegin, Length, ModuleID); - } catch (...) { + std::string ErrMsg; + if (ParseBytecode(ParseBegin, Length, ModuleID, &ErrMsg)) { if (MustDelete) delete [] Buffer; -throw; +throw ErrMsg; } } @@ -149,7 +154,10 @@ throw std::string("Standard Input empty!"); FileBuf = &FileData[0]; - ParseBytecode(FileBuf, FileData.size(), ""); + std::string ErrMsg; + if (ParseBytecode(FileBuf, FileData.size(), "", &ErrMsg)) { +throw ErrMsg; + } } //===--===// ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp
Changes in directory llvm/lib/Bytecode/Reader: ReaderWrappers.cpp updated: 1.53 -> 1.54 --- Log message: For PR787: http://llvm.cs.uiuc.edu/PR787 : Provide new llvm::sys::Program facilities for converting the stdout and stdin to binary mode. There is no standard way to do this and the available mechanisms are platform specific. Adjust the bytecode reader and writer to use these methods when their input is stdin or output is stdout. THis avoids the problem with \n writing CRLF to a bytecode file on windows. Patch Contributed by Michael Smith. --- Diffs of the changes: (+2 -0) ReaderWrappers.cpp |2 ++ 1 files changed, 2 insertions(+) Index: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp diff -u llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.53 llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.54 --- llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.53Mon Dec 26 08:23:22 2005 +++ llvm/lib/Bytecode/Reader/ReaderWrappers.cpp Wed Jun 7 18:18:33 2006 @@ -19,6 +19,7 @@ #include "llvm/Instructions.h" #include "llvm/ADT/StringExtras.h" #include "llvm/System/MappedFile.h" +#include "llvm/System/Program.h" #include #include #include @@ -132,6 +133,7 @@ BytecodeStdinReader::BytecodeStdinReader( BytecodeHandler* H ) : BytecodeReader(H) { + sys::Program::ChangeStdinToBinary(); char Buffer[4096*4]; // Read in all of the data from stdin, we cannot mmap stdin... ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits