forked from OSchip/llvm-project
Update bitcode reader and writer to handle multiple return values.
Take 2. llvm-svn: 47583
This commit is contained in:
parent
b7e656b177
commit
bbfd874cb4
|
@ -1337,17 +1337,24 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
|
||||||
}
|
}
|
||||||
|
|
||||||
case bitc::FUNC_CODE_INST_RET: // RET: [opty,opval<optional>]
|
case bitc::FUNC_CODE_INST_RET: // RET: [opty,opval<optional>]
|
||||||
if (Record.empty()) {
|
{
|
||||||
I = new ReturnInst();
|
unsigned Size = Record.size();
|
||||||
break;
|
if (Size == 0) {
|
||||||
} else {
|
I = new ReturnInst();
|
||||||
unsigned OpNum = 0;
|
break;
|
||||||
Value *Op;
|
} else {
|
||||||
if (getValueTypePair(Record, OpNum, NextValueNo, Op) ||
|
unsigned OpNum = 0;
|
||||||
OpNum != Record.size())
|
std::vector<Value *> Vs;
|
||||||
return Error("Invalid RET record");
|
do {
|
||||||
I = new ReturnInst(Op);
|
Value *Op = NULL;
|
||||||
break;
|
if (getValueTypePair(Record, OpNum, NextValueNo, Op))
|
||||||
|
return Error("Invalid RET record");
|
||||||
|
Vs.push_back(Op);
|
||||||
|
} while(OpNum != Record.size());
|
||||||
|
|
||||||
|
I = new ReturnInst(Vs);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case bitc::FUNC_CODE_INST_BR: { // BR: [bb#, bb#, opval] or [bb#]
|
case bitc::FUNC_CODE_INST_BR: { // BR: [bb#, bb#, opval] or [bb#]
|
||||||
if (Record.size() != 1 && Record.size() != 3)
|
if (Record.size() != 1 && Record.size() != 3)
|
||||||
|
|
|
@ -747,15 +747,24 @@ static void WriteInstruction(const Instruction &I, unsigned InstID,
|
||||||
case Instruction::GetResult:
|
case Instruction::GetResult:
|
||||||
Code = bitc::FUNC_CODE_INST_GETRESULT;
|
Code = bitc::FUNC_CODE_INST_GETRESULT;
|
||||||
PushValueAndType(I.getOperand(0), InstID, Vals, VE);
|
PushValueAndType(I.getOperand(0), InstID, Vals, VE);
|
||||||
Vals.push_back(Log2_32(cast<GetResultInst>(I).getIndex())+1);
|
Vals.push_back(cast<GetResultInst>(I).getIndex());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Instruction::Ret:
|
case Instruction::Ret:
|
||||||
Code = bitc::FUNC_CODE_INST_RET;
|
{
|
||||||
if (!I.getNumOperands())
|
Code = bitc::FUNC_CODE_INST_RET;
|
||||||
AbbrevToUse = FUNCTION_INST_RET_VOID_ABBREV;
|
unsigned NumOperands = I.getNumOperands();
|
||||||
else if (!PushValueAndType(I.getOperand(0), InstID, Vals, VE))
|
// printf ("dpatel write %d\n", NumOperands);
|
||||||
AbbrevToUse = FUNCTION_INST_RET_VAL_ABBREV;
|
if (NumOperands == 0)
|
||||||
|
AbbrevToUse = FUNCTION_INST_RET_VOID_ABBREV;
|
||||||
|
else if (NumOperands == 1) {
|
||||||
|
if (!PushValueAndType(I.getOperand(0), InstID, Vals, VE))
|
||||||
|
AbbrevToUse = FUNCTION_INST_RET_VAL_ABBREV;
|
||||||
|
} else {
|
||||||
|
for (unsigned i = 0, e = NumOperands; i != e; ++i)
|
||||||
|
PushValueAndType(I.getOperand(i), InstID, Vals, VE);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Instruction::Br:
|
case Instruction::Br:
|
||||||
Code = bitc::FUNC_CODE_INST_BR;
|
Code = bitc::FUNC_CODE_INST_BR;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
; RUN: llvm-as < %s -disable-output
|
; RUN: llvm-as < %s | opt -verify | llvm-dis | llvm-as -disable-output
|
||||||
|
|
||||||
define {i32, i8} @foo(i32 %p) {
|
define {i32, i8} @foo(i32 %p) {
|
||||||
ret i32 1, i8 2
|
ret i32 1, i8 2
|
||||||
|
|
Loading…
Reference in New Issue