This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][PR67666] Handle single restrict pointer in struct in create_variable_info_for_1


On 29/09/15 10:29, Richard Biener wrote:
On Tue, 29 Sep 2015, Tom de Vries wrote:

On 22/09/15 09:49, Richard Biener wrote:
On Tue, 22 Sep 2015, Tom de Vries wrote:

Hi,

Consider this test-case:

struct ps
{
    int *__restrict__ p;
};

void
f (struct ps &__restrict__ ps1)
{
    *(ps1.p) = 1;
}


Atm, the restrict on p has no effect. Now, say we add a field to the
struct:

struct ps
{
    int *__restrict__ p;
    int a;
};


Then the restrict on p does have the desired effect.


This patch fixes the handling of structs with a single field in alias
analysis.

Bootstrapped and reg-tested on x86_64.

OK for trunk?

Ok.


Hi,

I wonder if this follow-up patch is necessary.

Now that we handle structs with one field in the final loop of
create_variable_info_for_1, should we set the is_full_var field as well? It
used to be set for such structs before I committed the "Handle single restrict
pointer in struct in create_variable_info_for_1" patch.

Yeah, I suppose so.  But I'd set vi->is_full_var to true when
allocating 'vi':

   vi = new_var_info (decl, name);
   vi->fullsize = tree_to_uhwi (declsize);
  +      if (fieldstack.length () == 1)
  +       vi->is_full_var = true;


Ok with that change.


Committed as attached.

Thanks,
- Tom

Add missing is_full_var setting in create_variable_info_for_1

2015-10-23  Tom de Vries  <tom@codesourcery.com>

	* tree-ssa-structalias.c (create_variable_info_for_1): Add missing
	setting of is_full_var in case of a single field.
---
 gcc/tree-ssa-structalias.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index 8d86dcb..db0ab1e 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -5693,6 +5693,8 @@ create_variable_info_for_1 (tree decl, const char *name)
 
   vi = new_var_info (decl, name);
   vi->fullsize = tree_to_uhwi (declsize);
+  if (fieldstack.length () == 1)
+    vi->is_full_var = true;
   for (i = 0, newvi = vi;
        fieldstack.iterate (i, &fo);
        ++i, newvi = vi_next (newvi))
-- 
1.9.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]