summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Metadata.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-12-12 19:24:33 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-12-12 19:24:33 +0000
commit121eeff4f3cfa2e9b577dce342fd365462b95a4f (patch)
tree03f7bdb7dad14f464f2aa2f10f9cbaaaf0dc91ce /llvm/lib/IR/Metadata.cpp
parentfdb705318aa5cce4b238a2694db72d925afbeec9 (diff)
downloadbcm5719-llvm-121eeff4f3cfa2e9b577dce342fd365462b95a4f.tar.gz
bcm5719-llvm-121eeff4f3cfa2e9b577dce342fd365462b95a4f.zip
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
Diffstat (limited to 'llvm/lib/IR/Metadata.cpp')
-rw-r--r--llvm/lib/IR/Metadata.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index 506284fa87a..b45d0e393bd 100644
--- a/llvm/lib/IR/Metadata.cpp
+++ b/llvm/lib/IR/Metadata.cpp
@@ -173,7 +173,8 @@ void ReplaceableMetadataImpl::replaceAllUsesWith(Metadata *MD) {
// Update unowned tracking references directly.
Metadata *&Ref = *static_cast<Metadata **>(Pair.first);
Ref = MD;
- MetadataTracking::track(Ref);
+ if (MD)
+ MetadataTracking::track(Ref);
UseMap.erase(Pair.first);
continue;
}
OpenPOWER on IntegriCloud