Long compile times due mangling of return types in function templates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As per the Itanium ABI gcc mangles the return types of function templates, so that we can see mangled names like

  _Z1hIiEDTplcl1fIT_EEcl1gIS0_EEEv

which demangle to

  decltype (((f<int>)())+((g<int>)())) h<int>()

In seastar [1] this causes serious compile-time performance problems. Replacing complicated template argument dependent return types improves compile time and object size by around 10%.

What is the reason that the ABI mandates mangling the return type into the function name?

Are there any plans to improve the situation? As it is, certain styles of programming (continuations) can cause names and compile times to explode.


The patch below (replacing return types with auto) gave me about 10% compile time improvement:

--- a/core/future.hh
+++ b/core/future.hh
@@ -460,7 +460,8 @@ private:
     }
template <typename Ret, typename Func, typename Param>
-    futurize_t<Ret> then(Func&& func, Param&& param) noexcept {
+    auto // futurize_t<Ret>
+    then(Func&& func, Param&& param) noexcept {
         using futurator = futurize<Ret>;
         using P = typename futurator::promise_type;
         if (state()->available() && (++future_avail_count % 256)) {
@@ -526,12 +527,14 @@ public:
     }
template <typename Func>
-    futurize_t<std::result_of_t<Func(T&&...)>> then(Func&& func) noexcept {
+    auto // futurize_t<std::result_of_t<Func(T&&...)>>
+    then(Func&& func) noexcept {
         return then<std::result_of_t<Func(T&&...)>>(std::forward<Func>(func), [] (future_state<T...>&& state) { return state.get(); });
     }
template <typename Func>
-    futurize_t<std::result_of_t<Func(future<T...>)>>
+    auto
+    //futurize_t<std::result_of_t<Func(future<T...>)>>
     then_wrapped(Func&& func) noexcept {
         return then<std::result_of_t<Func(future<T...>)>>(std::forward<Func>(func), [] (future_state<T...>&& state) { return future(std::move(state)); });
     }




[1] https://github.com/cloudius-systems/seastar, specifically future::then() in core/future.hh




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux