<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Mon, Jul 10, 2017 at 6:27 AM Teresa Johnson via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Jul 9, 2017 at 7:35 PM, Mehdi AMINI via Phabricator <span dir="ltr"><<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">mehdi_amini added a comment.<br>
<span><br>
In <a href="https://reviews.llvm.org/D35148#803251" rel="noreferrer" target="_blank">https://reviews.llvm.org/D35148#803251</a>, @tejohnson wrote:<br>
<br>
> In <a href="https://reviews.llvm.org/D35148#803193" rel="noreferrer" target="_blank">https://reviews.llvm.org/D35148#803193</a>, @mehdi_amini wrote:<br>
><br>
> > When we used an std::map originally it was because we needed the ordering. Have you checked that we don't iterate on any instance of this map?<br>
><br>
><br>
> From <a href="http://llvm.org/docs/ProgrammersManual.html#llvm-adt-densemap-h" rel="noreferrer" target="_blank">http://llvm.org/docs/ProgrammersManual.html#llvm-adt-densemap-h</a> it doesn't appear that iteration order is an issue for DenseMap.<br>
<br>
<br>
</span>As long as keys aren't pointers...<br>
(But just as every hash_map right?)<br></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Right.</div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<span><br>
> StringMap on the other hand does not have a deterministic iteration ordering, and I recall using a std::map somewhere instead of a StringMap for that reason.<br>
<br>
</span>Really? I'm pretty sure the order is deterministic, but just like any hash_map (including DenseMap): the order of insertion and the hash function are determining the resulting order.<br></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>According to the end of <a href="http://llvm.org/docs/ProgrammersManual.html#llvm-adt-stringmap-h" target="_blank">http://llvm.org/docs/ProgrammersManual.html#llvm-adt-stringmap-h</a> the iteration order is non-deterministic.</div></div></div></div></blockquote><div><br>Yeah, this sort of gets into fuzzy places. LLVM's hash-based structures (this goes for DenseMap, StringMap, etc) are currently implemented deterministically, but arbitrarily ordered (based on hash and insertion order - I wonder if they change based on how many buckets they have (eg: could you get different order if you insert some things, clear, then insert some new things)).<br><br>It's not entirely clear whether we want to make LLVM's output stable relative to changes to these data structures internals changing (eg: changing hash, load factor, etc)... - I kind of like the idea of doing that, but it does come at some costs. If we don't do that then LLVM as a whole still probably has stable output (until someone gets annoyed with cleaning up tests when tuning these hashing data structures - and does what some standard library implementations have done: mix in a random number to the hash function (either random per execution, per build, or even per instance of the data structure)).<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<span><br>
> Note the index itself still uses a std::map, for other reasons (documented at the declaration). We also still use a std::map where we write out the individual index files for the backends in the distributed backend case. In any case from what I can tell, we typically query this map, rather than iterate. The only place I see an iteration is when we are computing imports for a module, so I suppose that could affect the debug output ordering, but does that matter (if iteration order is even non-deterministic for DenseMap, and from what I can tell from the LLVM doc linked above it isn't).<br>
<br>
</span>OK!<br>
<br>
<br>
<a href="https://reviews.llvm.org/D35148" rel="noreferrer" target="_blank">https://reviews.llvm.org/D35148</a><br>
<br>
<br>
<br>
</blockquote></div></div></div><div dir="ltr"><div class="gmail_extra"><br><br clear="all"><div><br></div>-- <br><div class="m_2644430149407634698gmail-m_-2897639449245781825gmail_signature"><span style="font-family:Times;font-size:medium"><table cellspacing="0" cellpadding="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top:2px solid rgb(213,15,37)">Teresa Johnson |</td><td nowrap style="border-top:2px solid rgb(51,105,232)"> Software Engineer |</td><td nowrap style="border-top:2px solid rgb(0,153,57)"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top:2px solid rgb(238,178,17)"> <a href="tel:(408)%20460-2413" value="+14084602413" target="_blank">408-460-2413</a></td></tr></tbody></table></span></div>
</div></div>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">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></div>