IR: Don't track nullptr on metadata RAUW
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 12 Dec 2014 19:24:33 +0000 (19:24 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 12 Dec 2014 19:24:33 +0000 (19:24 +0000)
commit121eeff4f3cfa2e9b577dce342fd365462b95a4f
tree03f7bdb7dad14f464f2aa2f10f9cbaaaf0dc91ce
parentfdb705318aa5cce4b238a2694db72d925afbeec9
IR: Don't track nullptr on metadata RAUW

The RAUW support in `Metadata` supports going to `nullptr` specifically
to handle values being deleted, causing `ValueAsMetadata` to be deleted.

Fix the case where the reference is from a `TrackingMDRef` (as opposed
to an `MDOperand` or a `MetadataAsValue`).

This is surprisingly rare -- metadata tracked by `TrackingMDRef` going
to null -- but it came up in an openSUSE bootstrap during inlining.  The
tracking ref was held by the `ValueMap` because it was referencing a
local, the basic block containing the local became dead after it had
been merged in, and when the local was deleted, the tracking ref
asserted in an `isa`.

llvm-svn: 224146
llvm/lib/IR/Metadata.cpp
llvm/unittests/IR/MetadataTest.cpp