aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2008-02-23 01:44:55 +0000
committerDevang Patel <dpatel@apple.com>2008-02-23 01:44:55 +0000
commit6a49782d33384b76ab412a4bea93551dca25b566 (patch)
treebd2f17746acacc9bbcdd3535666d9132fcf61a9b /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
parente70afb021b23e968c2944bab2dd87b0185a601b4 (diff)
downloadllvm-6a49782d33384b76ab412a4bea93551dca25b566.zip
llvm-6a49782d33384b76ab412a4bea93551dca25b566.tar.gz
llvm-6a49782d33384b76ab412a4bea93551dca25b566.tar.bz2
Properly read and write bitcodes for multiple return values.
llvm-svn: 47521
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 9b2b93cf..5de38b8 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -747,15 +747,23 @@ static void WriteInstruction(const Instruction &I, unsigned InstID,
case Instruction::GetResult:
Code = bitc::FUNC_CODE_INST_GETRESULT;
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;
- case Instruction::Ret:
- Code = bitc::FUNC_CODE_INST_RET;
- if (!I.getNumOperands())
- AbbrevToUse = FUNCTION_INST_RET_VOID_ABBREV;
- else if (!PushValueAndType(I.getOperand(0), InstID, Vals, VE))
- AbbrevToUse = FUNCTION_INST_RET_VAL_ABBREV;
+ case Instruction::Ret:
+ {
+ Code = bitc::FUNC_CODE_INST_RET;
+ unsigned NumOperands = I.getNumOperands();
+ 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;
case Instruction::Br:
Code = bitc::FUNC_CODE_INST_BR;