<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><div style="direction: inherit;"><br></div><br>Sent from my iPhone</div><div><br>On Aug 20, 2016, at 11:52 AM, Philip Reames <<a href="mailto:listmail@philipreames.com">listmail@philipreames.com</a>> wrote:<br><br></div><blockquote type="cite"><div><span>On 08/18/2016 11:30 AM, Pete Cooper via llvm-commits wrote:</span><br><blockquote type="cite"><span>Author: pete</span><br></blockquote><blockquote type="cite"><span>Date: Thu Aug 18 13:30:54 2016</span><br></blockquote><blockquote type="cite"><span>New Revision: 279113</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=279113&view=rev">http://llvm.org/viewvc/llvm-project?rev=279113&view=rev</a></span><br></blockquote><blockquote type="cite"><span>Log:</span><br></blockquote><blockquote type="cite"><span>Add a version of Intrinsic::getName which is more efficient when there are no overloads.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>When running 'opt -O2 verify-uselistorder-nodbg.lto.bc', there are 33m allocations.  8.2m</span><br></blockquote><blockquote type="cite"><span>come from std::string allocations in Intrinsic::getName().  Turns out this method only</span><br></blockquote><blockquote type="cite"><span>returns a std::string because it needs to handle overloads, but that is not the common case.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>This adds an overload of getName which just returns a StringRef when there are no overloads</span><br></blockquote><blockquote type="cite"><span>and so saves on the allocations.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>Modified:</span><br></blockquote><blockquote type="cite"><span>     llvm/trunk/include/llvm/IR/Intrinsics.h</span><br></blockquote><blockquote type="cite"><span>     llvm/trunk/lib/IR/Function.cpp</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>Modified: llvm/trunk/include/llvm/IR/Intrinsics.h</span><br></blockquote><blockquote type="cite"><span>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Intrinsics.h?rev=279113&r1=279112&r2=279113&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Intrinsics.h?rev=279113&r1=279112&r2=279113&view=diff</a></span><br></blockquote><blockquote type="cite"><span>==============================================================================</span><br></blockquote><blockquote type="cite"><span>--- llvm/trunk/include/llvm/IR/Intrinsics.h (original)</span><br></blockquote><blockquote type="cite"><span>+++ llvm/trunk/include/llvm/IR/Intrinsics.h Thu Aug 18 13:30:54 2016</span><br></blockquote><blockquote type="cite"><span>@@ -45,7 +45,10 @@ namespace Intrinsic {</span><br></blockquote><blockquote type="cite"><span>    };</span><br></blockquote><blockquote type="cite"><span>      /// Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".</span><br></blockquote><blockquote type="cite"><span>-  std::string getName(ID id, ArrayRef<Type*> Tys = None);</span><br></blockquote><blockquote type="cite"><span>+  StringRef getName(ID id);</span><br></blockquote><blockquote type="cite"><span>+</span><br></blockquote><blockquote type="cite"><span>+  /// Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".</span><br></blockquote><blockquote type="cite"><span>+  std::string getName(ID id, ArrayRef<Type*> Tys);</span><br></blockquote><span>Can you add clarifying comments to explain when each should be used?</span><br></div></blockquote><div style="direction: inherit;">Sure. Can do.</div><blockquote type="cite"><div><blockquote type="cite"><span>      /// Return the function type for an intrinsic.</span><br></blockquote><blockquote type="cite"><span>    FunctionType *getType(LLVMContext &Context, ID id,</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>Modified: llvm/trunk/lib/IR/Function.cpp</span><br></blockquote><blockquote type="cite"><span>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Function.cpp?rev=279113&r1=279112&r2=279113&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Function.cpp?rev=279113&r1=279112&r2=279113&view=diff</a></span><br></blockquote><blockquote type="cite"><span>==============================================================================</span><br></blockquote><blockquote type="cite"><span>--- llvm/trunk/lib/IR/Function.cpp (original)</span><br></blockquote><blockquote type="cite"><span>+++ llvm/trunk/lib/IR/Function.cpp Thu Aug 18 13:30:54 2016</span><br></blockquote><blockquote type="cite"><span>@@ -551,6 +551,11 @@ static std::string getMangledTypeStr(Typ</span><br></blockquote><blockquote type="cite"><span>    return Result;</span><br></blockquote><blockquote type="cite"><span>  }</span><br></blockquote><blockquote type="cite"><span>  +StringRef Intrinsic::getName(ID id) {</span><br></blockquote><blockquote type="cite"><span>+  assert(id < num_intrinsics && "Invalid intrinsic ID!");</span><br></blockquote><blockquote type="cite"><span>+  return IntrinsicNameTable[id];</span><br></blockquote><span>Can we add an assert that this intrinsic is not overloaded?</span><br></div></blockquote><div style="direction: inherit;">Good idea. I'll add that too.</div><div style="direction: inherit;"><br></div><div style="direction: inherit;">Cheers</div><div style="direction: inherit;">Pete</div><blockquote type="cite"><div><blockquote type="cite"><span>+}</span><br></blockquote><blockquote type="cite"><span>+</span><br></blockquote><blockquote type="cite"><span>  std::string Intrinsic::getName(ID id, ArrayRef<Type*> Tys) {</span><br></blockquote><blockquote type="cite"><span>    assert(id < num_intrinsics && "Invalid intrinsic ID!");</span><br></blockquote><blockquote type="cite"><span>    std::string Result(IntrinsicNameTable[id]);</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>_______________________________________________</span><br></blockquote><blockquote type="cite"><span>llvm-commits mailing list</span><br></blockquote><blockquote type="cite"><span><a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a></span><br></blockquote><blockquote type="cite"><span><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a></span><br></blockquote><span></span><br><span></span><br></div></blockquote></body></html>