aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/Bytecode/Reader/InstructionReader.cpp79
-rw-r--r--lib/Bytecode/Reader/Reader.cpp31
-rw-r--r--lib/Bytecode/Reader/ReaderInternals.h5
3 files changed, 23 insertions, 92 deletions
diff --git a/lib/Bytecode/Reader/InstructionReader.cpp b/lib/Bytecode/Reader/InstructionReader.cpp
index 0ade581..90be8cd 100644
--- a/lib/Bytecode/Reader/InstructionReader.cpp
+++ b/lib/Bytecode/Reader/InstructionReader.cpp
@@ -124,34 +124,7 @@ void BytecodeParser::ParseInstruction(const unsigned char *&Buf,
Result = new VAArgInst(getValue(RI.Type, Args[0]), getType(Args[1]));
break;
case Instruction::VANext:
- if (!hasOldStyleVarargs) {
- Result = new VANextInst(getValue(RI.Type, Args[0]), getType(Args[1]));
- } else {
- // In the old-style varargs scheme, this was the "va_arg" instruction.
- // Emit emulation code now.
- if (!usesOldStyleVarargs) {
- usesOldStyleVarargs = true;
- std::cerr << "WARNING: this bytecode file uses obsolete features. "
- << "Disassemble and assemble to update it.\n";
- }
-
- Value *VAListPtr = getValue(RI.Type, Args[0]);
- const Type *ArgTy = getType(Args[1]);
-
- // First, load the valist...
- Instruction *CurVAList = new LoadInst(VAListPtr, "");
- BB->getInstList().push_back(CurVAList);
-
- // Construct the vaarg
- Result = new VAArgInst(CurVAList, ArgTy);
-
- // Now we must advance the pointer and update it in memory.
- Instruction *TheVANext = new VANextInst(CurVAList, ArgTy);
- BB->getInstList().push_back(TheVANext);
-
- BB->getInstList().push_back(new StoreInst(TheVANext, VAListPtr));
- }
-
+ Result = new VANextInst(getValue(RI.Type, Args[0]), getType(Args[1]));
break;
case Instruction::Cast:
Result = new CastInst(getValue(RI.Type, Args[0]), getType(Args[1]));
@@ -234,21 +207,17 @@ void BytecodeParser::ParseInstruction(const unsigned char *&Buf,
if (It != FTy->param_end())
throw std::string("Invalid call instruction!");
} else {
- Args.erase(Args.begin(), Args.begin()+1+hasVarArgCallPadding);
+ Args.erase(Args.begin(), Args.begin()+1);
unsigned FirstVariableOperand;
- if (!hasVarArgCallPadding) {
- if (Args.size() < FTy->getNumParams())
- throw std::string("Call instruction missing operands!");
+ if (Args.size() < FTy->getNumParams())
+ throw std::string("Call instruction missing operands!");
- // Read all of the fixed arguments
- for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)
- Params.push_back(getValue(getTypeSlot(FTy->getParamType(i)),Args[i]));
-
- FirstVariableOperand = FTy->getNumParams();
- } else {
- FirstVariableOperand = 0;
- }
+ // Read all of the fixed arguments
+ for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)
+ Params.push_back(getValue(getTypeSlot(FTy->getParamType(i)),Args[i]));
+
+ FirstVariableOperand = FTy->getNumParams();
if ((Args.size()-FirstVariableOperand) & 1) // Must be pairs of type/value
throw std::string("Invalid call instruction!");
@@ -286,28 +255,16 @@ void BytecodeParser::ParseInstruction(const unsigned char *&Buf,
if (It != FTy->param_end())
throw std::string("Invalid invoke instruction!");
} else {
- Args.erase(Args.begin(), Args.begin()+1+hasVarArgCallPadding);
-
- unsigned FirstVariableArgument;
- if (!hasVarArgCallPadding) {
- Normal = getBasicBlock(Args[0]);
- Except = getBasicBlock(Args[1]);
-
- FirstVariableArgument = FTy->getNumParams()+2;
- for (unsigned i = 2; i != FirstVariableArgument; ++i)
- Params.push_back(getValue(getTypeSlot(FTy->getParamType(i-2)),
- Args[i]));
-
- } else {
- if (Args.size() < 4) throw std::string("Invalid invoke instruction!");
- if (Args[0] != Type::LabelTyID || Args[2] != Type::LabelTyID)
- throw std::string("Invalid invoke instruction!");
- Normal = getBasicBlock(Args[1]);
- Except = getBasicBlock(Args[3]);
-
- FirstVariableArgument = 4;
- }
+ Args.erase(Args.begin(), Args.begin()+1);
+ Normal = getBasicBlock(Args[0]);
+ Except = getBasicBlock(Args[1]);
+
+ unsigned FirstVariableArgument = FTy->getNumParams()+2;
+ for (unsigned i = 2; i != FirstVariableArgument; ++i)
+ Params.push_back(getValue(getTypeSlot(FTy->getParamType(i-2)),
+ Args[i]));
+
if (Args.size()-FirstVariableArgument & 1) // Must be pairs of type/value
throw std::string("Invalid invoke instruction!");
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp
index 63d8b42..54c9181 100644
--- a/lib/Bytecode/Reader/Reader.cpp
+++ b/lib/Bytecode/Reader/Reader.cpp
@@ -353,8 +353,7 @@ void BytecodeParser::materializeFunction(Function* F) {
GlobalValue::LinkageTypes Linkage = GlobalValue::ExternalLinkage;
unsigned LinkageType = read_vbr_uint(Buf, EndBuf);
- if ((!hasExtendedLinkageSpecs && LinkageType > 3) ||
- ( hasExtendedLinkageSpecs && LinkageType > 4))
+ if (LinkageType > 4)
throw std::string("Invalid linkage type for Function.");
switch (LinkageType) {
case 0: Linkage = GlobalValue::ExternalLinkage; break;
@@ -553,21 +552,12 @@ void BytecodeParser::ParseModuleGlobalInfo(const unsigned char *&Buf,
// Read global variables...
unsigned VarType = read_vbr_uint(Buf, End);
while (VarType != Type::VoidTyID) { // List is terminated by Void
- unsigned SlotNo;
+ // VarType Fields: bit0 = isConstant, bit1 = hasInitializer, bit2,3,4 =
+ // Linkage, bit4+ = slot#
+ unsigned SlotNo = VarType >> 5;
+ unsigned LinkageID = (VarType >> 2) & 7;
GlobalValue::LinkageTypes Linkage;
- unsigned LinkageID;
- if (hasExtendedLinkageSpecs) {
- // VarType Fields: bit0 = isConstant, bit1 = hasInitializer,
- // bit2,3,4 = Linkage, bit4+ = slot#
- SlotNo = VarType >> 5;
- LinkageID = (VarType >> 2) & 7;
- } else {
- // VarType Fields: bit0 = isConstant, bit1 = hasInitializer,
- // bit2,3 = Linkage, bit4+ = slot#
- SlotNo = VarType >> 4;
- LinkageID = (VarType >> 2) & 3;
- }
switch (LinkageID) {
default: assert(0 && "Unknown linkage type!");
case 0: Linkage = GlobalValue::ExternalLinkage; break;
@@ -655,20 +645,10 @@ void BytecodeParser::ParseVersionInfo(const unsigned char *&Buf,
RevisionNum = Version >> 4;
// Default values for the current bytecode version
- hasExtendedLinkageSpecs = true;
- hasOldStyleVarargs = false;
- hasVarArgCallPadding = false;
hasInconsistentModuleGlobalInfo = false;
hasExplicitPrimitiveZeros = false;
switch (RevisionNum) {
- case 2: // LLVM pre-1.0 release: will be deleted on the next rev
- // Version #2 only supported 4 linkage types. It didn't support weak
- // linkage.
- hasExtendedLinkageSpecs = false;
- hasOldStyleVarargs = true;
- hasVarArgCallPadding = true;
- // FALL THROUGH
case 0: // LLVM 1.0, 1.1 release version
// Compared to rev #2, we added support for weak linkage, a more dense
// encoding, and better varargs support.
@@ -789,7 +769,6 @@ void BytecodeParser::ParseBytecode(const unsigned char *Buf, unsigned Length,
TheModule = new Module(ModuleID);
try {
- usesOldStyleVarargs = false;
ParseModule(Buf, EndBuf);
} catch (std::string &Error) {
freeState(); // Must destroy handles before deleting module!
diff --git a/lib/Bytecode/Reader/ReaderInternals.h b/lib/Bytecode/Reader/ReaderInternals.h
index ff28e25..86bf800 100644
--- a/lib/Bytecode/Reader/ReaderInternals.h
+++ b/lib/Bytecode/Reader/ReaderInternals.h
@@ -97,11 +97,6 @@ private:
// Information about the module, extracted from the bytecode revision number.
unsigned char RevisionNum; // The rev # itself
- bool hasExtendedLinkageSpecs; // Supports more than 4 linkage types
- bool hasOldStyleVarargs; // Has old version of varargs intrinsics?
- bool hasVarArgCallPadding; // Bytecode has extra padding in vararg call
-
- bool usesOldStyleVarargs; // Does this module USE old style varargs?
// Flags to distinguish LLVM 1.0 & 1.1 bytecode formats (revision #0)