This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] m68k.c: Fix build.


Hi,

Attached is a patch to fix build of the m68k port.

Without this patch, the build fails while building libstdc++.
Consider the following reduced testcase:

class foo
{
public:
  virtual ~foo();
};
class bar : virtual public foo
{
public:
  virtual ~bar();
};
bar::~bar() { }

When we output a thunk, we have the following call sequence.  (I'm
including macros for the sake of explanation.)

  m68k_output_mi_thunk
    final
      final_scan_insn
        notice_update_cc (in m68k.c)
          ADDRESS_REG_P (in m68k.h)
            REGNO_OK_FOR_BASE_P

Notice that REGNO_OK_FOR_BASE_P uses reg_renumber.  During normal
compilation, reg_renumber is set by regclass and kept non-NULL until
final calls free_reg_info.  However, in this thunk compilation, where
we call final by hand, reg_renumber remains NULL, which causes
REGNO_OK_FOR_BASE_P to trigger a segfault.

The patch fixes the problem by temporarily allocating reg_renumber
while m68k_output_mi_thunk calls final.

Tested by building m68k-elf.  OK to apply?

Kazu Hirata

2007-06-12  Kazu Hirata  <kazu@codesourcery.com>

	* config/m68k/m68k.c (m68k_output_mi_thunk): Temporarily
	allocate reg_renumber.

Index: gcc/config/m68k/m68k.c
===================================================================
--- gcc/config/m68k/m68k.c	(revision 125636)
+++ gcc/config/m68k/m68k.c	(working copy)
@@ -4206,7 +4206,12 @@ m68k_output_mi_thunk (FILE *file, tree t
   insn = get_insns ();
   split_all_insns_noflow ();
   final_start_function (insn, file, 1);
+  max_regno = max_reg_num ();
+  reg_renumber = xmalloc (max_regno * sizeof (short));
+  memset (reg_renumber, -1, max_regno * sizeof (short));
   final (insn, file, 1);
+  free (reg_renumber);
+  reg_renumber = 0;
   final_end_function ();
 
   /* Clean up the vars set above.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]