[llvm] r238104 - Bump SmallString to the minimum required amount for raw_ostream to avoid allocation.

Benjamin Kramer benny.kra at gmail.com
Thu May 28 02:48:26 PDT 2015


On Thu, May 28, 2015 at 3:25 AM, Sean Silva <chisophugis at gmail.com> wrote:
>
>
> On Wed, May 27, 2015 at 6:24 PM, Sean Silva <chisophugis at gmail.com> wrote:
>>
>> I've always thought that it was confusing that SmallString internally did
>> so much processing on the number you give it to actually choose the buffer
>> size. Maybe we can just static_assert it is a power of 2 so it is always
>> WYSIWYG?
>
>
> (and all the other conditions it does, such as requiring 0 to mean "no
> buffer")

Does it really modify the buffer size internally? I thought it just
forwarded to SmallVector, which shouldn't be restricted to powers of
2.

This commit was about raw_svector_ostream always allocating 128 bytes
when its created, rendering the 60 bytes of inline storage completely
useless. This is very annoying but I have no idea how to fix it.

- Ben

>>
>> On Sat, May 23, 2015 at 10:20 AM, Benjamin Kramer
>> <benny.kra at googlemail.com> wrote:
>>>
>>> Author: d0k
>>> Date: Sat May 23 12:20:53 2015
>>> New Revision: 238104
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=238104&view=rev
>>> Log:
>>> Bump SmallString to the minimum required amount for raw_ostream to avoid
>>> allocation.
>>>
>>> NFC.
>>>
>>> Modified:
>>>     llvm/trunk/lib/Target/TargetMachine.cpp
>>>
>>> Modified: llvm/trunk/lib/Target/TargetMachine.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetMachine.cpp?rev=238104&r1=238103&r2=238104&view=diff
>>>
>>> ==============================================================================
>>> --- llvm/trunk/lib/Target/TargetMachine.cpp (original)
>>> +++ llvm/trunk/lib/Target/TargetMachine.cpp Sat May 23 12:20:53 2015
>>> @@ -185,7 +185,7 @@ void TargetMachine::getNameWithPrefix(Sm
>>>  }
>>>
>>>  MCSymbol *TargetMachine::getSymbol(const GlobalValue *GV, Mangler &Mang)
>>> const {
>>> -  SmallString<60> NameStr;
>>> +  SmallString<128> NameStr;
>>>    getNameWithPrefix(NameStr, GV, Mang);
>>>    const TargetLoweringObjectFile *TLOF = getObjFileLowering();
>>>    return TLOF->getContext().getOrCreateSymbol(NameStr);
>>>
>>>
>>> _______________________________________________
>>> 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