public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFC, PATCH ] [DATAFLOW] Validating an address in auto-inc-dec
@ 2007-05-28 21:58 Pranav Bhandarkar
  2007-05-29 18:59 ` Kenneth Zadeck
  0 siblings, 1 reply; 3+ messages in thread
From: Pranav Bhandarkar @ 2007-05-28 21:58 UTC (permalink / raw)
  To: gcc-patches

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

Hi,
I am working on a private port, wherein the constant addition /
subtraction in a post_modify  _must_  be less than a certain value.
For such a check I have defined GO_IF_LEGITIMATE_ADDRESS
appropriately. The problem is that attempt_change in auto-inc-dec
doesnt check if the new address is a valid memory address or not
resulting in an ICE in a later pass.

Therefore I wrote this patch, where in before replacing a memory
address and its modification by a constant by a post_modify, I first
check if the new address expression is going to be a valid expression.

Thanks,
Pranav

ChangeLog:
 * auto-inc-dec.c (attempt_change): Check if new_addr_pat is a
        valid memory address.

[-- Attachment #2: auto-inc-dec-patch --]
[-- Type: application/octet-stream, Size: 577 bytes --]

Index: auto-inc-dec.c
===================================================================
--- auto-inc-dec.c	(revision 123253)
+++ auto-inc-dec.c	(working copy)
@@ -540,6 +540,13 @@
       return false;
     }
 
+  if (! memory_address_p (mode, new_addr_pat))
+    {
+      if (dump_file)
+	fprintf (dump_file, "Not a valid address\n");
+      return false;
+    }
+
   /* Jump thru a lot of hoops to keep the attributes up to date.  We
      do not want to call one of the change address variants that take
      an offset even though we know the offset in many cases.  These

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC, PATCH ] [DATAFLOW] Validating an address in auto-inc-dec
  2007-05-28 21:58 [RFC, PATCH ] [DATAFLOW] Validating an address in auto-inc-dec Pranav Bhandarkar
@ 2007-05-29 18:59 ` Kenneth Zadeck
  2007-05-29 22:41   ` Pranav Bhandarkar
  0 siblings, 1 reply; 3+ messages in thread
From: Kenneth Zadeck @ 2007-05-29 18:59 UTC (permalink / raw)
  To: Pranav Bhandarkar; +Cc: gcc-patches

I talked to Ian Taylor and David Edelsohn about this.  
No one can see the reason for this patch assuming that you have a
properly written port.

Immediately after the point where you would like to insert the the
memory_address_p there is a call to validate_change.  If your port is
written correctly, that call should see the mem reference in the new
part of the insn and call memory_address_p on it.  This is what
validate_change does for a living.

Kenny

> Hi,
> I am working on a private port, wherein the constant addition /
> subtraction in a post_modify  _must_  be less than a certain value.
> For such a check I have defined GO_IF_LEGITIMATE_ADDRESS
> appropriately. The problem is that attempt_change in auto-inc-dec
> doesnt check if the new address is a valid memory address or not
> resulting in an ICE in a later pass.
> 
> Therefore I wrote this patch, where in before replacing a memory
> address and its modification by a constant by a post_modify, I first
> check if the new address expression is going to be a valid expression.
> 
> Thanks,
> Pranav
> 
> ChangeLog:
>  * auto-inc-dec.c (attempt_change): Check if new_addr_pat is a
>         valid memory address.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC, PATCH ] [DATAFLOW] Validating an address in auto-inc-dec
  2007-05-29 18:59 ` Kenneth Zadeck
@ 2007-05-29 22:41   ` Pranav Bhandarkar
  0 siblings, 0 replies; 3+ messages in thread
From: Pranav Bhandarkar @ 2007-05-29 22:41 UTC (permalink / raw)
  To: Kenneth.Zadeck; +Cc: gcc-patches

Hi Kenneth,
Thanks. I did check  and realised that there was a mistake in my port
in my version of GO_IF_LEGITIMATE_ADDRESS. Because of this mistake,
validate_change was allowing the insn to pass.

I agree that my patch to auto-inc-dec.c isnt quite required.

Thanks for your help,
Pranav

On 5/30/07, Kenneth Zadeck <Kenneth.Zadeck@naturalbridge.com> wrote:
> I talked to Ian Taylor and David Edelsohn about this.
> No one can see the reason for this patch assuming that you have a
> properly written port.
>
> Immediately after the point where you would like to insert the the
> memory_address_p there is a call to validate_change.  If your port is
> written correctly, that call should see the mem reference in the new
> part of the insn and call memory_address_p on it.  This is what
> validate_change does for a living.
>
> Kenny
>
> > Hi,
> > I am working on a private port, wherein the constant addition /
> > subtraction in a post_modify  _must_  be less than a certain value.
> > For such a check I have defined GO_IF_LEGITIMATE_ADDRESS
> > appropriately. The problem is that attempt_change in auto-inc-dec
> > doesnt check if the new address is a valid memory address or not
> > resulting in an ICE in a later pass.
> >
> > Therefore I wrote this patch, where in before replacing a memory
> > address and its modification by a constant by a post_modify, I first
> > check if the new address expression is going to be a valid expression.
> >
> > Thanks,
> > Pranav
> >
> > ChangeLog:
> >  * auto-inc-dec.c (attempt_change): Check if new_addr_pat is a
> >         valid memory address.
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-05-29 19:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-28 21:58 [RFC, PATCH ] [DATAFLOW] Validating an address in auto-inc-dec Pranav Bhandarkar
2007-05-29 18:59 ` Kenneth Zadeck
2007-05-29 22:41   ` Pranav Bhandarkar

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).