llvm.org GIT mirror llvm / ffa1a45
Utils: Thread distinct-ness through the cloneMD*() functions, NFC The new logic isn't actually reachable yet, so no functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225918 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 5 years ago
1 changed file(s) with 11 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
182182 static Metadata *cloneMDTuple(const MDTuple *Node, ValueToValueMapTy &VM,
183183 RemapFlags Flags,
184184 ValueMapTypeRemapper *TypeMapper,
185 ValueMaterializer *Materializer) {
185 ValueMaterializer *Materializer,
186 bool IsDistinct) {
186187 SmallVector Elts;
187188 Elts.reserve(Node->getNumOperands());
188189 for (unsigned I = 0, E = Node->getNumOperands(); I != E; ++I)
189190 Elts.push_back(mapMetadataOp(Node->getOperand(I), VM, Flags, TypeMapper,
190191 Materializer));
191192
192 return MDTuple::get(Node->getContext(), Elts);
193 return (IsDistinct ? MDTuple::getDistinct : MDTuple::get)(Node->getContext(),
194 Elts);
193195 }
194196
195197 static Metadata *cloneMDLocation(const MDLocation *Node, ValueToValueMapTy &VM,
196198 RemapFlags Flags,
197199 ValueMapTypeRemapper *TypeMapper,
198 ValueMaterializer *Materializer) {
199 return MDLocation::get(
200 ValueMaterializer *Materializer,
201 bool IsDistinct) {
202 return (IsDistinct ? MDLocation::getDistinct : MDLocation::get)(
200203 Node->getContext(), Node->getLine(), Node->getColumn(),
201204 mapMetadataOp(Node->getScope(), VM, Flags, TypeMapper, Materializer),
202205 mapMetadataOp(Node->getInlinedAt(), VM, Flags, TypeMapper, Materializer));
204207
205208 static Metadata *cloneMDNode(const UniquableMDNode *Node, ValueToValueMapTy &VM,
206209 RemapFlags Flags, ValueMapTypeRemapper *TypeMapper,
207 ValueMaterializer *Materializer) {
210 ValueMaterializer *Materializer, bool IsDistinct) {
208211 switch (Node->getMetadataID()) {
209212 default:
210213 llvm_unreachable("Invalid UniquableMDNode subclass");
211214 #define HANDLE_UNIQUABLE_LEAF(CLASS) \
212215 case Metadata::CLASS##Kind: \
213216 return clone##CLASS(cast(Node), VM, Flags, TypeMapper, \
214 Materializer); \
217 Materializer, IsDistinct); \
215218 break;
216219 #include "llvm/IR/Metadata.def"
217220 }
278281 }
279282
280283 // At least one operand needs remapping.
281 Metadata *NewMD = cloneMDNode(Node, VM, Flags, TypeMapper, Materializer);
284 Metadata *NewMD = cloneMDNode(Node, VM, Flags, TypeMapper, Materializer,
285 /* IsDistinct */ false);
282286 Dummy->replaceAllUsesWith(NewMD);
283287 MDNode::deleteTemporary(Dummy);
284288 return mapToMetadata(VM, Node, NewMD);