MODULE_CODE_FUNCTION = 8,
// ALIAS: [alias type, aliasee val#, linkage, visibility]
- MODULE_CODE_ALIAS = 9,
+ MODULE_CODE_ALIAS_OLD = 9,
// MODULE_CODE_PURGEVALS: [numvals]
MODULE_CODE_PURGEVALS = 10,
MODULE_CODE_COMDAT = 12, // COMDAT: [selection_kind, name]
MODULE_CODE_VSTOFFSET = 13, // VSTOFFSET: [offset]
+
+ // ALIAS: [alias value type, addrspace, aliasee val#, linkage, visibility]
+ MODULE_CODE_ALIAS = 14,
};
/// PARAMATTR blocks have code for defining a parameter attribute set.
// Read a record.
- switch (Stream.readRecord(Entry.ID, Record)) {
+ auto BitCode = Stream.readRecord(Entry.ID, Record);
+ switch (BitCode) {
default: break; // Default behavior, ignore unknown content.
case bitc::MODULE_CODE_VERSION: { // VERSION: [version#]
if (Record.size() < 1)
}
break;
}
- // ALIAS: [alias type, aliasee val#, linkage]
- // ALIAS: [alias type, aliasee val#, linkage, visibility, dllstorageclass]
- case bitc::MODULE_CODE_ALIAS: {
- if (Record.size() < 3)
+ // ALIAS: [alias type, addrspace, aliasee val#, linkage]
+ // ALIAS: [alias type, addrspace, aliasee val#, linkage, visibility, dllstorageclass]
+ case bitc::MODULE_CODE_ALIAS:
+ case bitc::MODULE_CODE_ALIAS_OLD: {
+ bool NewRecord = BitCode == bitc::MODULE_CODE_ALIAS;
+ if (Record.size() < (3 + NewRecord))
return error("Invalid record");
- Type *Ty = getTypeByID(Record[0]);
+ unsigned OpNum = 0;
+ Type *Ty = getTypeByID(Record[OpNum++]);
if (!Ty)
return error("Invalid record");
- auto *PTy = dyn_cast<PointerType>(Ty);
- if (!PTy)
- return error("Invalid type for value");
- auto *NewGA =
- GlobalAlias::create(PTy->getElementType(), PTy->getAddressSpace(),
- getDecodedLinkage(Record[2]), "", TheModule);
+ unsigned AddrSpace;
+ if (!NewRecord) {
+ auto *PTy = dyn_cast<PointerType>(Ty);
+ if (!PTy)
+ return error("Invalid type for value");
+ Ty = PTy->getElementType();
+ AddrSpace = PTy->getAddressSpace();
+ } else {
+ AddrSpace = Record[OpNum++];
+ }
+
+ auto Val = Record[OpNum++];
+ auto Linkage = Record[OpNum++];
+ auto *NewGA = GlobalAlias::create(
+ Ty, AddrSpace, getDecodedLinkage(Linkage), "", TheModule);
// Old bitcode files didn't have visibility field.
// Local linkage must have default visibility.
- if (Record.size() > 3 && !NewGA->hasLocalLinkage())
- // FIXME: Change to an error if non-default in 4.0.
- NewGA->setVisibility(getDecodedVisibility(Record[3]));
- if (Record.size() > 4)
- NewGA->setDLLStorageClass(getDecodedDLLStorageClass(Record[4]));
+ if (OpNum != Record.size()) {
+ auto VisInd = OpNum++;
+ if (!NewGA->hasLocalLinkage())
+ // FIXME: Change to an error if non-default in 4.0.
+ NewGA->setVisibility(getDecodedVisibility(Record[VisInd]));
+ }
+ if (OpNum != Record.size())
+ NewGA->setDLLStorageClass(getDecodedDLLStorageClass(Record[OpNum++]));
else
- upgradeDLLImportExportLinkage(NewGA, Record[2]);
- if (Record.size() > 5)
- NewGA->setThreadLocalMode(getDecodedThreadLocalMode(Record[5]));
- if (Record.size() > 6)
- NewGA->setUnnamedAddr(Record[6]);
+ upgradeDLLImportExportLinkage(NewGA, Linkage);
+ if (OpNum != Record.size())
+ NewGA->setThreadLocalMode(getDecodedThreadLocalMode(Record[OpNum++]));
+ if (OpNum != Record.size())
+ NewGA->setUnnamedAddr(Record[OpNum++]);
ValueList.push_back(NewGA);
- AliasInits.push_back(std::make_pair(NewGA, Record[1]));
+ AliasInits.push_back(std::make_pair(NewGA, Val));
break;
}
/// MODULE_CODE_PURGEVALS: [numvals]