aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2022-02-14 17:00:41 +0100
committerNikita Popov <npopov@redhat.com>2022-02-22 17:27:06 +0100
commitb6eafba296fc0444892a176ccc3cb947399b408c (patch)
treecfed2de41c04ae53b6d1dac1aa5ae49972d69b11 /llvm/lib/Bitcode/Reader/MetadataLoader.cpp
parent79c9072dc009693477242bc1347a2a6c3e419423 (diff)
downloadllvm-b6eafba296fc0444892a176ccc3cb947399b408c.zip
llvm-b6eafba296fc0444892a176ccc3cb947399b408c.tar.gz
llvm-b6eafba296fc0444892a176ccc3cb947399b408c.tar.bz2
[Bitcode] Store type IDs for values
This is the next step towards supporting bitcode auto upgrade with opaque pointers. The ValueList now stores the Value* together with its associated type ID, which allows inspecting the original pointer element type of arbitrary values. This is a largely mechanical change threading the type ID through various places. I've left TODOTypeID placeholders in a number of places where determining the type ID is either non-trivial or requires allocating a new type ID not present in the original bitcode. For this reason, the new type IDs are also not used for anything yet (apart from propagation). They will get used once the TODOs are resolved. Differential Revision: https://reviews.llvm.org/D119821
Diffstat (limited to 'llvm/lib/Bitcode/Reader/MetadataLoader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/MetadataLoader.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
index 1955443..fb5491a 100644
--- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
+++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
@@ -1219,14 +1219,15 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
break;
}
- Type *Ty = getTypeByID(Record[0]);
+ unsigned TyID = Record[0];
+ Type *Ty = getTypeByID(TyID);
if (Ty->isMetadataTy() || Ty->isVoidTy()) {
dropRecord();
break;
}
MetadataList.assignValue(
- LocalAsMetadata::get(ValueList.getValueFwdRef(Record[1], Ty)),
+ LocalAsMetadata::get(ValueList.getValueFwdRef(Record[1], Ty, TyID)),
NextMetadataNo);
NextMetadataNo++;
break;
@@ -1239,14 +1240,15 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
unsigned Size = Record.size();
SmallVector<Metadata *, 8> Elts;
for (unsigned i = 0; i != Size; i += 2) {
- Type *Ty = getTypeByID(Record[i]);
+ unsigned TyID = Record[i];
+ Type *Ty = getTypeByID(TyID);
if (!Ty)
return error("Invalid record");
if (Ty->isMetadataTy())
Elts.push_back(getMD(Record[i + 1]));
else if (!Ty->isVoidTy()) {
- auto *MD =
- ValueAsMetadata::get(ValueList.getValueFwdRef(Record[i + 1], Ty));
+ auto *MD = ValueAsMetadata::get(
+ ValueList.getValueFwdRef(Record[i + 1], Ty, TyID));
assert(isa<ConstantAsMetadata>(MD) &&
"Expected non-function-local metadata");
Elts.push_back(MD);
@@ -1261,12 +1263,13 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
if (Record.size() != 2)
return error("Invalid record");
- Type *Ty = getTypeByID(Record[0]);
+ unsigned TyID = Record[0];
+ Type *Ty = getTypeByID(TyID);
if (Ty->isMetadataTy() || Ty->isVoidTy())
return error("Invalid record");
MetadataList.assignValue(
- ValueAsMetadata::get(ValueList.getValueFwdRef(Record[1], Ty)),
+ ValueAsMetadata::get(ValueList.getValueFwdRef(Record[1], Ty, TyID)),
NextMetadataNo);
NextMetadataNo++;
break;