encode/decode function alignment in bc files

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24218 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2005-11-06 07:43:39 +00:00
parent afedcb36aa
commit e73bd45c1d
2 changed files with 30 additions and 24 deletions
+16 -14
View File
@@ -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<PointerType>(Ty)) {
if (!isa<PointerType>(Ty))
error("Global not a pointer type! Ty= " + Ty->getDescription());
}
const Type *ElTy = cast<PointerType>(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<PointerType>(Ty) ||
!isa<FunctionType>(cast<PointerType>(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);