From 121eeff4f3cfa2e9b577dce342fd365462b95a4f Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Fri, 12 Dec 2014 19:24:33 +0000 Subject: 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'llvm/lib') 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(Pair.first); Ref = MD; - MetadataTracking::track(Ref); + if (MD) + MetadataTracking::track(Ref); UseMap.erase(Pair.first); continue; } -- cgit v1.2.3