re PR lto/62026 (Crash in lto_get_decl_name_mapping)
authorJan Hubicka <hubicka@ucw.cz>
Wed, 15 Oct 2014 17:01:08 +0000 (19:01 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Wed, 15 Oct 2014 17:01:08 +0000 (17:01 +0000)
PR lto/62026
* lto/pr62026.C: New testcase.

* cgraphclones.c (duplicate_thunk_for_node): Get body to have args
to duplicate.
* lto-streamer-out.c (lto_output): Handle correctly thunks that was born
at WPA time.

From-SVN: r216278

gcc/ChangeLog
gcc/cgraphclones.c
gcc/lto-streamer-out.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lto/pr62026.C [new file with mode: 0644]

index 8eb654c0a4bda5cbd7eb3636d2262f6302890c04..5ba303dc5603b4822e77a725157b1e26af27600a 100644 (file)
@@ -1,3 +1,11 @@
+2014-10-15  Jan Hubicka  <hubicka@ucw.cz>
+
+       PR lto/62026
+       * cgraphclones.c (duplicate_thunk_for_node): Get body to have args
+       to duplicate.
+       * lto-streamer-out.c (lto_output): Handle correctly thunks that was born
+       at WPA time.
+
 2014-10-15  Vladimir Makarov  <vmakarov@redhat.com>
 
        PR rtl-optimization/63448
index c487c13f3db277b56f4ddbaaf4d9b53e5aa735ff..71b9269f984ffd194184e11de163292d88a8d7e1 100644 (file)
@@ -295,6 +295,9 @@ duplicate_thunk_for_node (cgraph_node *thunk, cgraph_node *node)
   if (thunk_of->thunk.thunk_p)
     node = duplicate_thunk_for_node (thunk_of, node);
 
+  if (!DECL_ARGUMENTS (thunk->decl))
+    thunk->get_body ();
+
   cgraph_edge *cs;
   for (cs = node->callers; cs; cs = cs->next_caller)
     if (cs->caller->thunk.thunk_p
index dad751b982544c22bc68699b56dde9eeb6632a4f..6d1384f21430845a4f36bb77f5f53e9099777818 100644 (file)
@@ -2249,7 +2249,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_or_variable (node);
index 0c3e540c69b5e2dac61655e869cd6794bf40bf23..471cd7712beece8a04953bedf0ab79073bcf23f5 100644 (file)
@@ -1,3 +1,8 @@
+2014-10-15  Jan Hubicka  <hubicka@ucw.cz>
+
+       PR lto/62026
+       * lto/pr62026.C: New testcase.
+
 2014-10-15  Vladimir Makarov  <vmakarov@redhat.com>
 
        PR rtl-optimization/63448
diff --git a/gcc/testsuite/g++.dg/lto/pr62026.C b/gcc/testsuite/g++.dg/lto/pr62026.C
new file mode 100644 (file)
index 0000000..63766a8
--- /dev/null
@@ -0,0 +1,22 @@
+// { dg-lto-do link }
+// { dg-lto-options {{-flto -O3 -r -nostdlib}} }
+class C;
+class F {
+  virtual C m_fn1();
+};
+class C {
+ public:
+  virtual int *m_fn3(int);
+};
+class G : F, C {
+  int offsets;
+  int *m_fn3(int);
+};
+C *a;
+int *G::m_fn3(int) {
+  if (offsets) return 0;
+}
+
+void fn1() {
+  for (;;) a->m_fn3(0);
+}