<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jan 28, 2010, at 2:18 PM, Chris Lattner wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>On Jan 28, 2010, at 10:21 AM, Devang Patel wrote:<br><blockquote type="cite">Author: dpatel<br></blockquote><blockquote type="cite">Date: Thu Jan 28 12:21:00 2010<br></blockquote><blockquote type="cite">New Revision: 94753<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=94753&view=rev">http://llvm.org/viewvc/llvm-project?rev=94753&view=rev</a><br></blockquote><blockquote type="cite">Log:<br></blockquote><blockquote type="cite">s/FunctionNames/DebugInfoNames/g<br></blockquote><br>Hi devang,<br><br><blockquote type="cite">+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jan 28 12:21:00 2010<br></blockquote><blockquote type="cite">@@ -78,7 +78,7 @@<br></blockquote><blockquote type="cite">  std::string NS = FD->getNameAsString();<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">  // Copy this name on the side and use its reference.<br></blockquote><blockquote type="cite">-  char *StrPtr = FunctionNames.Allocate<char>(NS.length());<br></blockquote><blockquote type="cite">+  char *StrPtr = DebugInfoNames.Allocate<char>(NS.length());<br></blockquote><blockquote type="cite">  memcpy(StrPtr, NS.data(), NS.length());<br></blockquote><blockquote type="cite">  return llvm::StringRef(StrPtr, NS.length());<br></blockquote><br>This seems like a really inefficient way to do this.  getNameAsString is not efficient because it returns an std::string, and each call to this function allocates and leaks (into the bumppointer allocator) the string.  Why not just use a StringSet to unique the strings and provide a stable version of the name?<font class="Apple-style-span" color="#000000"><font class="Apple-style-span" color="#144FAE"><br></font></font></div></blockquote><br></div><div>This routine is used when string name has to be constructed. getNameAsString() is one standard way to get "~A" for a destructor. I am reusing same bumpointer allocator for vtable names which are constructed as "_vptr$<className>"</div><div><br></div><div>-</div><div>Devang</div></body></html>