[PATCH] D22782: Added 'inline' attribute to __init to inline the basic_string's constructor

Laxman Sole via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 25 14:41:38 PDT 2016


laxmansole created this revision.
laxmansole added reviewers: mclow.lists, howard.hinnant.
laxmansole added subscribers: hiraditya, sebpop, laxmansole, llvm-commits, flyingforyou, evandro.

basic_string's constructor calls __init which was not getting inlined.
This prevented optimization of 'const string' as __init would appear as a call in between a string's def and use.

Worked in collaboration with Aditya Kumar.

https://reviews.llvm.org/D22782

Files:
  libcxx/include/string

Index: libcxx/include/string
===================================================================
--- libcxx/include/string
+++ libcxx/include/string
@@ -2008,6 +2008,7 @@
 }
 
 template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
 void
 basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz, size_type __reserve)
 {
@@ -2032,6 +2033,7 @@
 }
 
 template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
 void
 basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz)
 {
@@ -2169,6 +2171,7 @@
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
 void
 basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c)
 {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22782.65424.patch
Type: text/x-patch
Size: 858 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160725/6f51eaf7/attachment.bin>


More information about the llvm-commits mailing list