===================================================================
@@ -6668,20 +6668,21 @@ s390_mainpool_start (void)
for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
{
+ /* If the base register is call-clobbered, output the initializing
+ instruction at the start of the function. */
+ if (!pool->pool_insn
+ && NONDEBUG_INSN_P (insn)
+ && cfun->machine->base_reg
+ && call_really_used_regs[REGNO (cfun->machine->base_reg)])
+ pool->pool_insn
+ = emit_insn_before (gen_main_pool (cfun->machine->base_reg), insn);
+
if (NONJUMP_INSN_P (insn)
&& GET_CODE (PATTERN (insn)) == SET
&& GET_CODE (SET_SRC (PATTERN (insn))) == UNSPEC_VOLATILE
&& XINT (SET_SRC (PATTERN (insn)), 1) == UNSPECV_MAIN_POOL)
{
- /* There might be two main_pool instructions if base_reg
- is call-clobbered; one for shrink-wrapped code and one
- for the rest. We want to keep the first. */
- if (pool->pool_insn)
- {
- insn = PREV_INSN (insn);
- delete_insn (NEXT_INSN (insn));
- continue;
- }
+ gcc_assert (!pool->pool_insn);
pool->pool_insn = insn;
}
@@ -8643,11 +8644,6 @@ s390_early_mach (void)
/* Re-compute register info. */
s390_register_info ();
- /* If we're using a base register, ensure that it is always valid for
- the first non-prologue instruction. */
- if (cfun->machine->base_reg)
- emit_insn_at_entry (gen_main_pool (cfun->machine->base_reg));
-
/* Annotate all constant pool references to let the scheduler know
they implicitly use the base register. */
for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
@@ -8728,7 +8724,8 @@ s390_emit_prologue (void)
/* Dummy insn to mark literal pool slot. */
- if (cfun->machine->base_reg)
+ if (cfun->machine->base_reg
+ && !call_really_used_regs[REGNO (cfun->machine->base_reg)])
emit_insn (gen_main_pool (cfun->machine->base_reg));
offset = cfun_frame_layout.f0_offset;
@@ -9183,6 +9180,19 @@ s390_emit_epilogue (bool sibcall)
}
}
+/* Implement TARGET_EXTRA_LIVE_ON_ENTRY. */
+
+static void
+s300_extra_live_on_entry (bitmap regs)
+{
+ /* If the base register is call-clobbered, the main_pool instruction
+ should go at the beginning of the function. We only add it during
+ md_reorg. */
+ if (cfun->machine->base_reg
+ && call_really_used_regs[REGNO (cfun->machine->base_reg)])
+ bitmap_set_bit (regs, REGNO (cfun->machine->base_reg));
+}
+
/* Implement TARGET_SET_UP_BY_PROLOGUE. */
static void
@@ -12230,6 +12240,9 @@ #define TARGET_ATTRIBUTE_TABLE s390_attr
#undef TARGET_CAN_INLINE_P
#define TARGET_CAN_INLINE_P s390_can_inline_p
+#undef TARGET_EXTRA_LIVE_ON_ENTRY
+#define TARGET_EXTRA_LIVE_ON_ENTRY s300_extra_live_on_entry
+
#undef TARGET_SET_UP_BY_PROLOGUE
#define TARGET_SET_UP_BY_PROLOGUE s300_set_up_by_prologue