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

Devang Patel dpatel at apple.com
Mon Sep 21 10:24:42 PDT 2009


On Sep 19, 2009, at 10:37 PM, Daniel Dunbar wrote:

> 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.

ok.

> 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?

looks good.
>
> - Daniel
> <0001-Add-a-TrackingVH-value-handle.patch><0002-Switch-DIDescriptor- 
> to-use-a-TrackingVH.patch>

-
Devang




More information about the llvm-commits mailing list