<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 26, 2016, at 1:30 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br class="Apple-interchange-newline"><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Tue, Jan 26, 2016 at 12:34 PM, Mehdi AMINI via llvm-commits<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">joker.eph created this revision.<br class="">joker.eph added a reviewer: dexonsmith.<br class="">joker.eph added a subscriber: llvm-commits.<br class=""><br class="">Loading IR with debug info improves MDString::get() from 19ms to 10ms.<br class=""><br class=""><a href="http://reviews.llvm.org/D16597" rel="noreferrer" target="_blank" class="">http://reviews.llvm.org/D16597</a><br class=""><br class="">Files:<br class=""> <span class="Apple-converted-space"> </span>include/llvm/IR/Metadata.h<br class=""> <span class="Apple-converted-space"> </span>lib/IR/Metadata.cpp<br class=""><br class="">Index: lib/IR/Metadata.cpp<br class="">===================================================================<br class="">--- lib/IR/Metadata.cpp<br class="">+++ lib/IR/Metadata.cpp<br class="">@@ -399,17 +399,12 @@<br class=""><br class=""> MDString *MDString::get(LLVMContext &Context, StringRef Str) {<br class=""> auto &Store = Context.pImpl->MDStringCache;<br class="">- auto I = Store.find(Str);<br class="">- if (I != Store.end())<br class="">- return &I->second;<br class="">-<br class="">- auto *Entry =<br class="">- StringMapEntry<MDString>::Create(Str, Store.getAllocator(), MDString());<br class="">- bool WasInserted = Store.insert(Entry);<br class="">- (void)WasInserted;<br class="">- assert(WasInserted && "Expected entry to be inserted");<br class="">- Entry->second.Entry = Entry;<br class="">- return &Entry->second;<br class="">+ auto I = Store.insert(std::make_pair(Str, MDString()));<br class="">+ auto &MapEntry = I.first->getValue();<br class="">+ if (!I.second)<br class="">+ return &MapEntry;<br class="">+ MapEntry.Entry = &*I.first;<br class="">+ return &MapEntry;<br class=""> }<br class=""><br class=""> StringRef MDString::getString() const {<br class="">Index: include/llvm/IR/Metadata.h<br class="">===================================================================<br class="">--- include/llvm/IR/Metadata.h<br class="">+++ include/llvm/IR/Metadata.h<br class="">@@ -599,9 +599,9 @@<br class=""><br class=""> StringMapEntry<MDString> *Entry;<br class=""> MDString() : Metadata(MDStringKind, Uniqued), Entry(nullptr) {}<br class="">- MDString(MDString &&) : Metadata(MDStringKind, Uniqued) {}<br class=""></blockquote><div class=""><br class=""></div><div class="">Well that was weird/scary/bogus ^</div></div></div></blockquote><div><br class=""></div><div>Yes but private :)</div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><br class=""> public:<br class="">+ MDString(MDString &&R) : Metadata(MDStringKind, Uniqued), Entry(R.Entry) {}<br class=""></blockquote><div class=""><br class=""></div><div class="">Could we just remove this, and rely on the implicit move/copy ctors? ^ I guess maybe the base copy/move ctor doesn't do the right thing (since it's not being used here)<br class=""></div></div></div></blockquote><div><br class=""></div><div>Good point!</div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""><br class="">Should we just make this the copy ctor? It doesn't seme to really be moving anything.</div></div></div></blockquote><div><br class=""></div><div>We could consider MDString to be a “lightweight” value-based type (like StringRef) and declare a copy constructor, but will it be coherent with the rest of the other metadata types?</div><div>I was not really happy to make it public in the first place, but std::pair needs it to insert in the map.</div><div><br class=""></div><div>— </div><div>Mehdi</div><div><br class=""></div><div><br class=""></div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"> static MDString *get(LLVMContext &Context, StringRef Str);<br class=""> static MDString *get(LLVMContext &Context, const char *Str) {<br class=""> return get(Context, Str ? StringRef(Str) : StringRef());<br class=""><br class=""><br class=""><br class="">_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a></blockquote></div></div></blockquote></div><br class=""></body></html>