[llvm] r226504 - IR: Return unique_ptr from MDNode::getTemporary()
David Blaikie
dblaikie at gmail.com
Tue Jan 20 09:15:59 PST 2015
On Mon, Jan 19, 2015 at 1:30 PM, Duncan P. N. Exon Smith <
dexonsmith at apple.com> wrote:
> Author: dexonsmith
> Date: Mon Jan 19 15:30:18 2015
> New Revision: 226504
>
> URL: http://llvm.org/viewvc/llvm-project?rev=226504&view=rev
> Log:
> IR: Return unique_ptr from MDNode::getTemporary()
>
> Change `MDTuple::getTemporary()` and `MDLocation::getTemporary()` to
> return (effectively) `std::unique_ptr<T, MDNode::deleteTemporary>`, and
> clean up call sites. (For now, `DIBuilder` call sites just call
> `release()` immediately.)
>
> There's an accompanying change in each of clang and polly to use the new
> API.
>
> Modified:
> llvm/trunk/bindings/go/llvm/IRBindings.cpp
> llvm/trunk/include/llvm/IR/Metadata.h
> llvm/trunk/lib/AsmParser/LLParser.cpp
> llvm/trunk/lib/AsmParser/LLParser.h
> llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
> llvm/trunk/lib/IR/DIBuilder.cpp
> llvm/trunk/lib/IR/MDBuilder.cpp
> llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
> llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp
> llvm/trunk/unittests/IR/MetadataTest.cpp
>
> Modified: llvm/trunk/bindings/go/llvm/IRBindings.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/IRBindings.cpp?rev=226504&r1=226503&r2=226504&view=diff
>
> ==============================================================================
> --- llvm/trunk/bindings/go/llvm/IRBindings.cpp (original)
> +++ llvm/trunk/bindings/go/llvm/IRBindings.cpp Mon Jan 19 15:30:18 2015
> @@ -66,8 +66,9 @@ LLVMMetadataRef LLVMMDNode2(LLVMContextR
>
> LLVMMetadataRef LLVMTemporaryMDNode(LLVMContextRef C, LLVMMetadataRef
> *MDs,
> unsigned Count) {
> - return wrap(MDNode::getTemporary(*unwrap(C),
> - ArrayRef<Metadata *>(unwrap(MDs),
> Count)));
> + return wrap(MDTuple::getTemporary(*unwrap(C),
> + ArrayRef<Metadata *>(unwrap(MDs),
> Count))
> + .release());
> }
>
> void LLVMAddNamedMetadataOperand2(LLVMModuleRef M, const char *name,
>
> Modified: llvm/trunk/include/llvm/IR/Metadata.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Metadata.h?rev=226504&r1=226503&r2=226504&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/IR/Metadata.h (original)
> +++ llvm/trunk/include/llvm/IR/Metadata.h Mon Jan 19 15:30:18 2015
> @@ -651,6 +651,15 @@ public:
> }
> };
>
> +template <class T>
> +struct TempMDNodeDeleter {
> + inline void operator()(T *Node) const;
> +};
> +
> +#define HANDLE_UNIQUABLE_LEAF(CLASS)
> \
> + typedef std::unique_ptr<CLASS, TempMDNodeDeleter<CLASS>> Temp##CLASS;
>
I thought temporary MDNodes could just be "delete"d now? Why the custom
deleter, then? (we discussed making getTemporary return unique_ptr a week
or two ago)
(I guess there's some more recent changes that have/will necessitate this?)
> +#include "llvm/IR/Metadata.def"
> +
>
> //===----------------------------------------------------------------------===//
> /// \brief Tuple of metadata.
> class MDNode : public Metadata {
> @@ -697,8 +706,8 @@ public:
> ArrayRef<Metadata *> MDs);
> static inline MDTuple *getDistinct(LLVMContext &Context,
> ArrayRef<Metadata *> MDs);
> - static inline MDTuple *getTemporary(LLVMContext &Context,
> - ArrayRef<Metadata *> MDs);
> + static inline TempMDTuple getTemporary(LLVMContext &Context,
> + ArrayRef<Metadata *> MDs);
>
> /// \brief Deallocate a node created by getTemporary.
> ///
> @@ -884,8 +893,9 @@ public:
> /// For use in constructing cyclic MDNode structures. A temporary
> MDNode is
> /// not uniqued, may be RAUW'd, and must be manually deleted with
> /// deleteTemporary.
> - static MDTuple *getTemporary(LLVMContext &Context, ArrayRef<Metadata *>
> MDs) {
> - return getImpl(Context, MDs, Temporary);
> + static TempMDTuple getTemporary(LLVMContext &Context,
> + ArrayRef<Metadata *> MDs) {
> + return TempMDTuple(getImpl(Context, MDs, Temporary));
> }
>
> static bool classof(const Metadata *MD) {
> @@ -906,9 +916,14 @@ MDTuple *MDNode::getIfExists(LLVMContext
> MDTuple *MDNode::getDistinct(LLVMContext &Context, ArrayRef<Metadata *>
> MDs) {
> return MDTuple::getDistinct(Context, MDs);
> }
> -MDTuple *MDNode::getTemporary(LLVMContext &Context, ArrayRef<Metadata *>
> MDs) {
> +TempMDTuple MDNode::getTemporary(LLVMContext &Context,
> + ArrayRef<Metadata *> MDs) {
> return MDTuple::getTemporary(Context, MDs);
> }
> +template <class T>
> +void TempMDNodeDeleter<T>::operator()(T *Node) const {
> + MDNode::deleteTemporary(Node);
> +}
>
> /// \brief Debug location.
> ///
> @@ -945,10 +960,11 @@ public:
> Metadata *InlinedAt = nullptr) {
> return getImpl(Context, Line, Column, Scope, InlinedAt, Distinct);
> }
> - static MDLocation *getTemporary(LLVMContext &Context, unsigned Line,
> - unsigned Column, Metadata *Scope,
> - Metadata *InlinedAt = nullptr) {
> - return getImpl(Context, Line, Column, Scope, InlinedAt, Temporary);
> + static TempMDLocation getTemporary(LLVMContext &Context, unsigned Line,
> + unsigned Column, Metadata *Scope,
> + Metadata *InlinedAt = nullptr) {
> + return TempMDLocation(
> + getImpl(Context, Line, Column, Scope, InlinedAt, Temporary));
> }
>
> unsigned getLine() const { return MDNodeSubclassData; }
>
> Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=226504&r1=226503&r2=226504&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
> +++ llvm/trunk/lib/AsmParser/LLParser.cpp Mon Jan 19 15:30:18 2015
> @@ -531,13 +531,13 @@ bool LLParser::ParseMDNodeID(MDNode *&Re
> }
>
> // Otherwise, create MDNode forward reference.
> - MDTuple *FwdNode = MDTuple::getTemporary(Context, None);
> - ForwardRefMDNodes[MID] = std::make_pair(FwdNode, Lex.getLoc());
> + auto &FwdRef = ForwardRefMDNodes[MID];
> + FwdRef = std::make_pair(MDTuple::getTemporary(Context, None),
> Lex.getLoc());
>
> if (NumberedMetadata.size() <= MID)
> NumberedMetadata.resize(MID+1);
> - NumberedMetadata[MID].reset(FwdNode);
> - Result = FwdNode;
> + Result = FwdRef.first.get();
> + NumberedMetadata[MID].reset(Result);
> return false;
> }
>
> @@ -597,9 +597,7 @@ bool LLParser::ParseStandaloneMetadata()
> // See if this was forward referenced, if so, handle it.
> auto FI = ForwardRefMDNodes.find(MetadataID);
> if (FI != ForwardRefMDNodes.end()) {
> - MDTuple *Temp = FI->second.first;
> - Temp->replaceAllUsesWith(Init);
> - MDNode::deleteTemporary(Temp);
> + FI->second.first->replaceAllUsesWith(Init);
> ForwardRefMDNodes.erase(FI);
>
> assert(NumberedMetadata[MetadataID] == Init && "Tracking VH didn't
> work");
>
> Modified: llvm/trunk/lib/AsmParser/LLParser.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.h?rev=226504&r1=226503&r2=226504&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/AsmParser/LLParser.h (original)
> +++ llvm/trunk/lib/AsmParser/LLParser.h Mon Jan 19 15:30:18 2015
> @@ -136,7 +136,7 @@ namespace llvm {
> std::vector<std::pair<Type*, LocTy> > NumberedTypes;
>
> std::vector<TrackingMDNodeRef> NumberedMetadata;
> - std::map<unsigned, std::pair<MDTuple *, LocTy>> ForwardRefMDNodes;
> + std::map<unsigned, std::pair<TempMDTuple, LocTy>> ForwardRefMDNodes;
>
> // Global Value reference information.
> std::map<std::string, std::pair<GlobalValue*, LocTy> > ForwardRefVals;
>
> Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=226504&r1=226503&r2=226504&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
> +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Mon Jan 19 15:30:18
> 2015
> @@ -541,9 +541,8 @@ void BitcodeReaderMDValueList::AssignVal
> }
>
> // If there was a forward reference to this value, replace it.
> - MDTuple *PrevMD = cast<MDTuple>(OldMD.get());
> + TempMDTuple PrevMD(cast<MDTuple>(OldMD.get()));
> PrevMD->replaceAllUsesWith(MD);
> - MDNode::deleteTemporary(PrevMD);
> --NumFwdRefs;
> }
>
> @@ -557,7 +556,7 @@ Metadata *BitcodeReaderMDValueList::getV
> // Create and return a placeholder, which will later be RAUW'd.
> AnyFwdRefs = true;
> ++NumFwdRefs;
> - Metadata *MD = MDNode::getTemporary(Context, None);
> + Metadata *MD = MDNode::getTemporary(Context, None).release();
> MDValuePtrs[Idx].reset(MD);
> return MD;
> }
>
> Modified: llvm/trunk/lib/IR/DIBuilder.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=226504&r1=226503&r2=226504&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/IR/DIBuilder.cpp (original)
> +++ llvm/trunk/lib/IR/DIBuilder.cpp Mon Jan 19 15:30:18 2015
> @@ -142,15 +142,15 @@ DICompileUnit DIBuilder::createCompileUn
> assert(!Filename.empty() &&
> "Unable to create compile unit without filename");
> Metadata *TElts[] =
> {HeaderBuilder::get(DW_TAG_base_type).get(VMContext)};
> - TempEnumTypes = MDNode::getTemporary(VMContext, TElts);
> + TempEnumTypes = MDNode::getTemporary(VMContext, TElts).release();
>
> - TempRetainTypes = MDNode::getTemporary(VMContext, TElts);
> + TempRetainTypes = MDNode::getTemporary(VMContext, TElts).release();
>
> - TempSubprograms = MDNode::getTemporary(VMContext, TElts);
> + TempSubprograms = MDNode::getTemporary(VMContext, TElts).release();
>
> - TempGVs = MDNode::getTemporary(VMContext, TElts);
> + TempGVs = MDNode::getTemporary(VMContext, TElts).release();
>
> - TempImportedModules = MDNode::getTemporary(VMContext, TElts);
> + TempImportedModules = MDNode::getTemporary(VMContext, TElts).release();
>
> Metadata *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_compile_unit)
> .concat(Lang)
> @@ -825,7 +825,7 @@ DICompositeType DIBuilder::createReplace
> nullptr, // TemplateParams
> UniqueIdentifier.empty() ? nullptr
> : MDString::get(VMContext,
> UniqueIdentifier)};
> - DICompositeType RetTy(MDNode::getTemporary(VMContext, Elts));
> + DICompositeType RetTy(MDNode::getTemporary(VMContext, Elts).release());
> assert(RetTy.isCompositeType() &&
> "createReplaceableForwardDecl result should be a DIType");
> if (!UniqueIdentifier.empty())
> @@ -903,7 +903,7 @@ DIGlobalVariable DIBuilder::createTempGl
> return createGlobalVariableHelper(VMContext, Context, Name,
> LinkageName, F,
> LineNumber, Ty, isLocalToUnit, Val,
> Decl,
> false, [&](ArrayRef<Metadata *> Elts)
> {
> - return MDNode::getTemporary(VMContext, Elts);
> + return MDNode::getTemporary(VMContext, Elts).release();
> });
> }
>
> @@ -1007,7 +1007,7 @@ DISubprogram DIBuilder::createFunction(D
> return createFunctionHelper(VMContext, Context, Name, LinkageName, File,
> LineNo, Ty, isLocalToUnit, isDefinition,
> ScopeLine, Flags, isOptimized, Fn, TParams,
> Decl,
> - MDNode::getTemporary(VMContext, None),
> + MDNode::getTemporary(VMContext,
> None).release(),
> [&](ArrayRef<Metadata *> Elts) -> MDNode *{
> MDNode *Node = MDNode::get(VMContext, Elts);
> // Create a named metadata so that we
> @@ -1030,7 +1030,7 @@ DIBuilder::createTempFunctionFwdDecl(DID
> LineNo, Ty, isLocalToUnit, isDefinition,
> ScopeLine, Flags, isOptimized, Fn, TParams,
> Decl,
> nullptr, [&](ArrayRef<Metadata *> Elts) {
> - return MDNode::getTemporary(VMContext, Elts);
> + return MDNode::getTemporary(VMContext, Elts).release();
> });
> }
>
>
> Modified: llvm/trunk/lib/IR/MDBuilder.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/MDBuilder.cpp?rev=226504&r1=226503&r2=226504&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/IR/MDBuilder.cpp (original)
> +++ llvm/trunk/lib/IR/MDBuilder.cpp Mon Jan 19 15:30:18 2015
> @@ -68,9 +68,9 @@ MDNode *MDBuilder::createRange(const API
>
> MDNode *MDBuilder::createAnonymousAARoot(StringRef Name, MDNode *Extra) {
> // To ensure uniqueness the root node is self-referential.
> - MDNode *Dummy = MDNode::getTemporary(Context, None);
> + auto Dummy = MDNode::getTemporary(Context, None);
>
> - SmallVector<Metadata *, 3> Args(1, Dummy);
> + SmallVector<Metadata *, 3> Args(1, Dummy.get());
> if (Extra)
> Args.push_back(Extra);
> if (!Name.empty())
> @@ -82,7 +82,7 @@ MDNode *MDBuilder::createAnonymousAARoot
> // !1 = metadata !{metadata !0} <- root
> // Replace the dummy operand with the root node itself and delete the
> dummy.
> Root->replaceOperandWith(0, Root);
> - MDNode::deleteTemporary(Dummy);
> +
> // We now have
> // !1 = metadata !{metadata !1} <- self-referential root
> return Root;
>
> Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=226504&r1=226503&r2=226504&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original)
> +++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Mon Jan 19 15:30:18
> 2015
> @@ -319,13 +319,12 @@ static void CloneAliasScopeMetadata(Call
>
> // Now we have a complete set of all metadata in the chains used to
> specify
> // the noalias scopes and the lists of those scopes.
> - SmallVector<MDTuple *, 16> DummyNodes;
> + SmallVector<TempMDTuple, 16> DummyNodes;
> DenseMap<const MDNode *, TrackingMDNodeRef> MDMap;
> for (SetVector<const MDNode *>::iterator I = MD.begin(), IE = MD.end();
> I != IE; ++I) {
> - MDTuple *Dummy = MDTuple::getTemporary(CalledFunc->getContext(),
> None);
> - DummyNodes.push_back(Dummy);
> - MDMap[*I].reset(Dummy);
> + DummyNodes.push_back(MDTuple::getTemporary(CalledFunc->getContext(),
> None));
> + MDMap[*I].reset(DummyNodes.back().get());
> }
>
> // Create new metadata nodes to replace the dummy nodes, replacing old
> @@ -389,10 +388,6 @@ static void CloneAliasScopeMetadata(Call
> NI->setMetadata(LLVMContext::MD_noalias, M);
> }
> }
> -
> - // Now that everything has been replaced, delete the dummy nodes.
> - for (unsigned i = 0, ie = DummyNodes.size(); i != ie; ++i)
> - MDNode::deleteTemporary(DummyNodes[i]);
> }
>
> /// AddAliasScopeMetadata - If the inlined function has noalias
> arguments, then
>
> Modified: llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp?rev=226504&r1=226503&r2=226504&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp (original)
> +++ llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp Mon Jan 19 15:30:18
> 2015
> @@ -249,12 +249,11 @@ static Metadata *mapDistinctNode(const U
>
> // In general we need a dummy node, since whether the operands are null
> can
> // affect the size of the node.
> - MDTuple *Dummy = MDTuple::getTemporary(Node->getContext(), None);
> - mapToMetadata(VM, Node, Dummy);
> + auto Dummy = MDTuple::getTemporary(Node->getContext(), None);
> + mapToMetadata(VM, Node, Dummy.get());
> Metadata *NewMD = cloneMDNode(Node, VM, Flags, TypeMapper, Materializer,
> /* IsDistinct */ true);
> Dummy->replaceAllUsesWith(NewMD);
> - MDNode::deleteTemporary(Dummy);
> return mapToMetadata(VM, Node, NewMD);
> }
>
> @@ -285,14 +284,13 @@ static Metadata *mapUniquedNode(const Un
> assert(Node->isUniqued() && "Expected uniqued node");
>
> // Create a dummy node in case we have a metadata cycle.
> - MDTuple *Dummy = MDTuple::getTemporary(Node->getContext(), None);
> - mapToMetadata(VM, Node, Dummy);
> + auto Dummy = MDTuple::getTemporary(Node->getContext(), None);
> + mapToMetadata(VM, Node, Dummy.get());
>
> // Check all operands to see if any need to be remapped.
> if (!shouldRemapUniquedNode(Node, VM, Flags, TypeMapper, Materializer))
> {
> // Use an identity mapping.
> mapToSelf(VM, Node);
> - MDNode::deleteTemporary(Dummy);
> return const_cast<Metadata *>(static_cast<const Metadata *>(Node));
> }
>
> @@ -300,7 +298,6 @@ static Metadata *mapUniquedNode(const Un
> Metadata *NewMD = cloneMDNode(Node, VM, Flags, TypeMapper, Materializer,
> /* IsDistinct */ false);
> Dummy->replaceAllUsesWith(NewMD);
> - MDNode::deleteTemporary(Dummy);
> return mapToMetadata(VM, Node, NewMD);
> }
>
>
> Modified: llvm/trunk/unittests/IR/MetadataTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/MetadataTest.cpp?rev=226504&r1=226503&r2=226504&view=diff
>
> ==============================================================================
> --- llvm/trunk/unittests/IR/MetadataTest.cpp (original)
> +++ llvm/trunk/unittests/IR/MetadataTest.cpp Mon Jan 19 15:30:18 2015
> @@ -171,11 +171,10 @@ TEST_F(MDNodeTest, SelfReference) {
> // !0 = !{!0}
> // !1 = !{!0}
> {
> - MDNode *Temp = MDNode::getTemporary(Context, None);
> - Metadata *Args[] = {Temp};
> + auto Temp = MDNode::getTemporary(Context, None);
> + Metadata *Args[] = {Temp.get()};
> MDNode *Self = MDNode::get(Context, Args);
> Self->replaceOperandWith(0, Self);
> - MDNode::deleteTemporary(Temp);
> ASSERT_EQ(Self, Self->getOperand(0));
>
> // Self-references should be distinct, so MDNode::get() should grab a
> @@ -190,11 +189,10 @@ TEST_F(MDNodeTest, SelfReference) {
> // !0 = !{!0, !{}}
> // !1 = !{!0, !{}}
> {
> - MDNode *Temp = MDNode::getTemporary(Context, None);
> - Metadata *Args[] = {Temp, MDNode::get(Context, None)};
> + auto Temp = MDNode::getTemporary(Context, None);
> + Metadata *Args[] = {Temp.get(), MDNode::get(Context, None)};
> MDNode *Self = MDNode::get(Context, Args);
> Self->replaceOperandWith(0, Self);
> - MDNode::deleteTemporary(Temp);
> ASSERT_EQ(Self, Self->getOperand(0));
>
> // Self-references should be distinct, so MDNode::get() should grab a
> @@ -310,48 +308,44 @@ TEST_F(MDNodeTest, getDistinct) {
> TEST_F(MDNodeTest, isUniqued) {
> MDNode *U = MDTuple::get(Context, None);
> MDNode *D = MDTuple::getDistinct(Context, None);
> - MDNode *T = MDTuple::getTemporary(Context, None);
> + auto T = MDTuple::getTemporary(Context, None);
> EXPECT_TRUE(U->isUniqued());
> EXPECT_FALSE(D->isUniqued());
> EXPECT_FALSE(T->isUniqued());
> - MDNode::deleteTemporary(T);
> }
>
> TEST_F(MDNodeTest, isDistinct) {
> MDNode *U = MDTuple::get(Context, None);
> MDNode *D = MDTuple::getDistinct(Context, None);
> - MDNode *T = MDTuple::getTemporary(Context, None);
> + auto T = MDTuple::getTemporary(Context, None);
> EXPECT_FALSE(U->isDistinct());
> EXPECT_TRUE(D->isDistinct());
> EXPECT_FALSE(T->isDistinct());
> - MDNode::deleteTemporary(T);
> }
>
> TEST_F(MDNodeTest, isTemporary) {
> MDNode *U = MDTuple::get(Context, None);
> MDNode *D = MDTuple::getDistinct(Context, None);
> - MDNode *T = MDTuple::getTemporary(Context, None);
> + auto T = MDTuple::getTemporary(Context, None);
> EXPECT_FALSE(U->isTemporary());
> EXPECT_FALSE(D->isTemporary());
> EXPECT_TRUE(T->isTemporary());
> - MDNode::deleteTemporary(T);
> }
>
> TEST_F(MDNodeTest, getDistinctWithUnresolvedOperands) {
> // temporary !{}
> - MDTuple *Temp = MDTuple::getTemporary(Context, None);
> + auto Temp = MDTuple::getTemporary(Context, None);
> ASSERT_FALSE(Temp->isResolved());
>
> // distinct !{temporary !{}}
> - Metadata *Ops[] = {Temp};
> + Metadata *Ops[] = {Temp.get()};
> MDNode *Distinct = MDNode::getDistinct(Context, Ops);
> EXPECT_TRUE(Distinct->isResolved());
> - EXPECT_EQ(Temp, Distinct->getOperand(0));
> + EXPECT_EQ(Temp.get(), Distinct->getOperand(0));
>
> // temporary !{} => !{}
> MDNode *Empty = MDNode::get(Context, None);
> Temp->replaceAllUsesWith(Empty);
> - MDNode::deleteTemporary(Temp);
> EXPECT_EQ(Empty, Distinct->getOperand(0));
> }
>
> @@ -360,19 +354,18 @@ TEST_F(MDNodeTest, handleChangedOperandR
> MDNode *N0 = MDNode::get(Context, None);
>
> // !1 = !{!3, null}
> - MDTuple *Temp3 = MDTuple::getTemporary(Context, None);
> - Metadata *Ops1[] = {Temp3, nullptr};
> + auto Temp3 = MDTuple::getTemporary(Context, None);
> + Metadata *Ops1[] = {Temp3.get(), nullptr};
> MDNode *N1 = MDNode::get(Context, Ops1);
>
> // !2 = !{!3, !0}
> - Metadata *Ops2[] = {Temp3, N0};
> + Metadata *Ops2[] = {Temp3.get(), N0};
> MDNode *N2 = MDNode::get(Context, Ops2);
>
> // !3 = !{!2}
> Metadata *Ops3[] = {N2};
> MDNode *N3 = MDNode::get(Context, Ops3);
> Temp3->replaceAllUsesWith(N3);
> - MDNode::deleteTemporary(Temp3);
>
> // !4 = !{!1}
> Metadata *Ops4[] = {N1};
> @@ -425,8 +418,8 @@ TEST_F(MDNodeTest, replaceResolvedOperan
> // a global value that gets RAUW'ed.
> //
> // Use a temporary node to keep N from being resolved.
> - MDTuple *Temp = MDTuple::getTemporary(Context, None);
> - Metadata *Ops[] = {nullptr, Temp};
> + auto Temp = MDTuple::getTemporary(Context, None);
> + Metadata *Ops[] = {nullptr, Temp.get()};
>
> MDNode *Empty = MDTuple::get(Context, ArrayRef<Metadata *>());
> MDNode *N = MDTuple::get(Context, Ops);
> @@ -438,12 +431,11 @@ TEST_F(MDNodeTest, replaceResolvedOperan
> EXPECT_EQ(Empty, N->getOperand(0));
>
> // Check code for adding another unresolved operand.
> - N->replaceOperandWith(0, Temp);
> - EXPECT_EQ(Temp, N->getOperand(0));
> + N->replaceOperandWith(0, Temp.get());
> + EXPECT_EQ(Temp.get(), N->getOperand(0));
>
> // Remove the references to Temp; required for teardown.
> Temp->replaceAllUsesWith(nullptr);
> - MDNode::deleteTemporary(Temp);
> }
>
> typedef MetadataTest MDLocationTest;
> @@ -485,10 +477,9 @@ TEST_F(MDLocationTest, getDistinct) {
>
> TEST_F(MDLocationTest, getTemporary) {
> MDNode *N = MDNode::get(Context, None);
> - MDLocation *L = MDLocation::getTemporary(Context, 2, 7, N);
> + auto L = MDLocation::getTemporary(Context, 2, 7, N);
> EXPECT_TRUE(L->isTemporary());
> EXPECT_FALSE(L->isResolved());
> - MDNode::deleteTemporary(L);
> }
>
> typedef MetadataTest MetadataAsValueTest;
> @@ -557,11 +548,11 @@ TEST_F(ValueAsMetadataTest, CollidingDou
> ConstantInt::get(getGlobalContext(), APInt(8, 0)));
>
> // Create a temporary to prevent nodes from resolving.
> - MDTuple *Temp = MDTuple::getTemporary(Context, None);
> + auto Temp = MDTuple::getTemporary(Context, None);
>
> // When the first operand of N1 gets reset to nullptr, it'll collide
> with N2.
> - Metadata *Ops1[] = {CI, CI, Temp};
> - Metadata *Ops2[] = {nullptr, CI, Temp};
> + Metadata *Ops1[] = {CI, CI, Temp.get()};
> + Metadata *Ops2[] = {nullptr, CI, Temp.get()};
>
> auto *N1 = MDTuple::get(Context, Ops1);
> auto *N2 = MDTuple::get(Context, Ops2);
> @@ -573,11 +564,10 @@ TEST_F(ValueAsMetadataTest, CollidingDou
> ValueAsMetadata::handleDeletion(CI->getValue());
> EXPECT_EQ(nullptr, N2->getOperand(0));
> EXPECT_EQ(nullptr, N2->getOperand(1));
> - EXPECT_EQ(Temp, N2->getOperand(2));
> + EXPECT_EQ(Temp.get(), N2->getOperand(2));
>
> // Clean up Temp for teardown.
> Temp->replaceAllUsesWith(nullptr);
> - MDNode::deleteTemporary(Temp);
> }
>
> typedef MetadataTest TrackingMDRefTest;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150120/814df7a2/attachment.html>
More information about the llvm-commits
mailing list