GCC Bugzilla – Attachment 8366 Details for
Bug 20367
alias analysis doesn't take into account that variables that haven't their address taken can't alias arbitrary MEMs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch against 4.1
static-promotion-4.1 (text/plain), 6.76 KB, created by
Jorn Wolfgang Rennecke
on 2005-03-08 20:42:46 UTC
(
hide
)
Description:
patch against 4.1
Filename:
MIME Type:
Creator:
Jorn Wolfgang Rennecke
Created:
2005-03-08 20:42:46 UTC
Size:
6.76 KB
patch
obsolete
>2004-02-19 J"orn Rennecke <joern.rennecke@superh.com> > > * print-rtl.c (print_mem_expr): Handle unspecified_indirect_ref_node. > > * tree.h (enum tree_index): Add TI_UNSPEC_IND_REF. > (unspecified_indirect_ref_node): Define. > * tree.c (build_common_tree_nodes): Initialize > unspecified_indirect_ref_node. > * emit-rtl.c (set_mem_attributes_minus_bitpos): When finding > a vanilla INDIRECT_REF, record unspecified_indirect_ref_node. > > * alias.c (non_addressed_function_scope_var_p): New function. > (nonoverlapping_memrefs_p): Use it. > * rtlanal.c (may_trap_p): Check MEM_EXPR for evidence of a static > variable access. > >Index: alias.c >=================================================================== >RCS file: /cvs/gcc/gcc/gcc/alias.c,v >retrieving revision 1.249 >diff -p -u -r1.249 alias.c >--- alias.c 23 Jan 2005 15:05:27 -0000 1.249 >+++ alias.c 8 Mar 2005 20:39:59 -0000 >@@ -112,6 +112,7 @@ static int aliases_everything_p (rtx); > static bool nonoverlapping_component_refs_p (tree, tree); > static tree decl_for_component_ref (tree); > static rtx adjust_offset_for_component_ref (tree, rtx); >+static tree non_addressed_function_scope_var (tree); > static int nonoverlapping_memrefs_p (rtx, rtx); > static int write_dependence_p (rtx, rtx, int); > >@@ -1990,6 +1991,30 @@ adjust_offset_for_component_ref (tree x, > return GEN_INT (ioffset); > } > >+/* Iff EXPRX is a non-addressed variable in function scope, or a component >+ of one, return that variable. */ >+static tree >+non_addressed_function_scope_var (tree exprx) >+{ >+ if (exprx) >+ { >+ while (TREE_CODE (exprx) == COMPONENT_REF) >+ { >+ exprx = TREE_OPERAND (exprx, 0); >+ /* component_ref_for_mem_expr will just put NULL_RTX into argument >+ 0 of a COMPONENT_REF if it doesn't have a declaration. */ >+ if (! exprx) >+ return 0; >+ } >+ if (TREE_CODE (exprx) == VAR_DECL >+ && TREE_STATIC (exprx) >+ && ! TREE_ADDRESSABLE (exprx) >+ && decl_function_context (exprx) != 0) >+ return exprx; >+ } >+ return 0; >+} >+ > /* Return nonzero if we can determine the exprs corresponding to memrefs > X and Y and they do not overlap. */ > >@@ -2006,6 +2031,17 @@ nonoverlapping_memrefs_p (rtx x, rtx y) > if (exprx == 0 || expry == 0) > return 0; > >+ if (exprx != expry >+ && (non_addressed_function_scope_var (exprx) != >+ non_addressed_function_scope_var (expry)) >+ /* (mem:BLK (const_int 0 [0x0]) [0 A8]) is used as a wildcard, >+ when scan_loop detects that there is a non-pure function call - >+ which might cause recursion. */ >+ && XEXP (x, 0) != const0_rtx >+ && XEXP (y, 0) != const0_rtx) >+ >+ return 1; >+ > /* If both are field references, we may be able to determine something. */ > if (TREE_CODE (exprx) == COMPONENT_REF > && TREE_CODE (expry) == COMPONENT_REF >Index: emit-rtl.c >=================================================================== >RCS file: /cvs/gcc/gcc/gcc/emit-rtl.c,v >retrieving revision 1.435 >diff -p -u -r1.435 emit-rtl.c >--- emit-rtl.c 28 Feb 2005 18:18:23 -0000 1.435 >+++ emit-rtl.c 8 Mar 2005 20:39:59 -0000 >@@ -1666,6 +1666,14 @@ set_mem_attributes_minus_bitpos (rtx ref > expr = t; > offset = NULL; > } >+ /* If it is any other kind of indirect reference, just note the >+ fact that it is - i.e. it can't alias a variable which never >+ has its address taken. */ >+ else if (TREE_CODE (t) == INDIRECT_REF) >+ { >+ expr = unspecified_indirect_ref_node; >+ offset = NULL; >+ } > } > > /* If we modified OFFSET based on T, then subtract the outstanding >Index: print-rtl.c >=================================================================== >RCS file: /cvs/gcc/gcc/gcc/print-rtl.c,v >retrieving revision 1.119 >diff -p -u -r1.119 print-rtl.c >--- print-rtl.c 23 Sep 2004 14:34:19 -0000 1.119 >+++ print-rtl.c 8 Mar 2005 20:39:59 -0000 >@@ -99,7 +99,13 @@ print_mem_expr (FILE *outfile, tree expr > else if (TREE_CODE (expr) == INDIRECT_REF) > { > fputs (" (*", outfile); >- print_mem_expr (outfile, TREE_OPERAND (expr, 0)); >+ /* We can't do a pointer-comparison to unspecified_indirect_ref_node >+ here because genflags doesn't have the global_trees array, but >+ links with print-rtl.o . */ >+ if (TREE_OPERAND (expr, 0) == NULL_TREE) >+ fputs (" <anonymous>", outfile); >+ else >+ print_mem_expr (outfile, TREE_OPERAND (expr, 0)); > fputs (")", outfile); > } > else if (TREE_CODE (expr) == ALIGN_INDIRECT_REF) >Index: rtlanal.c >=================================================================== >RCS file: /cvs/gcc/gcc/gcc/rtlanal.c,v >retrieving revision 1.211 >diff -p -u -r1.211 rtlanal.c >--- rtlanal.c 24 Jan 2005 08:55:39 -0000 1.211 >+++ rtlanal.c 8 Mar 2005 20:40:00 -0000 >@@ -26,6 +26,7 @@ Software Foundation, 59 Temple Place - S > #include "tm.h" > #include "toplev.h" > #include "rtl.h" >+#include "tree.h" > #include "hard-reg-set.h" > #include "insn-config.h" > #include "recog.h" >@@ -2065,6 +2066,7 @@ may_trap_p (rtx x) > int i; > enum rtx_code code; > const char *fmt; >+ tree exprx; > > if (x == 0) > return 0; >@@ -2094,6 +2096,13 @@ may_trap_p (rtx x) > > /* Memory ref can trap unless it's a static var or a stack slot. */ > case MEM: >+ /* If the symbol_ref had to be loaded into a register first, the >+ information we seek is not in the address rtx proper. */ >+ exprx = MEM_EXPR (x); >+ if (exprx >+ && TREE_CODE (exprx) == VAR_DECL && TREE_STATIC (exprx) >+ && ! DECL_WEAK (exprx)) >+ return 0; > if (MEM_NOTRAP_P (x)) > return 0; > return rtx_addr_can_trap_p (XEXP (x, 0)); >Index: tree.c >=================================================================== >RCS file: /cvs/gcc/gcc/gcc/tree.c,v >retrieving revision 1.466 >diff -p -u -r1.466 tree.c >--- tree.c 12 Feb 2005 00:26:56 -0000 1.466 >+++ tree.c 8 Mar 2005 20:40:00 -0000 >@@ -5650,6 +5650,9 @@ build_common_tree_nodes (bool signed_cha > error_mark_node = make_node (ERROR_MARK); > TREE_TYPE (error_mark_node) = error_mark_node; > >+ unspecified_indirect_ref_node = make_node (INDIRECT_REF); >+ TREE_TYPE (unspecified_indirect_ref_node) = error_mark_node; >+ > initialize_sizetypes (signed_sizetype); > > /* Define both `signed char' and `unsigned char'. */ >Index: tree.h >=================================================================== >RCS file: /cvs/gcc/gcc/gcc/tree.h,v >retrieving revision 1.696 >diff -p -u -r1.696 tree.h >--- tree.h 7 Mar 2005 13:59:50 -0000 1.696 >+++ tree.h 8 Mar 2005 20:40:00 -0000 >@@ -2531,6 +2531,7 @@ union tree_node GTY ((ptr_alias (union l > enum tree_index > { > TI_ERROR_MARK, >+ TI_UNSPEC_IND_REF, > TI_INTQI_TYPE, > TI_INTHI_TYPE, > TI_INTSI_TYPE, >@@ -2596,6 +2597,7 @@ enum tree_index > extern GTY(()) tree global_trees[TI_MAX]; > > #define error_mark_node global_trees[TI_ERROR_MARK] >+#define unspecified_indirect_ref_node global_trees[TI_UNSPEC_IND_REF] > > #define intQI_type_node global_trees[TI_INTQI_TYPE] > #define intHI_type_node global_trees[TI_INTHI_TYPE]
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 20367
:
8353
|
8363
|
8364
|
8365
| 8366