[llvm-commits] CVS: llvm/lib/Bytecode/Reader/Analyzer.cpp Reader.cpp Reader.h ReaderWrappers.cpp
LLVM
llvm at cs.uiuc.edu
Sun Jul 4 19:59:01 PDT 2004
Changes in directory llvm/lib/Bytecode/Reader:
Analyzer.cpp updated: 1.8 -> 1.9
Reader.cpp updated: 1.109 -> 1.110
Reader.h updated: 1.2 -> 1.3
ReaderWrappers.cpp updated: 1.24 -> 1.25
---
Log message:
Finalize bytecode dumping. The "handleFinish" method was getting called
too soon so the function data was not getting dumped (it was generated
after the call handleFinish). Also cleaned up the output format for
proper indentation.
---
Diffs of the changes: (+38 -29)
Index: llvm/lib/Bytecode/Reader/Analyzer.cpp
diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.8 llvm/lib/Bytecode/Reader/Analyzer.cpp:1.9
--- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.8 Sun Jul 4 06:00:39 2004
+++ llvm/lib/Bytecode/Reader/Analyzer.cpp Sun Jul 4 19:57:50 2004
@@ -185,9 +185,9 @@
}
virtual void handleGlobalInitializer(GlobalVariable* GV, Constant* CV) {
- dump << " Initializer: GV=";
+ dump << " Initializer: GV=";
GV->print(dump);
- dump << " CV=";
+ dump << " CV=";
CV->print(dump);
dump << "\n";
}
@@ -204,17 +204,17 @@
}
virtual void handleCompactionTableBegin() {
- dump << " BLOCK: CompactionTable {\n";
+ dump << " BLOCK: CompactionTable {\n";
}
virtual void handleCompactionTablePlane( unsigned Ty, unsigned NumEntries) {
bca.numCmpctnTables++;
- dump << " Plane: Ty=" << Ty << " Size=" << NumEntries << "\n";
+ dump << " Plane: Ty=" << Ty << " Size=" << NumEntries << "\n";
}
virtual void handleCompactionTableType( unsigned i, unsigned TypSlot,
const Type* Ty ) {
- dump << " Type: " << i << " Slot:" << TypSlot
+ dump << " Type: " << i << " Slot:" << TypSlot
<< " is " << Ty->getDescription() << "\n";
}
@@ -223,13 +223,13 @@
unsigned TypSlot,
unsigned ValSlot,
const Type* Ty ) {
- dump << " Value: " << i << " TypSlot: " << TypSlot
+ dump << " Value: " << i << " TypSlot: " << TypSlot
<< " ValSlot:" << ValSlot << " is " << Ty->getDescription()
<< "\n";
}
virtual void handleCompactionTableEnd() {
- dump << " } END BLOCK: CompactionTable\n";
+ dump << " } END BLOCK: CompactionTable\n";
}
virtual void handleSymbolTableBegin(Function* CF, SymbolTable* ST) {
@@ -260,9 +260,9 @@
}
virtual void handleFunctionBegin(Function* Func, unsigned Size) {
- dump << "BLOCK: Function {\n";
- dump << " Linkage: " << Func->getLinkage() << "\n";
- dump << " Type: " << Func->getType()->getDescription() << "\n";
+ dump << " BLOCK: Function {\n";
+ dump << " Linkage: " << Func->getLinkage() << "\n";
+ dump << " Type: " << Func->getType()->getDescription() << "\n";
const FunctionType* FType =
cast<FunctionType>(Func->getType()->getElementType());
currFunc = &bca.FunctionInfo[Func];
@@ -284,7 +284,7 @@
}
virtual void handleFunctionEnd( Function* Func) {
- dump << "} END BLOCK: Function\n";
+ dump << " } END BLOCK: Function\n";
currFunc->density = double(currFunc->byteSize) /
double(currFunc->numInstructions+currFunc->numBasicBlocks);
@@ -298,7 +298,7 @@
}
virtual void handleBasicBlockBegin( unsigned blocknum) {
- dump << " BLOCK: BasicBlock #" << blocknum << "{\n";
+ dump << " BLOCK: BasicBlock #" << blocknum << "{\n";
bca.numBasicBlocks++;
bca.numValues++;
if ( currFunc ) currFunc->numBasicBlocks++;
@@ -306,11 +306,12 @@
virtual bool handleInstruction( unsigned Opcode, const Type* iType,
std::vector<unsigned>& Operands, unsigned Size){
- dump << " INST: OpCode="
- << Instruction::getOpcodeName(Opcode) << " Type="
- << iType->getDescription() << "\n";
+ dump << " INST: OpCode="
+ << Instruction::getOpcodeName(Opcode) << " Type=\""
+ << iType->getDescription() << "\"";
for ( unsigned i = 0; i < Operands.size(); ++i )
- dump << " Op#" << i << " Slot=" << Operands[i] << "\n";
+ dump << " Op(" << i << ")=Slot(" << Operands[i] << ")";
+ dump << "\n";
bca.numInstructions++;
bca.numValues++;
@@ -327,7 +328,7 @@
}
virtual void handleBasicBlockEnd(unsigned blocknum) {
- dump << " } END BLOCK: BasicBlock #" << blocknum << "{\n";
+ dump << " } END BLOCK: BasicBlock #" << blocknum << "{\n";
}
virtual void handleGlobalConstantsBegin() {
Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.109 llvm/lib/Bytecode/Reader/Reader.cpp:1.110
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.109 Sun Jul 4 06:33:49 2004
+++ llvm/lib/Bytecode/Reader/Reader.cpp Sun Jul 4 19:57:50 2004
@@ -894,7 +894,6 @@
BB = ParsedBasicBlocks[BlockNo] = new BasicBlock();
else
BB = ParsedBasicBlocks[BlockNo];
- if (Handler) Handler->handleBasicBlockEnd( BlockNo );
++BlockNo;
F->getBasicBlockList().push_back(BB);
@@ -904,6 +903,8 @@
if (!BB->getTerminator())
throw std::string("Non-terminated basic block found!");
+
+ if (Handler) Handler->handleBasicBlockEnd( BlockNo-1 );
}
return BlockNo;
@@ -1898,7 +1899,8 @@
/// and \p Length parameters.
void BytecodeReader::ParseBytecode(
BufPtr Buf, unsigned Length,
- const std::string &ModuleID) {
+ const std::string &ModuleID,
+ bool processFunctions) {
try {
At = MemStart = BlockStart = Buf;
@@ -1934,14 +1936,19 @@
// Parse the module contents
this->ParseModule();
- // Tell the handler we're done
- if (Handler) Handler->handleModuleEnd(ModuleID);
-
// Check for missing functions
if ( hasFunctions() )
throw std::string("Function expected, but bytecode stream ended!");
- // Tell the handler we're
+ // Process all the function bodies now, if requested
+ if ( processFunctions )
+ ParseAllFunctionBodies();
+
+ // Tell the handler we're done with the module
+ if (Handler)
+ Handler->handleModuleEnd(ModuleID);
+
+ // Tell the handler we're finished the parse
if (Handler) Handler->handleFinish();
} catch (std::string& errstr ) {
Index: llvm/lib/Bytecode/Reader/Reader.h
diff -u llvm/lib/Bytecode/Reader/Reader.h:1.2 llvm/lib/Bytecode/Reader/Reader.h:1.3
--- llvm/lib/Bytecode/Reader/Reader.h:1.2 Sun Jul 4 06:04:56 2004
+++ llvm/lib/Bytecode/Reader/Reader.h Sun Jul 4 19:57:50 2004
@@ -127,9 +127,10 @@
public:
/// @brief Main interface to parsing a bytecode buffer.
void ParseBytecode(
- const unsigned char *Buf, ///< Beginning of the bytecode buffer
- unsigned Length, ///< Length of the bytecode buffer
- const std::string &ModuleID ///< An identifier for the module constructed.
+ const unsigned char *Buf, ///< Beginning of the bytecode buffer
+ unsigned Length, ///< Length of the bytecode buffer
+ const std::string &ModuleID, ///< An identifier for the module constructed.
+ bool processFunctions=false ///< Process all function bodies fully.
);
/// @brief Parse all function bodies
Index: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp
diff -u llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.24 llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.25
--- llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.24 Sun Jul 4 06:03:03 2004
+++ llvm/lib/Bytecode/Reader/ReaderWrappers.cpp Sun Jul 4 19:57:50 2004
@@ -58,7 +58,7 @@
try {
// Parse the bytecode we mmapped in
- ParseBytecode(Buffer, Length, Filename);
+ ParseBytecode(Buffer, Length, Filename, H != 0);
} catch (...) {
UnmapFileFromAddressSpace(Buffer, Length);
throw;
@@ -114,7 +114,7 @@
MustDelete = false;
}
try {
- ParseBytecode(ParseBegin, Length, ModuleID);
+ ParseBytecode(ParseBegin, Length, ModuleID, H != 0);
} catch (...) {
if (MustDelete) delete [] Buffer;
throw;
@@ -163,7 +163,7 @@
throw std::string("Standard Input empty!");
FileBuf = &FileData[0];
- ParseBytecode(FileBuf, FileData.size(), "<stdin>");
+ ParseBytecode(FileBuf, FileData.size(), "<stdin>", H != 0 );
}
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list