add bytecode reader support for tail calls

llvm-svn: 21727
diff --git a/llvm/lib/Bytecode/Reader/Reader.cpp b/llvm/lib/Bytecode/Reader/Reader.cpp
index 82a73fa..24875e4 100644
--- a/llvm/lib/Bytecode/Reader/Reader.cpp
+++ b/llvm/lib/Bytecode/Reader/Reader.cpp
@@ -720,6 +720,7 @@
     break;
   }
 
+  case 61:  // tail call
   case Instruction::Call: {
     if (Oprnds.size() == 0)
       error("Invalid call instruction encountered!");
@@ -765,6 +766,7 @@
     }
 
     Result = new CallInst(F, Params);
+    if (Opcode == 61) cast<CallInst>(Result)->setTailCall(true);
     break;
   }
   case Instruction::Invoke: {
diff --git a/llvm/lib/Bytecode/Writer/Writer.cpp b/llvm/lib/Bytecode/Writer/Writer.cpp
index f6d09c8..5f614fd 100644
--- a/llvm/lib/Bytecode/Writer/Writer.cpp
+++ b/llvm/lib/Bytecode/Writer/Writer.cpp
@@ -606,7 +606,10 @@
   unsigned Opcode = I.getOpcode();
   unsigned NumOperands = I.getNumOperands();
 
-  // Encode 'volatile load' as 62 and 'volatile store' as 63.
+  // Encode 'tail call' as 61, 'volatile load' as 62, and 'volatile store' as
+  // 63.
+  if (isa<CallInst>(I) && cast<CallInst>(I).isTailCall())
+    Opcode = 61;
   if (isa<LoadInst>(I) && cast<LoadInst>(I).isVolatile())
     Opcode = 62;
   if (isa<StoreInst>(I) && cast<StoreInst>(I).isVolatile())