mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-11 00:39:36 +00:00
Utils: Extract helper function, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225897 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
cb5c0e6745
commit
f29d97eb0f
@ -154,6 +154,32 @@ static Metadata *mapToSelf(ValueToValueMapTy &VM, const Metadata *MD) {
|
||||
return mapToMetadata(VM, MD, const_cast<Metadata *>(MD));
|
||||
}
|
||||
|
||||
static Metadata *MapMetadataImpl(const Metadata *MD, ValueToValueMapTy &VM,
|
||||
RemapFlags Flags,
|
||||
ValueMapTypeRemapper *TypeMapper,
|
||||
ValueMaterializer *Materializer);
|
||||
|
||||
static Metadata *mapMetadataOp(Metadata *Op, ValueToValueMapTy &VM,
|
||||
RemapFlags Flags,
|
||||
ValueMapTypeRemapper *TypeMapper,
|
||||
ValueMaterializer *Materializer) {
|
||||
if (!Op)
|
||||
return nullptr;
|
||||
if (Metadata *MappedOp =
|
||||
MapMetadataImpl(Op, VM, Flags, TypeMapper, Materializer))
|
||||
return MappedOp;
|
||||
// Use identity map if MappedOp is null and we can ignore missing entries.
|
||||
if (Flags & RF_IgnoreMissingEntries)
|
||||
return Op;
|
||||
|
||||
// FIXME: This assert crashes during bootstrap, but I think it should be
|
||||
// correct. For now, just match behaviour from before the metadata/value
|
||||
// split.
|
||||
//
|
||||
// llvm_unreachable("Referenced metadata not in value map!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static Metadata *MapMetadataImpl(const Metadata *MD, ValueToValueMapTy &VM,
|
||||
RemapFlags Flags,
|
||||
ValueMapTypeRemapper *TypeMapper,
|
||||
@ -190,21 +216,7 @@ static Metadata *MapMetadataImpl(const Metadata *MD, ValueToValueMapTy &VM,
|
||||
assert(Node->isResolved() && "Unexpected unresolved node");
|
||||
|
||||
auto getMappedOp = [&](Metadata *Op) -> Metadata *{
|
||||
if (!Op)
|
||||
return nullptr;
|
||||
if (Metadata *MappedOp =
|
||||
MapMetadataImpl(Op, VM, Flags, TypeMapper, Materializer))
|
||||
return MappedOp;
|
||||
// Use identity map if MappedOp is null and we can ignore missing entries.
|
||||
if (Flags & RF_IgnoreMissingEntries)
|
||||
return Op;
|
||||
|
||||
// FIXME: This assert crashes during bootstrap, but I think it should be
|
||||
// correct. For now, just match behaviour from before the metadata/value
|
||||
// split.
|
||||
//
|
||||
// llvm_unreachable("Referenced metadata not in value map!");
|
||||
return nullptr;
|
||||
return mapMetadataOp(Op, VM, Flags, TypeMapper, Materializer);
|
||||
};
|
||||
|
||||
// If this is a module-level metadata and we know that nothing at the
|
||||
|
Loading…
x
Reference in New Issue
Block a user