[llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp
Chris Lattner
lattner at cs.uiuc.edu
Thu Jan 15 12:46:11 PST 2004
Changes in directory llvm/lib/Bytecode/Reader:
Reader.cpp updated: 1.96 -> 1.97
---
Log message:
Allow bytecode files to refer directly to global values as constants, instead
of forcing them to go through ConstantPointerRef's. This allows bytecode
files to mirror .ll files, allows more efficient encoding, and makes it easier
to eventually eliminate CPR's.
---
Diffs of the changes: (+6 -2)
Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.96 llvm/lib/Bytecode/Reader/Reader.cpp:1.97
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.96 Thu Jan 15 11:55:01 2004
+++ llvm/lib/Bytecode/Reader/Reader.cpp Thu Jan 15 12:45:25 2004
@@ -151,6 +151,10 @@
if (Value *V = getValue(TypeSlot, Slot, false))
if (Constant *C = dyn_cast<Constant>(V))
return C; // If we already have the value parsed, just return it
+ else if (GlobalValue *GV = dyn_cast<GlobalValue>(V))
+ // ConstantPointerRef's are an abomination, but at least they don't have
+ // to infest bytecode files.
+ return ConstantPointerRef::get(GV);
else
throw std::string("Reference of a value is expected to be a constant!");
@@ -637,10 +641,10 @@
// Look up the initializer value...
// FIXME: Preserve this type ID!
unsigned TypeSlot = getTypeSlot(GV->getType()->getElementType());
- if (Value *V = getValue(TypeSlot, Slot, false)) {
+ if (Constant *CV = getConstantValue(TypeSlot, Slot)) {
if (GV->hasInitializer())
throw std::string("Global *already* has an initializer?!");
- GV->setInitializer(cast<Constant>(V));
+ GV->setInitializer(CV);
} else
throw std::string("Cannot find initializer value.");
}
More information about the llvm-commits
mailing list