From 946fdcc50cbda9cc30bb78f6c71aa49f3c3ae7ae Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Mon, 19 Jan 2015 20:36:39 +0000 Subject: IR: Remove MDNodeFwdDecl Remove `MDNodeFwdDecl` (as promised in r226481). Aside from API changes, there's no real functionality change here. `MDNode::getTemporary()` now forwards to `MDTuple::getTemporary()`, which returns a tuple with `isTemporary()` equal to true. The main point is that we can now add temporaries of other `MDNode` subclasses, needed for PR22235 (I introduced `MDNodeFwdDecl` in the first place because I didn't recognize this need, and thought they were only needed to handle forward references). A few things left out of (or highlighted by) this commit: - I've had to remove the (few) uses of `std::unique_ptr<>` to deal with temporaries, since the destructor is no longer public. `getTemporary()` should probably return the equivalent of `std::unique_ptr`. - `MDLocation::getTemporary()` doesn't exist yet (worse, it actually does exist, but does the wrong thing: `MDNode::getTemporary()` is inherited and returns an `MDTuple`). - `MDNode` now only has one subclass, `UniquableMDNode`, and the distinction between them is actually somewhat confusing. I'll fix those up next. llvm-svn: 226501 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp') diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index fe48c25..a9adaf4 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -541,7 +541,7 @@ void BitcodeReaderMDValueList::AssignValue(Metadata *MD, unsigned Idx) { } // If there was a forward reference to this value, replace it. - MDNodeFwdDecl *PrevMD = cast(OldMD.get()); + MDTuple *PrevMD = cast(OldMD.get()); PrevMD->replaceAllUsesWith(MD); MDNode::deleteTemporary(PrevMD); --NumFwdRefs; @@ -573,9 +573,12 @@ void BitcodeReaderMDValueList::tryToResolveCycles() { // Resolve any cycles. for (auto &MD : MDValuePtrs) { - assert(!(MD && isa(MD)) && "Unexpected forward reference"); - if (auto *N = dyn_cast_or_null(MD)) - N->resolveCycles(); + auto *N = dyn_cast_or_null(MD); + if (!N) + continue; + + assert(!N->isTemporary() && "Unexpected forward reference"); + N->resolveCycles(); } } -- cgit v1.1