don't misencode CC#'s
authorChris Lattner <sabre@nondot.org>
Sun, 6 Nov 2005 07:46:13 +0000 (07:46 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 6 Nov 2005 07:46:13 +0000 (07:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24219 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Bytecode/Reader/Reader.cpp
lib/Bytecode/Writer/Writer.cpp

index 372a5b5aa0814a2d02ecf4c578a8498bace2ae2f..f52cfa616787c7a440cf73e1a8c1bf0c50e27d1b 100644 (file)
@@ -1999,7 +1999,7 @@ void BytecodeReader::ParseModuleGlobalInfo() {
       CC |= ((ExtWord >> 5) & 15) << 4;
     }
     
-    Func->setCallingConv(CC);
+    Func->setCallingConv(CC-1);
     Func->setAlignment(Alignment);
 
     if (Handler) Handler->handleFunctionDeclaration(Func);
index 071a41efcfe4ee92598f0ff4e53a5f1b0790fb7a..9ba475c9d3e14e33f35ed03925b3cb97a40f0f50 100644 (file)
@@ -968,12 +968,13 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) {
     assert(Slot != -1 && "Module slot calculator is broken!");
     assert(Slot >= Type::FirstDerivedTyID && "Derived type not in range!");
     assert(((Slot << 6) >> 6) == Slot && "Slot # too big!");
-    unsigned ID = (Slot << 5) | (I->getCallingConv() & 15);
+    unsigned CC = I->getCallingConv()+1;
+    unsigned ID = (Slot << 5) | (CC & 15);
 
     if (I->isExternal())   // If external, we don't have an FunctionInfo block.
       ID |= 1 << 4;
     
-    if (I->getAlignment() || I->getCallingConv() & ~15)
+    if (I->getAlignment() || (CC & ~15) != 0)
       ID |= 1 << 31;       // Do we need an extension word?
     
     output_vbr(ID);
@@ -981,7 +982,7 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) {
     if (ID & (1 << 31)) {
       // Extension byte: bits 0-4 = alignment, bits 5-9 = top nibble of calling
       // convention.
-      ID = (Log2_32(I->getAlignment())+1) | ((I->getCallingConv() >> 4) << 5);
+      ID = (Log2_32(I->getAlignment())+1) | ((CC >> 4) << 5);
       output_vbr(ID);
     }
   }