diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a0d6e785bbe1..07cea556aa2a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2010-09-21 Kai Tietz <kai.tietz@onevision.com> + + PR target/45694 + * config/i386/i386.c (ix86_expand_prologue): Save r10 in case that + static chain-register is used for 64-bit. + 2010-09-21 Richard Guenther <rguenther@suse.de> * dwarf2out.c (is_cu_die): New function. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index de1564afb946..4501efb047ba 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -9692,19 +9692,27 @@ ix86_expand_prologue (void) } else { - rtx eax = gen_rtx_REG (Pmode, AX_REG); - bool eax_live; + rtx eax = gen_rtx_REG (Pmode, AX_REG);; + rtx r10 = NULL; + bool eax_live = false; + bool r10_live = false; - if (cfun->machine->call_abi == MS_ABI) - eax_live = false; - else - eax_live = ix86_eax_live_at_start_p (); + if (TARGET_64BIT) + r10_live = (DECL_STATIC_CHAIN (current_function_decl) != 0); + if (!TARGET_64BIT_MS_ABI) + eax_live = ix86_eax_live_at_start_p (); if (eax_live) { emit_insn (gen_push (eax)); allocate -= UNITS_PER_WORD; } + if (r10_live) + { + r10 = gen_rtx_REG (Pmode, R10_REG); + emit_insn (gen_push (r10)); + allocate -= UNITS_PER_WORD; + } emit_move_insn (eax, GEN_INT (allocate)); @@ -9720,10 +9728,17 @@ ix86_expand_prologue (void) } m->fs.sp_offset += allocate; - if (eax_live) + if (r10_live && eax_live) + { + t = choose_baseaddr (m->fs.sp_offset - allocate); + emit_move_insn (r10, gen_frame_mem (Pmode, t)); + t = choose_baseaddr (m->fs.sp_offset - allocate - UNITS_PER_WORD); + emit_move_insn (eax, gen_frame_mem (Pmode, t)); + } + else if (eax_live || r10_live) { t = choose_baseaddr (m->fs.sp_offset - allocate); - emit_move_insn (eax, gen_frame_mem (Pmode, t)); + emit_move_insn ((eax_live ? eax : r10), gen_frame_mem (Pmode, t)); } } gcc_assert (m->fs.sp_offset == frame.stack_pointer_offset);