[cfe-commits] r94753 - in /cfe/trunk/lib/CodeGen: CGDebugInfo.cpp CGDebugInfo.h

Devang Patel dpatel at apple.com
Thu Jan 28 14:57:27 PST 2010


On Jan 28, 2010, at 2:18 PM, Chris Lattner wrote:

> On Jan 28, 2010, at 10:21 AM, Devang Patel wrote:
>> Author: dpatel
>> Date: Thu Jan 28 12:21:00 2010
>> New Revision: 94753
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=94753&view=rev
>> Log:
>> s/FunctionNames/DebugInfoNames/g
> 
> Hi devang,
> 
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jan 28 12:21:00 2010
>> @@ -78,7 +78,7 @@
>>  std::string NS = FD->getNameAsString();
>> 
>>  // Copy this name on the side and use its reference.
>> -  char *StrPtr = FunctionNames.Allocate<char>(NS.length());
>> +  char *StrPtr = DebugInfoNames.Allocate<char>(NS.length());
>>  memcpy(StrPtr, NS.data(), NS.length());
>>  return llvm::StringRef(StrPtr, NS.length());
> 
> 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?

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>"

-
Devang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100128/16cb67da/attachment.html>


More information about the cfe-commits mailing list