https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62026
--- Comment #14 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
I am testing the following for 4.9-branch:
Index: cgraphclones.c
===================================================================
--- cgraphclones.c (revision 215890)
+++ cgraphclones.c (working copy)
@@ -310,6 +310,8 @@ duplicate_thunk_for_node (cgraph_node *t
if (thunk_of->thunk.thunk_p)
node = duplicate_thunk_for_node (thunk_of, node);
+ cgraph_get_body (thunk);
+
struct cgraph_edge *cs;
for (cs = node->callers; cs; cs = cs->next_caller)
if (cs->caller->thunk.thunk_p
Index: lto-streamer-out.c
===================================================================
--- lto-streamer-out.c (revision 215890)
+++ lto-streamer-out.c (working copy)
@@ -2077,7 +2077,10 @@ lto_output (void)
#endif
decl_state = lto_new_out_decl_state ();
lto_push_out_decl_state (decl_state);
- if (gimple_has_body_p (node->decl) || !flag_wpa)
+ if (gimple_has_body_p (node->decl) || !flag_wpa
+ /* Thunks have no body but they may be synthetized
+ at WPA time. */
+ || DECL_ARGUMENTS (node->decl))
output_function (node);
else
copy_function (node);