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

Sean Silva chisophugis at gmail.com
Thu May 28 16:00:12 PDT 2015


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


-- 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
> >>> 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
> >>
> >>
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150528/f0fb8736/attachment.html>


More information about the llvm-commits mailing list