Fix the bug that was preventing the parser from working on all bytecode
files. It was reading non-initialized global vars when the flag said it was initialized and vice versa. Causes mis-alignment since initialized and non-initialized constants have different bytecode lengths. llvm-svn: 14057
This commit is contained in:
		
							parent
							
								
									2c5613d1c3
								
							
						
					
					
						commit
						42427f0ccb
					
				| 
						 | 
					@ -156,7 +156,8 @@ void AbstractBytecodeParser::ParseBasicBlock(BufPtr &Buf,
 | 
				
			||||||
/// ParseInstructionList - Parse all of the BasicBlock's & Instruction's in the
 | 
					/// ParseInstructionList - Parse all of the BasicBlock's & Instruction's in the
 | 
				
			||||||
/// body of a function.  In post 1.0 bytecode files, we no longer emit basic
 | 
					/// body of a function.  In post 1.0 bytecode files, we no longer emit basic
 | 
				
			||||||
/// block individually, in order to avoid per-basic-block overhead.
 | 
					/// block individually, in order to avoid per-basic-block overhead.
 | 
				
			||||||
unsigned AbstractBytecodeParser::ParseInstructionList( BufPtr &Buf, BufPtr EndBuf) {
 | 
					unsigned AbstractBytecodeParser::ParseInstructionList( BufPtr &Buf, 
 | 
				
			||||||
 | 
					                                                       BufPtr EndBuf) {
 | 
				
			||||||
  unsigned BlockNo = 0;
 | 
					  unsigned BlockNo = 0;
 | 
				
			||||||
  std::vector<unsigned> Args;
 | 
					  std::vector<unsigned> Args;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -698,12 +699,11 @@ void AbstractBytecodeParser::ParseModuleGlobalInfo(BufPtr &Buf, BufPtr End) {
 | 
				
			||||||
    const Type *ElTy = cast<PointerType>(Ty)->getElementType();
 | 
					    const Type *ElTy = cast<PointerType>(Ty)->getElementType();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Create the global variable...
 | 
					    // Create the global variable...
 | 
				
			||||||
    if (hasInitializer)
 | 
					    if (hasInitializer) {
 | 
				
			||||||
      handler->handleGlobalVariable( ElTy, isConstant, Linkage );
 | 
					 | 
				
			||||||
    else {
 | 
					 | 
				
			||||||
      unsigned initSlot = read_vbr_uint(Buf,End);
 | 
					      unsigned initSlot = read_vbr_uint(Buf,End);
 | 
				
			||||||
      handler->handleInitializedGV( ElTy, isConstant, Linkage, initSlot );
 | 
					      handler->handleInitializedGV( ElTy, isConstant, Linkage, initSlot );
 | 
				
			||||||
    }
 | 
					    } else 
 | 
				
			||||||
 | 
					      handler->handleGlobalVariable( ElTy, isConstant, Linkage );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Get next item
 | 
					    // Get next item
 | 
				
			||||||
    VarType = read_vbr_uint(Buf, End);
 | 
					    VarType = read_vbr_uint(Buf, End);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -156,7 +156,8 @@ void AbstractBytecodeParser::ParseBasicBlock(BufPtr &Buf,
 | 
				
			||||||
/// ParseInstructionList - Parse all of the BasicBlock's & Instruction's in the
 | 
					/// ParseInstructionList - Parse all of the BasicBlock's & Instruction's in the
 | 
				
			||||||
/// body of a function.  In post 1.0 bytecode files, we no longer emit basic
 | 
					/// body of a function.  In post 1.0 bytecode files, we no longer emit basic
 | 
				
			||||||
/// block individually, in order to avoid per-basic-block overhead.
 | 
					/// block individually, in order to avoid per-basic-block overhead.
 | 
				
			||||||
unsigned AbstractBytecodeParser::ParseInstructionList( BufPtr &Buf, BufPtr EndBuf) {
 | 
					unsigned AbstractBytecodeParser::ParseInstructionList( BufPtr &Buf, 
 | 
				
			||||||
 | 
					                                                       BufPtr EndBuf) {
 | 
				
			||||||
  unsigned BlockNo = 0;
 | 
					  unsigned BlockNo = 0;
 | 
				
			||||||
  std::vector<unsigned> Args;
 | 
					  std::vector<unsigned> Args;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -698,12 +699,11 @@ void AbstractBytecodeParser::ParseModuleGlobalInfo(BufPtr &Buf, BufPtr End) {
 | 
				
			||||||
    const Type *ElTy = cast<PointerType>(Ty)->getElementType();
 | 
					    const Type *ElTy = cast<PointerType>(Ty)->getElementType();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Create the global variable...
 | 
					    // Create the global variable...
 | 
				
			||||||
    if (hasInitializer)
 | 
					    if (hasInitializer) {
 | 
				
			||||||
      handler->handleGlobalVariable( ElTy, isConstant, Linkage );
 | 
					 | 
				
			||||||
    else {
 | 
					 | 
				
			||||||
      unsigned initSlot = read_vbr_uint(Buf,End);
 | 
					      unsigned initSlot = read_vbr_uint(Buf,End);
 | 
				
			||||||
      handler->handleInitializedGV( ElTy, isConstant, Linkage, initSlot );
 | 
					      handler->handleInitializedGV( ElTy, isConstant, Linkage, initSlot );
 | 
				
			||||||
    }
 | 
					    } else 
 | 
				
			||||||
 | 
					      handler->handleGlobalVariable( ElTy, isConstant, Linkage );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Get next item
 | 
					    // Get next item
 | 
				
			||||||
    VarType = read_vbr_uint(Buf, End);
 | 
					    VarType = read_vbr_uint(Buf, End);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue