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

Sean Silva chisophugis at gmail.com
Fri May 29 18:56:10 PDT 2015


On Thu, May 28, 2015 at 8:53 PM, Yaron Keren <yaron.keren at gmail.com> wrote:

> grow() does the power of 2 thing, probably to avoid quadratic behaviour
>
> http://llvm.org/klaus/llvm/blob/master/include/llvm/ADT/SmallVector.h#L-248
>

That's different (it is a dynamic thing). I was talking about something
static.

-- Sean Silva


>
>
>
> 2015-05-29 2:00 GMT+03:00 Sean Silva <chisophugis at gmail.com>:
>
>>
>>
>> On Thu, May 28, 2015 at 2:48 AM, Benjamin Kramer <benny.kra at gmail.com>
>> wrote:
>>
>>> 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.
>>>
>>
>> Hmm.. not sure what I was remembering. I seem to recall SmallVector would
>> always round the buffer size to a power of 2, but I guess not:
>> http://llvm.org/klaus/llvm/blob/master/include/llvm/ADT/SmallVector.h#L-843
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_klaus_llvm_blob_master_include_llvm_ADT_SmallVector.h-23L-2D843&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=9Q11tH9G2gqowmFtkwbMQvXQv-nLf4pqSkShmPhoQ2k&s=ZmHY7mQg1FsH1YGgmlOicA8YRpZ67UevR-BxlNMGVLE&e=>
>>
>>
>> -- Sean Silva
>>
>>
>>> 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
>>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D238104-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=9Q11tH9G2gqowmFtkwbMQvXQv-nLf4pqSkShmPhoQ2k&s=68kVpHm58qHqnifgI4sZAKvLwQHhJiTDfkcRB2NJX_0&e=>
>>> >>> 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
>>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_Target_TargetMachine.cpp-3Frev-3D238104-26r1-3D238103-26r2-3D238104-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=9Q11tH9G2gqowmFtkwbMQvXQv-nLf4pqSkShmPhoQ2k&s=cyhaMAOkJrpQl0TWmHbwVXKICaMpb028BvNSV3IfxZw&e=>
>>> >>>
>>> >>>
>>> ==============================================================================
>>> >>> --- 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
>>> >>
>>> >>
>>> >
>>>
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150529/e746c0c1/attachment.html>


More information about the llvm-commits mailing list