This is an archive of the discontinued LLVM Phabricator instance.

[NFC] Use SmallString instead of std::string for the AttrBuilder
ClosedPublic

Authored by serge-sans-paille on Mar 8 2021, 8:52 AM.

Details

Summary

This avoids a few unnecessary conversion from StringRef to std::string, and a
bunch of extra allocation thanks to the SmallString.

Diff Detail

Event Timeline

serge-sans-paille requested review of this revision.Mar 8 2021, 8:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 8 2021, 8:52 AM
bkramer added a comment.EditedMar 9 2021, 4:58 AM

Do we have some information on how long these attributes typically are? libc++'s std::string has an inline capacity of 22, which is why I've been reluctant to change this so far.

Do we have some information on how long these attributes typically are? libc++'s std::string has an inline capacity of 22, which is why I've been reluctant to change this so far.

Here is what I know fore sure:

When parsing the SQLite amalgametion and counting the number of instructions, which is a fairly stable metric:

perf stat ./bin/clang -w -c sqlite3.c -o/dev/null

I get 6,005,593,103 instructions *before* that patch and 5,974,383,558 instructions *after* the patch.

bkramer accepted this revision.Mar 16 2021, 4:29 AM

Sounds like a good enough improvement to me, thanks for checking.

This revision is now accepted and ready to land.Mar 16 2021, 4:29 AM