aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Bytecode/Reader
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-10-13 14:34:59 +0000
committerChris Lattner <sabre@nondot.org>2003-10-13 14:34:59 +0000
commitf0d9273af7079c3057d62689babf8e61cbbc3eaa (patch)
treea7b825ef74ef915b081b0d9173abf959be3f9c0d /lib/Bytecode/Reader
parent1825009ba8133992c103102556d32a25aa524d0c (diff)
downloadexternal_llvm-f0d9273af7079c3057d62689babf8e61cbbc3eaa.zip
external_llvm-f0d9273af7079c3057d62689babf8e61cbbc3eaa.tar.gz
external_llvm-f0d9273af7079c3057d62689babf8e61cbbc3eaa.tar.bz2
Avoid calling getTypeSlot more
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9077 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode/Reader')
-rw-r--r--lib/Bytecode/Reader/ConstantReader.cpp2
-rw-r--r--lib/Bytecode/Reader/Reader.cpp10
-rw-r--r--lib/Bytecode/Reader/ReaderInternals.h1
3 files changed, 9 insertions, 4 deletions
diff --git a/lib/Bytecode/Reader/ConstantReader.cpp b/lib/Bytecode/Reader/ConstantReader.cpp
index 2689362..71afaf6 100644
--- a/lib/Bytecode/Reader/ConstantReader.cpp
+++ b/lib/Bytecode/Reader/ConstantReader.cpp
@@ -350,7 +350,7 @@ void BytecodeParser::ParseConstantPool(const unsigned char *&Buf,
Constant *C = parseConstantValue(Buf, EndBuf, Ty);
assert(C && "parseConstantValue returned NULL!");
BCR_TRACE(4, "Read Constant: '" << *C << "'\n");
- unsigned Slot = insertValue(C, Tab);
+ unsigned Slot = insertValue(C, Typ, Tab);
// If we are reading a function constant table, make sure that we adjust
// the slot number to be the real global constant number.
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp
index e735564..8713855 100644
--- a/lib/Bytecode/Reader/Reader.cpp
+++ b/lib/Bytecode/Reader/Reader.cpp
@@ -75,11 +75,15 @@ const Type *BytecodeParser::getType(unsigned ID) {
}
unsigned BytecodeParser::insertValue(Value *Val, ValueTable &ValueTab) {
+ return insertValue(Val, getTypeSlot(Val->getType()), ValueTab);
+}
+
+unsigned BytecodeParser::insertValue(Value *Val, unsigned type,
+ ValueTable &ValueTab) {
assert((!HasImplicitZeroInitializer || !isa<Constant>(Val) ||
Val->getType()->isPrimitiveType() ||
!cast<Constant>(Val)->isNullValue()) &&
"Cannot read null values from bytecode!");
- unsigned type = getTypeSlot(Val->getType());
assert(type != Type::TypeTyID && "Types should never be insertValue'd!");
if (ValueTab.size() <= type) {
@@ -452,7 +456,7 @@ void BytecodeParser::ParseModuleGlobalInfo(const unsigned char *&Buf,
GlobalVariable *GV = new GlobalVariable(ElTy, VarType & 1, Linkage,
0, "", TheModule);
BCR_TRACE(2, "Global Variable of type: " << *Ty << "\n");
- ResolveReferencesToValue(GV, insertValue(GV, ModuleValues));
+ ResolveReferencesToValue(GV, insertValue(GV, SlotNo, ModuleValues));
if (VarType & 2) { // Does it have an initializer?
unsigned InitSlot;
@@ -483,7 +487,7 @@ void BytecodeParser::ParseModuleGlobalInfo(const unsigned char *&Buf,
// Insert the placeholder...
Function *Func = new Function(cast<FunctionType>(Ty),
GlobalValue::InternalLinkage, "", TheModule);
- unsigned DestSlot = insertValue(Func, ModuleValues);
+ unsigned DestSlot = insertValue(Func, FnSignature, ModuleValues);
ResolveReferencesToValue(Func, DestSlot);
// Keep track of this information in a list that is emptied as functions are
diff --git a/lib/Bytecode/Reader/ReaderInternals.h b/lib/Bytecode/Reader/ReaderInternals.h
index 61e6fa9..7f921d7 100644
--- a/lib/Bytecode/Reader/ReaderInternals.h
+++ b/lib/Bytecode/Reader/ReaderInternals.h
@@ -170,6 +170,7 @@ private:
Constant *getConstantValue(const Type *Ty, unsigned num);
unsigned insertValue(Value *V, ValueTable &Table);
+ unsigned insertValue(Value *V, unsigned Type, ValueTable &Table);
unsigned getTypeSlot(const Type *Ty);