[opaque pointer type] encode the pointee type of global variables

Use a few extra bits in the const field (after widening it from a fixed
single bit) to stash the address space which is no longer provided by
the type (and an extra bit in there to specify that we're using that new
encoding).

llvm-svn: 235911
This commit is contained in:
David Blaikie
2015-04-27 19:58:56 +00:00
parent 6661e2ddb2
commit 643774f4c6
2 changed files with 20 additions and 12 deletions

View File

@@ -2876,12 +2876,18 @@ std::error_code BitcodeReader::ParseModule(bool Resume,
Type *Ty = getTypeByID(Record[0]);
if (!Ty)
return Error("Invalid record");
if (!Ty->isPointerTy())
return Error("Invalid type for value");
unsigned AddressSpace = cast<PointerType>(Ty)->getAddressSpace();
Ty = cast<PointerType>(Ty)->getElementType();
bool isConstant = Record[1] & 1;
bool explicitType = Record[1] & 2;
unsigned AddressSpace;
if (explicitType) {
AddressSpace = Record[1] >> 2;
} else {
if (!Ty->isPointerTy())
return Error("Invalid type for value");
AddressSpace = cast<PointerType>(Ty)->getAddressSpace();
Ty = cast<PointerType>(Ty)->getElementType();
}
bool isConstant = Record[1];
uint64_t RawLinkage = Record[3];
GlobalValue::LinkageTypes Linkage = getDecodedLinkage(RawLinkage);
unsigned Alignment;