forked from OSchip/llvm-project
[Bitcode] Report metadata decoding error more gracefully
This commit is contained in:
parent
c945d88d2b
commit
159feac1c0
|
@ -1226,10 +1226,12 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
|
|||
break;
|
||||
}
|
||||
|
||||
MetadataList.assignValue(
|
||||
LocalAsMetadata::get(ValueList.getValueFwdRef(
|
||||
Record[1], Ty, TyID, /*ConstExprInsertBB*/ nullptr)),
|
||||
NextMetadataNo);
|
||||
Value *V = ValueList.getValueFwdRef(Record[1], Ty, TyID,
|
||||
/*ConstExprInsertBB*/ nullptr);
|
||||
if (!V)
|
||||
return error("Invalid value reference from old fn metadata");
|
||||
|
||||
MetadataList.assignValue(LocalAsMetadata::get(V), NextMetadataNo);
|
||||
NextMetadataNo++;
|
||||
break;
|
||||
}
|
||||
|
@ -1248,8 +1250,11 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
|
|||
if (Ty->isMetadataTy())
|
||||
Elts.push_back(getMD(Record[i + 1]));
|
||||
else if (!Ty->isVoidTy()) {
|
||||
auto *MD = ValueAsMetadata::get(ValueList.getValueFwdRef(
|
||||
Record[i + 1], Ty, TyID, /*ConstExprInsertBB*/ nullptr));
|
||||
Value *V = ValueList.getValueFwdRef(Record[i + 1], Ty, TyID,
|
||||
/*ConstExprInsertBB*/ nullptr);
|
||||
if (!V)
|
||||
return error("Invalid value reference from old metadata");
|
||||
auto *MD = ValueAsMetadata::get(V);
|
||||
assert(isa<ConstantAsMetadata>(MD) &&
|
||||
"Expected non-function-local metadata");
|
||||
Elts.push_back(MD);
|
||||
|
@ -1269,10 +1274,12 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
|
|||
if (Ty->isMetadataTy() || Ty->isVoidTy())
|
||||
return error("Invalid record");
|
||||
|
||||
MetadataList.assignValue(
|
||||
ValueAsMetadata::get(ValueList.getValueFwdRef(
|
||||
Record[1], Ty, TyID, /*ConstExprInsertBB*/ nullptr)),
|
||||
NextMetadataNo);
|
||||
Value *V = ValueList.getValueFwdRef(Record[1], Ty, TyID,
|
||||
/*ConstExprInsertBB*/ nullptr);
|
||||
if (!V)
|
||||
return error("Invalid value reference from metadata");
|
||||
|
||||
MetadataList.assignValue(ValueAsMetadata::get(V), NextMetadataNo);
|
||||
NextMetadataNo++;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue