MapMetadata: Allow unresolved metadata if it won't change

Allow unresolved nodes through the `MapMetadata()` if
`RF_NoModuleLevelChanges`, since there's no remapping to do anyway.

This fixes PR22929.  I'll add a clang test as a follow-up.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232449 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith
2015-03-17 01:14:40 +00:00
parent 58d2381868
commit ed1d6bdfbd
3 changed files with 33 additions and 1 deletions

View File

@ -291,14 +291,18 @@ static Metadata *MapMetadataImpl(const Metadata *MD,
return nullptr;
}
// Note: this cast precedes the Flags check so we always get its associated
// assertion.
const MDNode *Node = cast<MDNode>(MD);
assert(Node->isResolved() && "Unexpected unresolved node");
// If this is a module-level metadata and we know that nothing at the
// module level is changing, then use an identity mapping.
if (Flags & RF_NoModuleLevelChanges)
return mapToSelf(VM, MD);
// Require resolved nodes whenever metadata might be remapped.
assert(Node->isResolved() && "Unexpected unresolved node");
if (Node->isDistinct())
return mapDistinctNode(Node, Cycles, VM, Flags, TypeMapper, Materializer);