From: Bernd Schmidt <bernds@codesourcery.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: 'Richard Sandiford' <richard.sandiford@linaro.org>
Subject: Add unwind information to mips epilogues
Date: Wed, 31 Aug 2011 19:57:00 -0000 [thread overview]
Message-ID: <4E5E6E6D.8050905@codesourcery.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 199 bytes --]
This is necessary when adding shrink-wrapping; otherwise dwarf2cfi sees
inconsistent information and aborts.
Tested on mips64-elf together with the rest of the shrink-wrapping
patches. Ok?
Bernd
[-- Attachment #2: mipsep.diff --]
[-- Type: text/plain, Size: 3528 bytes --]
* config/mips/mips.c (cfa_restores): New static variable.
(mips_restore_reg): Add to it.
(mips_expand_epilogue): Initialize it. Annotate RTL to ensure
dwarf2cfi sees the effects of the epilogue.
Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c (revision 178135)
+++ gcc/config/mips/mips.c (working copy)
@@ -10227,7 +10227,10 @@ mips_expand_prologue (void)
emit_insn (gen_blockage ());
}
\f
-/* Emit instructions to restore register REG from slot MEM. */
+static rtx cfa_restores = NULL_RTX;
+
+/* Emit instructions to restore register REG from slot MEM. Also update
+ the cfa_restores list. */
static void
mips_restore_reg (rtx reg, rtx mem)
@@ -10238,6 +10241,7 @@ mips_restore_reg (rtx reg, rtx mem)
reg = gen_rtx_REG (GET_MODE (reg), GP_REG_FIRST + 7);
mips_emit_save_slot_move (reg, mem, MIPS_EPILOGUE_TEMP (GET_MODE (reg)));
+ cfa_restores = alloc_reg_note (REG_CFA_RESTORE, reg, cfa_restores);
}
/* Emit any instructions needed before a return. */
@@ -10268,6 +10272,8 @@ mips_expand_epilogue (bool sibcall_p)
HOST_WIDE_INT step1, step2;
rtx base, target, insn;
+ cfa_restores = NULL_RTX;
+
if (!sibcall_p && mips_can_use_return_insn ())
{
emit_jump_insn (gen_return ());
@@ -10324,12 +10330,26 @@ mips_expand_epilogue (bool sibcall_p)
if (!TARGET_MIPS16)
target = stack_pointer_rtx;
- emit_insn (gen_add3_insn (target, base, adjust));
+ insn = emit_insn (gen_add3_insn (target, base, adjust));
+ if (!frame_pointer_needed && target == stack_pointer_rtx)
+ {
+ RTX_FRAME_RELATED_P (insn) = 1;
+ add_reg_note (insn, REG_CFA_DEF_CFA,
+ plus_constant (stack_pointer_rtx, step2));
+ }
}
/* Copy TARGET into the stack pointer. */
if (target != stack_pointer_rtx)
- mips_emit_move (stack_pointer_rtx, target);
+ {
+ insn = mips_emit_move (stack_pointer_rtx, target);
+ if (!frame_pointer_needed)
+ {
+ add_reg_note (insn, REG_CFA_DEF_CFA,
+ plus_constant (stack_pointer_rtx, step2));
+ RTX_FRAME_RELATED_P (insn) = 1;
+ }
+ }
/* If we're using addressing macros, $gp is implicitly used by all
SYMBOL_REFs. We must emit a blockage insn before restoring $gp
@@ -10393,9 +10413,14 @@ mips_expand_epilogue (bool sibcall_p)
/* If we don't use shoadow register set, we need to update SP. */
if (!cfun->machine->use_shadow_register_set_p && step2 > 0)
- emit_insn (gen_add3_insn (stack_pointer_rtx,
- stack_pointer_rtx,
- GEN_INT (step2)));
+ {
+ insn = emit_insn (gen_add3_insn (stack_pointer_rtx,
+ stack_pointer_rtx,
+ GEN_INT (step2)));
+ REG_NOTES (insn) = cfa_restores;
+ RTX_FRAME_RELATED_P (insn) = 1;
+ add_reg_note (insn, REG_CFA_DEF_CFA, stack_pointer_rtx);
+ }
/* Move to COP0 Status. */
emit_insn (gen_cop0_move (gen_rtx_REG (SImode, COP0_STATUS_REG_NUM),
@@ -10405,9 +10430,14 @@ mips_expand_epilogue (bool sibcall_p)
{
/* Deallocate the final bit of the frame. */
if (step2 > 0)
- emit_insn (gen_add3_insn (stack_pointer_rtx,
- stack_pointer_rtx,
- GEN_INT (step2)));
+ {
+ insn = emit_insn (gen_add3_insn (stack_pointer_rtx,
+ stack_pointer_rtx,
+ GEN_INT (step2)));
+ REG_NOTES (insn) = cfa_restores;
+ RTX_FRAME_RELATED_P (insn) = 1;
+ add_reg_note (insn, REG_CFA_DEF_CFA, stack_pointer_rtx);
+ }
}
}
next reply other threads:[~2011-08-31 17:27 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-31 19:57 Bernd Schmidt [this message]
2011-08-31 20:55 ` Richard Sandiford
2011-09-01 17:21 ` Bernd Schmidt
2011-09-01 18:42 ` Richard Sandiford
2011-09-01 19:19 ` Richard Sandiford
2011-09-01 19:25 ` Bernd Schmidt
2011-09-01 19:37 ` Richard Sandiford
[not found] ` <4E5EA981.5010203@codesourcery.com>
2011-09-01 7:49 ` Richard Sandiford
2011-09-05 1:37 ` Richard Henderson
2011-09-05 1:51 ` Richard Henderson
2011-09-05 8:07 ` Richard Sandiford
2011-09-06 3:31 ` Richard Henderson
2011-09-06 8:05 ` Richard Sandiford
2011-09-07 10:38 ` Bernd Schmidt
2011-09-07 11:26 ` Richard Guenther
2011-09-07 11:47 ` Joseph S. Myers
2011-09-07 12:18 ` Jakub Jelinek
2011-09-07 15:52 ` Bernd Schmidt
2011-09-08 14:16 ` Richard Sandiford
2011-09-08 14:19 ` Richard Sandiford
2011-09-08 15:32 ` Bernd Schmidt
2011-09-08 15:41 ` Richard Sandiford
2011-09-08 15:58 ` Richard Henderson
2011-09-08 18:00 ` Richard Sandiford
2011-09-09 12:53 ` Bernd Schmidt
2011-09-10 14:44 ` Richard Sandiford
2011-09-11 12:41 ` Richard Sandiford
2011-09-12 14:55 ` Bernd Schmidt
2011-09-12 20:04 ` Richard Sandiford
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E5E6E6D.8050905@codesourcery.com \
--to=bernds@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.sandiford@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).