Patchwork 0002-Allow-constant-MEMs-through-calls.patch

login
register
mail settings
Submitter Maxim Kuvyrkov
Date June 16, 2010, 3:54 p.m.
Message ID <4C18F3B2.8080708@codesourcery.com>
Download mbox | patch
Permalink /patch/55902/
State New
Headers show

Comments

Maxim Kuvyrkov - June 16, 2010, 3:54 p.m.
The function gcse.c: compute_transpout() is responsible for filtering 
out expressions that do not survive function calls.  Certain kinds of 
memory references, e.g., references to read-only memory can safely be 
propagated through calls.  This patch improves compute_transpout() to 
allow that.

OK to apply?

Thank you,
Jeff Law - June 16, 2010, 4:38 p.m.
> The function gcse.c: compute_transpout() is responsible for filtering 
> out expressions that do not survive function calls.  Certain kinds of 
> memory references, e.g., references to read-only memory can safely be 
> propagated through calls.  This patch improves compute_transpout() to 
> allow that.
>
> OK to apply?
OK.

Thanks,
Jeff

Patch

diff --git a/gcc/gcse.c b/gcc/gcse.c
index 1dbd2f0..00f3841 100644
--- a/gcc/gcse.c
+++ b/gcc/gcse.c
@@ -4083,6 +4083,12 @@  compute_transpout (void)
 		  && CONSTANT_POOL_ADDRESS_P (XEXP (expr->expr, 0)))
 		continue;
 
+	      /* Handle constant memory references, e.g., PIC addresses.
+		 We don't need to assume MEM_NOTRAP_P here because we only
+		 care about MEM's value surviving the call.  */
+	      if (MEM_READONLY_P (expr->expr) && !MEM_VOLATILE_P (expr->expr))
+		continue;
+
 	      /* ??? Optimally, we would use interprocedural alias
 		 analysis to determine if this mem is actually killed
 		 by this call.  */