[llvm-commits] [llvm] r80710 - in /llvm/trunk/lib: CodeGen/AsmPrinter/DwarfException.cpp Target/ARM/AsmPrinter/ARMAsmPrinter.cpp

Chris Lattner clattner at apple.com
Wed Sep 2 20:17:57 PDT 2009


On Sep 2, 2009, at 8:10 PM, Daniel Dunbar wrote:

> Hi Jim,
>
> Actually 256 is a better choice. Unless we actively care about the
> stack size in some case, 256 is a nice "idiomatic" choice, because of
> the interaction with raw_svector_ostream.
>
> The particular issue is that raw_ostream expects to have a certain
> size buffer (64 bytes, currently), and so the vector will get
> immediately resized (malloc'd) if it is smaller than that. I'm open to
> suggestions about how to improve this API though (some obvious options
> are make raw_ostream's required buffer size smaller, or make
> raw_svector_ostream give a compile time assertion when passed a vector
> that is provably too small).
>
> Given the current implementation, 128 is the smallest "safe" choice
> which will almost always avoid allocation, but since all uses already
> use 256 I was hoping we could make the API "reasonable" by idiom.

What am I missing here Daniel?  The string being constructed is sizeof 
(PrivateGlobalPrefix) which is a max of 2 + sizeof("_LSDA_")  + utostr 
(Asm->getFunctionNumber()).size()

This isn't very big.

-Chris

>
> - Daniel
>
> On Tue, Sep 1, 2009 at 11:55 AM, Jim Grosbach<grosbach at apple.com>  
> wrote:
>> Author: grosbach
>> Date: Tue Sep  1 13:55:08 2009
>> New Revision: 80710
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=80710&view=rev
>> Log:
>> reduce size of SmallString to something more reasonable
>>
>> Modified:
>>    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp
>>    llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
>>
>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp?rev=80710&r1=80709&r2=80710&view=diff
>>
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Tue Sep  1  
>> 13:55:08 2009
>> @@ -601,7 +601,7 @@
>>
>>   EmitLabel("exception", SubprogramCount);
>>   if (MAI->getExceptionHandlingType() == ExceptionHandling::SjLj) {
>> -    SmallString<256> LSDAName;
>> +    SmallString<16> LSDAName;
>>     raw_svector_ostream(LSDAName) << MAI->getPrivateGlobalPrefix() <<
>>       "_LSDA_" << Asm->getFunctionNumber();
>>     O << LSDAName.str() << ":\n";
>>
>> Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=80710&r1=80709&r2=80710&view=diff
>>
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original)
>> +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Tue Sep   
>> 1 13:55:08 2009
>> @@ -160,7 +160,7 @@
>>       std::string Name;
>>
>>       if (ACPV->isLSDA()) {
>> -        SmallString<256> LSDAName;
>> +        SmallString<16> LSDAName;
>>         raw_svector_ostream(LSDAName) << MAI->getPrivateGlobalPrefix 
>> () <<
>>           "_LSDA_" << getFunctionNumber();
>>         Name = LSDAName.str();
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list