This is essentially pretty simple, it first walks through the the contents of
the module starting from instructions/named metadata to find all MDNodes and
then does a standard list reduction in order to cut down the list of which
metadata nodes to keep. To actually implement the MDNode removal, it creates
a temporary Node, inserts it into the VMap, and laters RAUWs that to null.
This works great, except that the verifier really doesn't like null values in
some MDTuples. Thus, we need some extra logic to also fix up any MDTuples,
which would otherwise contain a null.
The one ugly point here is that in order to do the above, we need to allow
temporary metadata during cloning. To make this possible, I had to modify
CloneModule and CloneFunctionInto, in order to allow passing RemapFlags
through. I think this API change is fine, but if there's a different way
to accomplish the same thing, I'd be happy to change that. Naturally, I can
split that part out into a separate review.
There's also a small fix to pass through AllowTemps recursively in
resolveCylces, which was needed to make the above work.