aboutsummaryrefslogtreecommitdiff
path: root/lib/Bytecode
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-06-08 05:54:47 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-06-08 05:54:47 +0000
commit5e8868d2a33a9c057d89e301c508c38d5120edaf (patch)
tree5c0477f7fc0d0bb7bf67eb9062eed037b0a3de04 /lib/Bytecode
parentb7041b0c432a54c9ff8ef99cd4a7ca3412b278df (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14057 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode')
-rw-r--r--lib/Bytecode/Analyzer/Parser.cpp10
-rw-r--r--lib/Bytecode/Reader/Parser.cpp10
2 files changed, 10 insertions, 10 deletions
diff --git a/lib/Bytecode/Analyzer/Parser.cpp b/lib/Bytecode/Analyzer/Parser.cpp
index d236b64aae..45f761ea67 100644
--- a/lib/Bytecode/Analyzer/Parser.cpp
+++ b/lib/Bytecode/Analyzer/Parser.cpp
@@ -156,7 +156,8 @@ void AbstractBytecodeParser::ParseBasicBlock(BufPtr &Buf,
/// 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
/// 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;
std::vector<unsigned> Args;
@@ -698,12 +699,11 @@ void AbstractBytecodeParser::ParseModuleGlobalInfo(BufPtr &Buf, BufPtr End) {
const Type *ElTy = cast<PointerType>(Ty)->getElementType();
// Create the global variable...
- if (hasInitializer)
- handler->handleGlobalVariable( ElTy, isConstant, Linkage );
- else {
+ if (hasInitializer) {
unsigned initSlot = read_vbr_uint(Buf,End);
handler->handleInitializedGV( ElTy, isConstant, Linkage, initSlot );
- }
+ } else
+ handler->handleGlobalVariable( ElTy, isConstant, Linkage );
// Get next item
VarType = read_vbr_uint(Buf, End);
diff --git a/lib/Bytecode/Reader/Parser.cpp b/lib/Bytecode/Reader/Parser.cpp
index d236b64aae..45f761ea67 100644
--- a/lib/Bytecode/Reader/Parser.cpp
+++ b/lib/Bytecode/Reader/Parser.cpp
@@ -156,7 +156,8 @@ void AbstractBytecodeParser::ParseBasicBlock(BufPtr &Buf,
/// 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
/// 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;
std::vector<unsigned> Args;
@@ -698,12 +699,11 @@ void AbstractBytecodeParser::ParseModuleGlobalInfo(BufPtr &Buf, BufPtr End) {
const Type *ElTy = cast<PointerType>(Ty)->getElementType();
// Create the global variable...
- if (hasInitializer)
- handler->handleGlobalVariable( ElTy, isConstant, Linkage );
- else {
+ if (hasInitializer) {
unsigned initSlot = read_vbr_uint(Buf,End);
handler->handleInitializedGV( ElTy, isConstant, Linkage, initSlot );
- }
+ } else
+ handler->handleGlobalVariable( ElTy, isConstant, Linkage );
// Get next item
VarType = read_vbr_uint(Buf, End);