[llvm-commits] [PATCH] TrackingVH and DebugInfo changes

Daniel Dunbar daniel at zuster.org
Sat Sep 19 22:37:20 PDT 2009


Hi,

The attached patches add a TrackingVH and changes DebugInfo to use it
*everywhere*.

The immediate motivation for this change is PR4984:
  http://llvm.org/bugs/show_bug.cgi?id=4894
but they are also motivated by the general complexity of using
something which is represented by an MDNode.

The issue is that metadata nodes are uniqued, sometimes surprisingly.
This patch essentially trades some runtime performance for safety by
making sure that DebugInfo objects never have dangling pointers.

It isn't without warts, see the comments on TrackingVH. I also decided
to change DIDerivedType to allow its version of replaceAllUsesWith()
on a value with itself. The issue here is that a DIDerivedType wraps
an MDNode internally, so it may be very reasonable for a client to do
something like:
--
  DIDerivedType A = ...;
  ... do some work, for example code which may build a recursive
reference to A ...
  DIDerivedType B = ... create the real object ...;
  B.replaceAllUsesWith(B);
--
but due to MDNode uniquing, its possible that A and B will end up
pointing to the same underlying node. It seems mean to require clients
to remember this, but it does go against the RAUW convention.

Overall I think this is an net positive change, and it will simplify
some subtle code in clang and llvm-gcc (and PR4984), but I'm open to
alternate approaches.

Comments?

 - Daniel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-a-TrackingVH-value-handle.patch
Type: application/octet-stream
Size: 6657 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090919/18f8b6f6/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Switch-DIDescriptor-to-use-a-TrackingVH.patch
Type: application/octet-stream
Size: 2445 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090919/18f8b6f6/attachment-0001.obj>


More information about the llvm-commits mailing list