public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Sandra Loosemore <sandra@codesourcery.com>
To: Yao Qi <yao@codesourcery.com>, <gdb-patches@sourceware.org>
Subject: [3/3 patch, nios2] clean up prologue/epilogue detection code, v2
Date: Tue, 25 Nov 2014 00:03:00 -0000	[thread overview]
Message-ID: <5473C73F.1040800@codesourcery.com> (raw)
In-Reply-To: <5473C4BA.2050903@codesourcery.com>

[-- Attachment #1: Type: text/plain, Size: 420 bytes --]

This part of the revised Nios II prologue/epilogue refactoring patch 
fixes the prologue analyzer to handle the multiple stack adjustment 
instructions that GCC may now emit in some cases.  It replaces the test 
that caused analysis to terminate when a second adjustment is found with 
more specific tests that can distinguish between prologue-ish and 
epilogue-ish adjustments.

OK to commit on top of part 1?

-Sandra

[-- Attachment #2: gdb-nios2-prologue-3.log --]
[-- Type: text/x-log, Size: 247 bytes --]

2014-11-24  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/
	* nios2-tdep.c (nios2_analyze_prologue): Replace restriction
	that there can be only one stack adjustment in the prologue
	with tests to detect specific disallowed stack adjustments.

[-- Attachment #3: gdb-nios2-prologue-3.patch --]
[-- Type: text/x-patch, Size: 2148 bytes --]

diff -u b/gdb/nios2-tdep.c b/gdb/nios2-tdep.c
--- b/gdb/nios2-tdep.c
+++ b/gdb/nios2-tdep.c
@@ -842,6 +842,11 @@
 	      cache->reg_saved[NIOS2_SP_REGNUM].addr = -4;
 	    }
 
+	  else if (rc == NIOS2_SP_REGNUM && ra == NIOS2_FP_REGNUM)
+	    /* This is setting SP from FP.  This only happens in the
+	       function epilogue.  */
+	    break;
+
 	  else if (rc != 0)
 	    {
 	      if (value[rb].reg == 0)
@@ -853,13 +858,21 @@
 	      value[rc].offset = value[ra].offset + value[rb].offset;
 	    }
 
-	  prologue_end = pc;
+	  /* The add/move is only considered a prologue instruction
+	     if the destination is SP or FP.  */
+	  if (rc == NIOS2_SP_REGNUM || rc == NIOS2_FP_REGNUM)
+	    prologue_end = pc;
 	}
       
       else if (nios2_match_sub (insn, op, mach, &ra, &rb, &rc))
 	{
 	  /* SUB   rc, ra, rb */
-	  if (rc != 0)
+	  if (rc == NIOS2_SP_REGNUM && rb == NIOS2_SP_REGNUM
+	      && value[rc].reg != 0)
+	    /* If we are decrementing the SP by a non-constant amount,
+	       this is alloca, not part of the prologue.  */
+	    break;
+	  else if (rc != 0)
 	    {
 	      if (value[rb].reg == 0)
 		value[rc].reg = value[ra].reg;
@@ -873,12 +886,13 @@
 	{
 	  /* ADDI    rb, ra, imm */
 
-	  /* The first stack adjustment is part of the prologue.
-	     Any subsequent stack adjustments are either down to
-	     alloca or the epilogue so stop analysing when we hit
-	     them.  */
+	  /* A positive stack adjustment has to be part of the epilogue.  */
 	  if (rb == NIOS2_SP_REGNUM
-	      && (value[rb].offset != 0 || value[ra].reg != NIOS2_SP_REGNUM))
+	      && (imm > 0 || value[ra].reg != NIOS2_SP_REGNUM))
+	    break;
+
+	  /* Likewise restoring SP from FP.  */
+	  else if (rb == NIOS2_SP_REGNUM && ra == NIOS2_FP_REGNUM)
 	    break;
 
 	  if (rb != 0)
@@ -887,7 +901,10 @@
 	      value[rb].offset = value[ra].offset + imm;
 	    }
 
-	  prologue_end = pc;
+	  /* The add is only considered a prologue instruction
+	     if the destination is SP or FP.  */
+	  if (rb == NIOS2_SP_REGNUM || rb == NIOS2_FP_REGNUM)
+	    prologue_end = pc;
 	}
 
       else if (nios2_match_orhi (insn, op, mach, &ra, &rb, &uimm))

  parent reply	other threads:[~2014-11-25  0:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-08 23:01 [patch, nios2] clean up prologue/epilogue detection code Sandra Loosemore
2014-11-11  3:33 ` Yao Qi
2014-11-24 23:52   ` Sandra Loosemore
2014-11-25  0:03     ` [1/3 patch, nios2] clean up prologue/epilogue detection code, v2 Sandra Loosemore
2014-11-25  2:50       ` Yao Qi
2014-11-25  0:03     ` Sandra Loosemore [this message]
2014-11-25  3:00       ` [3/3 " Yao Qi
2014-11-25  0:03     ` [2/3 " Sandra Loosemore
2014-11-25  3:29       ` Yao Qi

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=5473C73F.1040800@codesourcery.com \
    --to=sandra@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=yao@codesourcery.com \
    /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).