GCC Bugzilla – Attachment 8353 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 3.4
static-promotion (text/plain), 6.88 KB, created by
Jorn Wolfgang Rennecke
on 2005-03-07 20:01:27 UTC
(
hide
)
Description:
patch against 3.4
Filename:
MIME Type:
Creator:
Jorn Wolfgang Rennecke
Created:
2005-03-07 20:01:27 UTC
Size:
6.88 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: gcc/alias.c >=================================================================== >RCS file: /cvs/gcc/gcc/gcc/alias.c,v >retrieving revision 1.209.2.7 >diff -d -u -p -r1.209.2.7 alias.c >--- gcc/alias.c 25 Jun 2004 19:15:52 -0000 1.209.2.7 >+++ gcc/alias.c 24 Feb 2005 17:04:15 -0000 >@@ -111,6 +111,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, int); > >@@ -2020,6 +2021,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. */ > >@@ -2036,6 +2061,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: gcc/emit-rtl.c >=================================================================== >RCS file: /cvs/gcc/gcc/gcc/emit-rtl.c,v >retrieving revision 1.365.4.5 >diff -d -u -p -r1.365.4.5 emit-rtl.c >--- gcc/emit-rtl.c 25 Mar 2004 16:44:40 -0000 1.365.4.5 >+++ gcc/emit-rtl.c 24 Feb 2005 17:04:19 -0000 >@@ -1756,6 +1765,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: gcc/rtlanal.c >=================================================================== >RCS file: /cvs/gcc/gcc/gcc/rtlanal.c,v >retrieving revision 1.171.4.3 >diff -d -u -p -r1.171.4.3 rtlanal.c >--- gcc/rtlanal.c 24 Feb 2004 21:45:51 -0000 1.171.4.3 >+++ gcc/rtlanal.c 24 Feb 2005 17:04:28 -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" >@@ -2348,6 +2353,7 @@ may_trap_p (rtx x) > int i; > enum rtx_code code; > const char *fmt; >+ tree exprx; > > if (x == 0) > return 0; >@@ -2377,6 +2383,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: gcc/tree.c >=================================================================== >RCS file: /cvs/gcc/gcc/gcc/tree.c,v >retrieving revision 1.342.2.5 >diff -d -u -p -r1.342.2.5 tree.c >--- gcc/tree.c 23 Aug 2004 18:02:41 -0000 1.342.2.5 >+++ gcc/tree.c 24 Feb 2005 17:04:29 -0000 >@@ -4813,6 +4813,9 @@ build_common_tree_nodes (int signed_char > 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 (); > > /* Define both `signed char' and `unsigned char'. */ >Index: gcc/tree.h >=================================================================== >RCS file: /cvs/gcc/gcc/gcc/tree.h,v >retrieving revision 1.458.2.5 >diff -d -u -p -r1.458.2.5 tree.h >--- gcc/tree.h 23 Aug 2004 18:02:42 -0000 1.458.2.5 >+++ gcc/tree.h 24 Feb 2005 17:04:29 -0000 >@@ -1792,6 +1792,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, >@@ -1882,6 +1883,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] >Index: gcc/print-rtl.c >=================================================================== >RCS file: /cvs/gcc/gcc/gcc/print-rtl.c,v >retrieving revision 1.104 >diff -d -u -p -r1.104 print-rtl.c >--- gcc/print-rtl.c 31 Dec 2003 23:02:44 -0000 1.104 >+++ gcc/print-rtl.c 24 Feb 2005 17:04:25 -0000 >@@ -79,7 +79,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 (DECL_NAME (expr))
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