On Aug 29, 2013, at 5:07 PM, David Blaikie <[email protected]> wrote:

> On Thu, Aug 29, 2013 at 1:56 PM, Howard Hinnant <[email protected]> wrote:
>> Author: hhinnant
>> Date: Thu Aug 29 15:56:53 2013
>> New Revision: 189610
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=189610&view=rev
>> Log:
>> Turn off extern templates for most uses.  It is causing more problems than 
>> it is worth.  The extern templates will still be built into the dylib, 
>> mainly for ABI stability purposes.  And the client can still turn these back 
>> on with a #define if desire.  This fixes 
>> http://llvm.org/bugs/show_bug.cgi?id=17027.  However there's no associated 
>> test for the test suite because http://llvm.org/bugs/show_bug.cgi?id=17027 
>> needs mismatched dylib and headers to fire.
> 
> For what it's worth, extern templates can, in some cases, drastically
> reduce the size of debug info (and thus reduce link times, etc) in
> client code. This only, currently, applies to types with vtables (such
> as iostreams) but can cause GCC and (recently) Clang to omit the
> definition of these types in TUs that don't emit the vtable, relying
> on the type debug info to be emitted in the TU with the vtable.
> 
> The most awesome/horrifying example of this was in the simple TU:
> 
> #include <fstream>
> 
> int main() {
>  std::ifstream x;
>  return x.bad(); // make sure we've used member functions, etc
> }
> 
> The debug info that Clang & GCC emit for this TU is now /tiny/, the
> ifstream typedef, a declaration of the basic_ifstream template &
> nothing more. Without the extern template you get /lots/ of debug info
> here.

Thanks for the feedback.  If really needed I can revert this.  In your example 
I'm measuring a 11% code size increase at -O3.

Howard

> 
>> 
>> Modified:
>>    libcxx/trunk/include/__config
>>    libcxx/trunk/src/algorithm.cpp
>>    libcxx/trunk/src/ios.cpp
>>    libcxx/trunk/src/locale.cpp
>>    libcxx/trunk/src/string.cpp
>>    libcxx/trunk/src/valarray.cpp
>> 
>> Modified: libcxx/trunk/include/__config
>> URL: 
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=189610&r1=189609&r2=189610&view=diff
>> ==============================================================================
>> --- libcxx/trunk/include/__config (original)
>> +++ libcxx/trunk/include/__config Thu Aug 29 15:56:53 2013
>> @@ -538,7 +538,7 @@ template <unsigned> struct __static_asse
>> #endif
>> 
>> #ifndef _LIBCPP_EXTERN_TEMPLATE
>> -#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
>> +#define _LIBCPP_EXTERN_TEMPLATE(...)
>> #endif
>> 
>> #ifndef _LIBCPP_EXTERN_TEMPLATE2
>> 
>> Modified: libcxx/trunk/src/algorithm.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/algorithm.cpp?rev=189610&r1=189609&r2=189610&view=diff
>> ==============================================================================
>> --- libcxx/trunk/src/algorithm.cpp (original)
>> +++ libcxx/trunk/src/algorithm.cpp Thu Aug 29 15:56:53 2013
>> @@ -7,6 +7,7 @@
>> //
>> //===----------------------------------------------------------------------===//
>> 
>> +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
>> #include "algorithm"
>> #include "random"
>> #include "mutex"
>> 
>> Modified: libcxx/trunk/src/ios.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/ios.cpp?rev=189610&r1=189609&r2=189610&view=diff
>> ==============================================================================
>> --- libcxx/trunk/src/ios.cpp (original)
>> +++ libcxx/trunk/src/ios.cpp Thu Aug 29 15:56:53 2013
>> @@ -7,6 +7,8 @@
>> //
>> //===----------------------------------------------------------------------===//
>> 
>> +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
>> +
>> #include "ios"
>> #include "streambuf"
>> #include "istream"
>> 
>> Modified: libcxx/trunk/src/locale.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/locale.cpp?rev=189610&r1=189609&r2=189610&view=diff
>> ==============================================================================
>> --- libcxx/trunk/src/locale.cpp (original)
>> +++ libcxx/trunk/src/locale.cpp Thu Aug 29 15:56:53 2013
>> @@ -7,6 +7,8 @@
>> //
>> //===----------------------------------------------------------------------===//
>> 
>> +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
>> +
>> // On Solaris, we need to define something to make the C99 parts of 
>> localeconv
>> // visible.
>> #ifdef __sun__
>> 
>> Modified: libcxx/trunk/src/string.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/string.cpp?rev=189610&r1=189609&r2=189610&view=diff
>> ==============================================================================
>> --- libcxx/trunk/src/string.cpp (original)
>> +++ libcxx/trunk/src/string.cpp Thu Aug 29 15:56:53 2013
>> @@ -7,6 +7,8 @@
>> //
>> //===----------------------------------------------------------------------===//
>> 
>> +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
>> +
>> #include "string"
>> #include "cstdlib"
>> #include "cwchar"
>> 
>> Modified: libcxx/trunk/src/valarray.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/valarray.cpp?rev=189610&r1=189609&r2=189610&view=diff
>> ==============================================================================
>> --- libcxx/trunk/src/valarray.cpp (original)
>> +++ libcxx/trunk/src/valarray.cpp Thu Aug 29 15:56:53 2013
>> @@ -7,6 +7,8 @@
>> //
>> //===----------------------------------------------------------------------===//
>> 
>> +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
>> +
>> #include "valarray"
>> 
>> _LIBCPP_BEGIN_NAMESPACE_STD
>> 
>> 
>> _______________________________________________
>> cfe-commits mailing list
>> [email protected]
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to