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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14627 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Spencer 2004-07-05 00:57:50 +00:00
parent c156095b17
commit 5c15fe5cf8
4 changed files with 38 additions and 29 deletions

View File

@ -307,10 +307,11 @@ public:
virtual bool handleInstruction( unsigned Opcode, const Type* iType,
std::vector<unsigned>& Operands, unsigned Size){
dump << " INST: OpCode="
<< Instruction::getOpcodeName(Opcode) << " Type="
<< iType->getDescription() << "\n";
<< 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++;

View File

@ -894,7 +894,6 @@ unsigned BytecodeReader::ParseInstructionList(Function* F) {
BB = ParsedBasicBlocks[BlockNo] = new BasicBlock();
else
BB = ParsedBasicBlocks[BlockNo];
if (Handler) Handler->handleBasicBlockEnd( BlockNo );
++BlockNo;
F->getBasicBlockList().push_back(BB);
@ -904,6 +903,8 @@ unsigned BytecodeReader::ParseInstructionList(Function* F) {
if (!BB->getTerminator())
throw std::string("Non-terminated basic block found!");
if (Handler) Handler->handleBasicBlockEnd( BlockNo-1 );
}
return BlockNo;
@ -1898,7 +1899,8 @@ void BytecodeReader::ParseModule() {
/// 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 @@ void BytecodeReader::ParseBytecode(
// 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 ) {

View File

@ -129,7 +129,8 @@ public:
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 std::string &ModuleID, ///< An identifier for the module constructed.
bool processFunctions=false ///< Process all function bodies fully.
);
/// @brief Parse all function bodies

View File

@ -58,7 +58,7 @@ BytecodeFileReader::BytecodeFileReader(const std::string &Filename,
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 @@ BytecodeBufferReader::BytecodeBufferReader(const unsigned char *Buf,
MustDelete = false;
}
try {
ParseBytecode(ParseBegin, Length, ModuleID);
ParseBytecode(ParseBegin, Length, ModuleID, H != 0);
} catch (...) {
if (MustDelete) delete [] Buffer;
throw;
@ -163,7 +163,7 @@ BytecodeStdinReader::BytecodeStdinReader( BytecodeHandler* H )
throw std::string("Standard Input empty!");
FileBuf = &FileData[0];
ParseBytecode(FileBuf, FileData.size(), "<stdin>");
ParseBytecode(FileBuf, FileData.size(), "<stdin>", H != 0 );
}
//===----------------------------------------------------------------------===//