summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bytecode/Reader/ConstantReader.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-10-14 03:33:02 +0000
committerChris Lattner <sabre@nondot.org>2002-10-14 03:33:02 +0000
commit2862d2ec711cb77a954f313f11e280280691c895 (patch)
tree6932a5cbe8738c79ab55e80108515b4718aa0758 /llvm/lib/Bytecode/Reader/ConstantReader.cpp
parent163b890dfb7811e2ff473d548570823c63d4d598 (diff)
downloadbcm5719-llvm-2862d2ec711cb77a954f313f11e280280691c895.tar.gz
bcm5719-llvm-2862d2ec711cb77a954f313f11e280280691c895.zip
There is no way to guarantee that constants are not forward referenced.
Handle forward referenced constants in a general way. This fixes bug: Assembler/2002-10-13-ConstantEncodingProblem.llx and allows the SPEC 197.parser benchmark to be built llvm-svn: 4161
Diffstat (limited to 'llvm/lib/Bytecode/Reader/ConstantReader.cpp')
-rw-r--r--llvm/lib/Bytecode/Reader/ConstantReader.cpp37
1 files changed, 8 insertions, 29 deletions
diff --git a/llvm/lib/Bytecode/Reader/ConstantReader.cpp b/llvm/lib/Bytecode/Reader/ConstantReader.cpp
index 3fb2530c119..e71441edd8a 100644
--- a/llvm/lib/Bytecode/Reader/ConstantReader.cpp
+++ b/llvm/lib/Bytecode/Reader/ConstantReader.cpp
@@ -202,28 +202,8 @@ bool BytecodeParser::parseConstantValue(const uchar *&Buf, const uchar *EndBuf,
<< ArgValSlot << "\n");
// Get the arg value from its slot if it exists, otherwise a placeholder
- Value *Val = getValue(ArgTy, ArgValSlot, false);
- Constant *C;
- if (Val) {
- if (!(C = dyn_cast<Constant>(Val))) return true;
- BCR_TRACE(5, "Constant Found in ValueTable!\n");
- } else { // Nope... find or create a forward ref. for it
- GlobalRefsType::iterator I =
- GlobalRefs.find(make_pair(ArgTy, ArgValSlot));
-
- if (I != GlobalRefs.end()) {
- BCR_TRACE(5, "Previous forward ref found!\n");
- C = cast<Constant>(I->second);
- } else {
- // Create a placeholder for the constant reference and
- // keep track of the fact that we have a forward ref to recycle it
- BCR_TRACE(5, "Creating new forward ref to a constant!\n");
- C = new ConstPHolder(ArgTy, ArgValSlot);
-
- // Keep track of the fact that we have a forward ref to recycle it
- GlobalRefs.insert(make_pair(make_pair(ArgTy, ArgValSlot), C));
- }
- }
+ Constant *C = getConstantValue(ArgTy, ArgValSlot);
+ if (C == 0) return true;
ArgVec.push_back(C);
}
@@ -310,9 +290,9 @@ bool BytecodeParser::parseConstantValue(const uchar *&Buf, const uchar *EndBuf,
while (NumElements--) { // Read all of the elements of the constant.
unsigned Slot;
if (read_vbr(Buf, EndBuf, Slot)) return true;
- Value *V = getValue(AT->getElementType(), Slot, false);
- if (!V || !isa<Constant>(V)) return true;
- Elements.push_back(cast<Constant>(V));
+ Constant *C = getConstantValue(AT->getElementType(), Slot);
+ if (!C) return true;
+ Elements.push_back(C);
}
V = ConstantArray::get(AT, Elements);
break;
@@ -326,10 +306,9 @@ bool BytecodeParser::parseConstantValue(const uchar *&Buf, const uchar *EndBuf,
for (unsigned i = 0; i < ET.size(); ++i) {
unsigned Slot;
if (read_vbr(Buf, EndBuf, Slot)) return true;
- Value *V = getValue(ET[i], Slot, false);
- if (!V || !isa<Constant>(V))
- return true;
- Elements.push_back(cast<Constant>(V));
+ Constant *C = getConstantValue(ET[i], Slot);
+ if (!C) return true;
+ Elements.push_back(C);
}
V = ConstantStruct::get(ST, Elements);
OpenPOWER on IntegriCloud