From e73bd45c1dbc0f256cdf4450192a0e74af51e881 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 6 Nov 2005 07:43:39 +0000 Subject: encode/decode function alignment in bc files git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24218 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bytecode/Reader/Reader.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'lib/Bytecode/Reader/Reader.cpp') diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index 26bd68c344..372a5b5aa0 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -1928,13 +1928,11 @@ void BytecodeReader::ParseModuleGlobalInfo() { } const Type *Ty = getType(SlotNo); - if (!Ty) { + if (!Ty) error("Global has no type! SlotNo=" + utostr(SlotNo)); - } - if (!isa(Ty)) { + if (!isa(Ty)) error("Global not a pointer type! Ty= " + Ty->getDescription()); - } const Type *ElTy = cast(Ty)->getElementType(); @@ -1965,8 +1963,8 @@ void BytecodeReader::ParseModuleGlobalInfo() { FnSignature = (FnSignature << 5) + 1; // List is terminated by VoidTy. - while ((FnSignature >> 5) != Type::VoidTyID) { - const Type *Ty = getType(FnSignature >> 5); + while (((FnSignature & (~0U >> 1)) >> 5) != Type::VoidTyID) { + const Type *Ty = getType((FnSignature & (~0U >> 1)) >> 5); if (!isa(Ty) || !isa(cast(Ty)->getElementType())) { error("Function not a pointer to function type! Ty = " + @@ -1981,7 +1979,7 @@ void BytecodeReader::ParseModuleGlobalInfo() { // Insert the place holder. Function* Func = new Function(FTy, GlobalValue::ExternalLinkage, "", TheModule); - insertValue(Func, FnSignature >> 5, ModuleValues); + insertValue(Func, (FnSignature & (~0U >> 1)) >> 5, ModuleValues); // Flags are not used yet. unsigned Flags = FnSignature & 31; @@ -1992,13 +1990,17 @@ void BytecodeReader::ParseModuleGlobalInfo() { if ((Flags & (1 << 4)) == 0) FunctionSignatureList.push_back(Func); - // Look at the low bits. If there is a calling conv here, apply it, - // read it as a vbr. - Flags &= 15; - if (Flags) - Func->setCallingConv(Flags-1); - else - Func->setCallingConv(read_vbr_uint()); + // Get the calling convention from the low bits. + unsigned CC = Flags & 15; + unsigned Alignment = 0; + if (FnSignature & (1 << 31)) { // Has extension word? + unsigned ExtWord = read_vbr_uint(); + Alignment = (1 << (ExtWord & 31)) >> 1; + CC |= ((ExtWord >> 5) & 15) << 4; + } + + Func->setCallingConv(CC); + Func->setAlignment(Alignment); if (Handler) Handler->handleFunctionDeclaration(Func); -- cgit v1.2.3