Remove a gross hack that was there to support bytecode files that are over a year old.
If you still have these suckers laying around, you have GOT to rebuild them. geeze. llvm-svn: 8395
This commit is contained in:
parent
8e8593a2c4
commit
53bd0b24f2
|
|
@ -116,8 +116,7 @@ bool BytecodeParser::ParseRawInst(const unsigned char *&Buf,
|
||||||
|
|
||||||
bool BytecodeParser::ParseInstruction(const unsigned char *&Buf,
|
bool BytecodeParser::ParseInstruction(const unsigned char *&Buf,
|
||||||
const unsigned char *EndBuf,
|
const unsigned char *EndBuf,
|
||||||
Instruction *&Res,
|
Instruction *&Res) {
|
||||||
BasicBlock *BB /*HACK*/) {
|
|
||||||
RawInst Raw;
|
RawInst Raw;
|
||||||
if (ParseRawInst(Buf, EndBuf, Raw))
|
if (ParseRawInst(Buf, EndBuf, Raw))
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -359,14 +358,13 @@ bool BytecodeParser::ParseInstruction(const unsigned char *&Buf,
|
||||||
Res = new FreeInst(V);
|
Res = new FreeInst(V);
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case Instruction::Load:
|
|
||||||
case Instruction::GetElementPtr: {
|
case Instruction::GetElementPtr: {
|
||||||
std::vector<Value*> Idx;
|
std::vector<Value*> Idx;
|
||||||
if (!isa<PointerType>(Raw.Ty)) return true;
|
if (!isa<PointerType>(Raw.Ty)) return true;
|
||||||
const CompositeType *TopTy = dyn_cast<CompositeType>(Raw.Ty);
|
const CompositeType *TopTy = dyn_cast<CompositeType>(Raw.Ty);
|
||||||
|
|
||||||
switch (Raw.NumOperands) {
|
switch (Raw.NumOperands) {
|
||||||
case 0: std::cerr << "Invalid load encountered!\n"; return true;
|
case 0: std::cerr << "Invalid getelementptr encountered!\n"; return true;
|
||||||
case 1: break;
|
case 1: break;
|
||||||
case 2:
|
case 2:
|
||||||
if (!TopTy) return true;
|
if (!TopTy) return true;
|
||||||
|
|
@ -403,71 +401,20 @@ bool BytecodeParser::ParseInstruction(const unsigned char *&Buf,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Raw.Opcode == Instruction::Load) {
|
Res = new GetElementPtrInst(getValue(Raw.Ty, Raw.Arg1), Idx);
|
||||||
Value *Src = getValue(Raw.Ty, Raw.Arg1);
|
|
||||||
if (!Idx.empty()) {
|
|
||||||
std::cerr << "WARNING: Bytecode contains load instruction with indices."
|
|
||||||
<< " Replacing with getelementptr/load pair\n";
|
|
||||||
assert(GetElementPtrInst::getIndexedType(Raw.Ty, Idx) &&
|
|
||||||
"Bad indices for Load!");
|
|
||||||
Src = new GetElementPtrInst(Src, Idx);
|
|
||||||
// FIXME: Remove this compatibility code and the BB parameter to this
|
|
||||||
// method.
|
|
||||||
BB->getInstList().push_back(cast<Instruction>(Src));
|
|
||||||
}
|
|
||||||
Res = new LoadInst(Src);
|
|
||||||
} else if (Raw.Opcode == Instruction::GetElementPtr)
|
|
||||||
Res = new GetElementPtrInst(getValue(Raw.Ty, Raw.Arg1), Idx);
|
|
||||||
else
|
|
||||||
abort();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case Instruction::Store: {
|
|
||||||
std::vector<Value*> Idx;
|
case Instruction::Load:
|
||||||
|
if (Raw.NumOperands != 1) return true;
|
||||||
if (!isa<PointerType>(Raw.Ty)) return true;
|
if (!isa<PointerType>(Raw.Ty)) return true;
|
||||||
const CompositeType *TopTy = dyn_cast<CompositeType>(Raw.Ty);
|
Res = new LoadInst(getValue(Raw.Ty, Raw.Arg1));
|
||||||
|
return false;
|
||||||
|
|
||||||
switch (Raw.NumOperands) {
|
case Instruction::Store: {
|
||||||
case 0:
|
if (!isa<PointerType>(Raw.Ty) || Raw.NumOperands != 2) return true;
|
||||||
case 1: std::cerr << "Invalid store encountered!\n"; return true;
|
|
||||||
case 2: break;
|
|
||||||
case 3:
|
|
||||||
if (!TopTy) return true;
|
|
||||||
Idx.push_back(V = getValue(TopTy->getIndexType(), Raw.Arg3));
|
|
||||||
if (!V) return true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
std::vector<unsigned> &args = *Raw.VarArgs;
|
|
||||||
const CompositeType *ElTy = TopTy;
|
|
||||||
unsigned i, E;
|
|
||||||
for (i = 0, E = args.size(); ElTy && i != E; ++i) {
|
|
||||||
Idx.push_back(V = getValue(ElTy->getIndexType(), args[i]));
|
|
||||||
if (!V) return true;
|
|
||||||
|
|
||||||
const Type *ETy = GetElementPtrInst::getIndexedType(Raw.Ty, Idx, true);
|
|
||||||
ElTy = dyn_cast_or_null<CompositeType>(ETy);
|
|
||||||
}
|
|
||||||
if (i != E)
|
|
||||||
return true; // didn't use up all of the indices!
|
|
||||||
|
|
||||||
delete Raw.VarArgs;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Value *Ptr = getValue(Raw.Ty, Raw.Arg2);
|
Value *Ptr = getValue(Raw.Ty, Raw.Arg2);
|
||||||
if (!Idx.empty()) {
|
|
||||||
std::cerr << "WARNING: Bytecode contains load instruction with indices. "
|
|
||||||
<< "Replacing with getelementptr/load pair\n";
|
|
||||||
|
|
||||||
const Type *ElType = GetElementPtrInst::getIndexedType(Raw.Ty, Idx);
|
|
||||||
if (ElType == 0) return true;
|
|
||||||
|
|
||||||
Ptr = new GetElementPtrInst(Ptr, Idx);
|
|
||||||
// FIXME: Remove this compatibility code and the BB parameter to this
|
|
||||||
// method.
|
|
||||||
BB->getInstList().push_back(cast<Instruction>(Ptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
const Type *ValTy = cast<PointerType>(Ptr->getType())->getElementType();
|
const Type *ValTy = cast<PointerType>(Ptr->getType())->getElementType();
|
||||||
Res = new StoreInst(getValue(ValTy, Raw.Arg1), Ptr);
|
Res = new StoreInst(getValue(ValTy, Raw.Arg1), Ptr);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -222,7 +222,7 @@ bool BytecodeParser::ParseBasicBlock(const unsigned char *&Buf,
|
||||||
|
|
||||||
while (Buf < EndBuf) {
|
while (Buf < EndBuf) {
|
||||||
Instruction *Inst;
|
Instruction *Inst;
|
||||||
if (ParseInstruction(Buf, EndBuf, Inst, /*HACK*/BB)) {
|
if (ParseInstruction(Buf, EndBuf, Inst)) {
|
||||||
delete BB;
|
delete BB;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ private:
|
||||||
bool ParseBasicBlock (const unsigned char *&Buf, const unsigned char *End,
|
bool ParseBasicBlock (const unsigned char *&Buf, const unsigned char *End,
|
||||||
BasicBlock *&);
|
BasicBlock *&);
|
||||||
bool ParseInstruction (const unsigned char *&Buf, const unsigned char *End,
|
bool ParseInstruction (const unsigned char *&Buf, const unsigned char *End,
|
||||||
Instruction *&, BasicBlock *BB /*HACK*/);
|
Instruction *&);
|
||||||
bool ParseRawInst (const unsigned char *&Buf, const unsigned char *End,
|
bool ParseRawInst (const unsigned char *&Buf, const unsigned char *End,
|
||||||
RawInst &);
|
RawInst &);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue