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.
}
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) {
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;
// 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