summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-04-11 19:04:09 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-04-11 19:04:09 +0000
commitc89d664f72866d5b64fa23796376e433d101c03b (patch)
tree1081fa501e2d3ea5dc7fe0a6eaed2c3a01514c53
parent79de6e6d89aced04a612dab1f1a03aff2eb7e7a4 (diff)
downloadbcm5719-llvm-c89d664f72866d5b64fa23796376e433d101c03b.tar.gz
bcm5719-llvm-c89d664f72866d5b64fa23796376e433d101c03b.zip
DebugInfo: Introduce DIBuilder::replaceTemporary()
Add `DIBuilder::replaceTemporary()` as a replacement for `DIDescriptor::replaceAllUsesWith()`. I'll update clang to use the new method, and then come back to delete the original. This method dispatches to `replaceAllUsesWith()` or `replaceWithUniqued()`, depending on whether the replacement is actually a different node from the original. llvm-svn: 234695
-rw-r--r--llvm/include/llvm/IR/DIBuilder.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h
index eb5cdd60427..ac82947741c 100644
--- a/llvm/include/llvm/IR/DIBuilder.h
+++ b/llvm/include/llvm/IR/DIBuilder.h
@@ -701,6 +701,23 @@ namespace llvm {
/// resolve cycles.
void replaceArrays(DICompositeType &T, DIArray Elements,
DIArray TParems = DIArray());
+
+ /// \brief Replace a temporary node.
+ ///
+ /// Call \a MDNode::replaceAllUsesWith() on \c N, replacing it with \c
+ /// Replacement.
+ ///
+ /// If \c Replacement is the same as \c N.get(), instead call \a
+ /// MDNode::replaceWithUniqued(). In this case, the uniqued node could
+ /// have a different address, so we return the final address.
+ template <class NodeTy>
+ NodeTy *replaceTemporary(TempMDNode &&N, NodeTy *Replacement) {
+ if (N.get() == Replacement)
+ return cast<NodeTy>(MDNode::replaceWithUniqued(std::move(N)));
+
+ N->replaceAllUsesWith(Replacement);
+ return Replacement;
+ }
};
} // end namespace llvm
OpenPOWER on IntegriCloud