<div dir="ltr">SmallVector? (or I guess std::vector allows this to not impact the size of LLVMContext very much & there's no small size that'd practically fit all the nodes in the small space when used anyway?)</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 19, 2016 at 4:59 PM, Duncan P. N. Exon Smith via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: dexonsmith<br>
Date: Tue Apr 19 18:59:13 2016<br>
New Revision: 266835<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=266835&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=266835&view=rev</a><br>
Log:<br>
IR: Use std::vector instead of SmallPtrSet for distinct nodes, NFC<br>
<br>
We never use the set-ness of SmallPtrSet for distinct nodes. Eventually<br>
we may start garbage-collecting or reference-counting nodes (in which<br>
cases we'd want to remove things from this collection, and a fast erase<br>
would be valuable), but in the meantime a vector is sufficient.<br>
<br>
Modified:<br>
llvm/trunk/lib/IR/LLVMContextImpl.h<br>
llvm/trunk/lib/IR/Metadata.cpp<br>
<br>
Modified: llvm/trunk/lib/IR/LLVMContextImpl.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LLVMContextImpl.h?rev=266835&r1=266834&r2=266835&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LLVMContextImpl.h?rev=266835&r1=266834&r2=266835&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/LLVMContextImpl.h (original)<br>
+++ llvm/trunk/lib/IR/LLVMContextImpl.h Tue Apr 19 18:59:13 2016<br>
@@ -33,6 +33,7 @@<br>
#include "llvm/IR/Metadata.h"<br>
#include "llvm/IR/ValueHandle.h"<br>
#include "llvm/Support/Dwarf.h"<br>
+#include <vector><br>
<br>
namespace llvm {<br>
<br>
@@ -1026,9 +1027,9 @@ public:<br>
<br>
// MDNodes may be uniqued or not uniqued. When they're not uniqued, they<br>
// aren't in the MDNodeSet, but they're still shared between objects, so no<br>
- // one object can destroy them. This set allows us to at least destroy them<br>
- // on Context destruction.<br>
- SmallPtrSet<MDNode *, 1> DistinctMDNodes;<br>
+ // one object can destroy them. Keep track of them here so we can delete<br>
+ // them on context teardown.<br>
+ std::vector<MDNode *> DistinctMDNodes;<br>
<br>
DenseMap<Type*, ConstantAggregateZero*> CAZConstants;<br>
<br>
<br>
Modified: llvm/trunk/lib/IR/Metadata.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Metadata.cpp?rev=266835&r1=266834&r2=266835&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Metadata.cpp?rev=266835&r1=266834&r2=266835&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/Metadata.cpp (original)<br>
+++ llvm/trunk/lib/IR/Metadata.cpp Tue Apr 19 18:59:13 2016<br>
@@ -806,7 +806,7 @@ void MDNode::storeDistinctInContext() {<br>
#include "llvm/IR/Metadata.def"<br>
}<br>
<br>
- getContext().pImpl->DistinctMDNodes.insert(this);<br>
+ getContext().pImpl->DistinctMDNodes.push_back(this);<br>
}<br>
<br>
void MDNode::replaceOperandWith(unsigned I, Metadata *New) {<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>