aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/Bytecode/Reader/Reader.cpp2
-rw-r--r--lib/Bytecode/Writer/Writer.cpp7
2 files changed, 5 insertions, 4 deletions
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp
index 372a5b5..f52cfa6 100644
--- a/lib/Bytecode/Reader/Reader.cpp
+++ b/lib/Bytecode/Reader/Reader.cpp
@@ -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);
diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp
index 071a41e..9ba475c 100644
--- a/lib/Bytecode/Writer/Writer.cpp
+++ b/lib/Bytecode/Writer/Writer.cpp
@@ -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);
}
}