[PATCH] D106186: Avoid keeping internal string_views in Twine.

Sterling Augustine via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 16 13:27:57 PDT 2021


saugustine created this revision.
saugustine added reviewers: dblaikie, tstellar, dexonsmith.
Herald added a subscriber: hiraditya.
saugustine requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This is a follow-up to https://reviews.llvm.org/D103935

A Twine's internal layout should not depend on which version of the
C++ standard is in use. Dynamically linking binaries compiled with two
different layouts (eg, --std=c++14 vs --std=c++17) ends up
problematic.

This change avoids that issue by immediately converting a
string_view to a StringRef at the cost of an extra eight-bytes
in Twine, and certain copies and dereferences to StringRefs that
hadn't happened prior to this change.

I do believe the optimizer can elide almost all the extra nominal
work via inlining and the like.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106186

Files:
  llvm/include/llvm/ADT/Twine.h
  llvm/lib/Support/Twine.cpp
  llvm/unittests/ADT/TwineTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106186.359431.patch
Type: text/x-patch
Size: 4962 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210716/eb6a6611/attachment.bin>


More information about the llvm-commits mailing list