Re: [RFC][IPA-VRP] Check for POINTER_TYPE_P before accessing SSA_NAME_PTR_INFO in tree-inline

2016-07-15 Thread Richard Biener
On Fri, Jul 15, 2016 at 6:43 AM, kugan
 wrote:
>
> Hi,
>
>
>
> This patch adds check for POINTER_TYPE_P before accessing SSA_NAME_PTR_INFO
> in remap_ssa_name in gcc/tree-inline.c. This is not related to IPA_VRP but
> was exposed by that.

Ok.  (before your IPA VRP nothing sets RANGE_INFO on SSA vars before
inlining is complete)

Thanks,
Richard.

>
>
> Thanks,
>
> Kugan
>
>
>
>
>
> gcc/ChangeLog:
>
>
>
> 2016-07-14  Kugan Vivekanandarajah  
>
>
>
> * tree-inline.c (remap_ssa_name): Check for POINTER_TYPE_P before
>
> accessing SSA_NAME_PTR_INFO.
>
>
>
>
>


Re: [RFC][IPA-VRP] Check for POINTER_TYPE_P before accessing SSA_NAME_PTR_INFO in tree-inline

2016-07-15 Thread Jakub Jelinek
On Thu, Jul 14, 2016 at 09:47:03PM -0700, Andrew Pinski wrote:
> On Thu, Jul 14, 2016 at 9:43 PM, kugan
>  wrote:
> > This patch adds check for POINTER_TYPE_P before accessing SSA_NAME_PTR_INFO
> > in remap_ssa_name in gcc/tree-inline.c. This is not related to IPA_VRP but
> > was exposed by that.
> 
> SSA_NAME_PTR_INFO should be NULL for non POINTER_TYPE ssa names?  Why
> is it not null in your case?

??
  /* Value range information.  */
  union ssa_name_info_type {
/* Pointer attributes used for alias analysis.  */
struct GTY ((tag ("0"))) ptr_info_def *ptr_info;
/* Value range attributes used for zero/sign extension elimination.  */
struct GTY ((tag ("1"))) range_info_def *range_info;
  } GTY ((desc ("%1.typed.type ?" \
"!POINTER_TYPE_P (TREE_TYPE ((tree)&%1)) : 2"))) info;

SSA_NAME_PTR_INFO and SSA_NAME_RANGE_INFO share space, so all uses of
SSA_NAME_PTR_INFO should be only used for pointer types and
SSA_NAME_RANGE_INFO only for integral types.

Jakub


Re: [RFC][IPA-VRP] Check for POINTER_TYPE_P before accessing SSA_NAME_PTR_INFO in tree-inline

2016-07-15 Thread kugan



Hi Andrew,


This patch adds check for POINTER_TYPE_P before accessing SSA_NAME_PTR_INFO
in remap_ssa_name in gcc/tree-inline.c. This is not related to IPA_VRP but
was exposed by that.


SSA_NAME_PTR_INFO should be NULL for non POINTER_TYPE ssa names?  Why
is it not null in your case?
In both cases there is a check for SSA_NAME_PTR_INFO being NULL before using it.


As per tree.h:

#define SSA_NAME_PTR_INFO(N) \
   SSA_NAME_CHECK (N)->ssa_name.info.ptr_info

#define SSA_NAME_RANGE_INFO(N) \
SSA_NAME_CHECK (N)->ssa_name.info.range_info

ptr_info and range_info are unions (see below). Unless I am missing 
something, now that we set range_info, we should check it is 
POINTER_TYPE_P before accessing.


  /* Value range information.  */
  union ssa_name_info_type {
/* Pointer attributes used for alias analysis.  */
struct GTY ((tag ("0"))) ptr_info_def *ptr_info;
/* Value range attributes used for zero/sign extension elimination.  */
struct GTY ((tag ("1"))) range_info_def *range_info;
  } GTY ((desc ("%1.typed.type ?" \
"!POINTER_TYPE_P (TREE_TYPE ((tree)&%1)) : 2"))) info;


Thanks,
Kugan


Re: [RFC][IPA-VRP] Check for POINTER_TYPE_P before accessing SSA_NAME_PTR_INFO in tree-inline

2016-07-14 Thread Andrew Pinski
On Thu, Jul 14, 2016 at 9:43 PM, kugan
 wrote:
>
> Hi,
>
>
>
> This patch adds check for POINTER_TYPE_P before accessing SSA_NAME_PTR_INFO
> in remap_ssa_name in gcc/tree-inline.c. This is not related to IPA_VRP but
> was exposed by that.

SSA_NAME_PTR_INFO should be NULL for non POINTER_TYPE ssa names?  Why
is it not null in your case?
In both cases there is a check for SSA_NAME_PTR_INFO being NULL before using it.

Thanks,
Andrew

>
>
>
> Thanks,
>
> Kugan
>
>
>
>
>
> gcc/ChangeLog:
>
>
>
> 2016-07-14  Kugan Vivekanandarajah  
>
>
>
> * tree-inline.c (remap_ssa_name): Check for POINTER_TYPE_P before
>
> accessing SSA_NAME_PTR_INFO.
>
>
>
>
>


[RFC][IPA-VRP] Check for POINTER_TYPE_P before accessing SSA_NAME_PTR_INFO in tree-inline

2016-07-14 Thread kugan


Hi,



This patch adds check for POINTER_TYPE_P before accessing 
SSA_NAME_PTR_INFO in remap_ssa_name in gcc/tree-inline.c. This is not 
related to IPA_VRP but was exposed by that.




Thanks,

Kugan





gcc/ChangeLog:



2016-07-14  Kugan Vivekanandarajah  



* tree-inline.c (remap_ssa_name): Check for POINTER_TYPE_P before

accessing SSA_NAME_PTR_INFO.





>From 7c1e5f3058a55d635e57bb4e9f2fd4ff14cd2b94 Mon Sep 17 00:00:00 2001
From: Kugan Vivekanandarajah 
Date: Tue, 5 Jul 2016 17:14:52 +1000
Subject: [PATCH 2/6] Inliner Check for POINTER_TYPE

---
 gcc/tree-inline.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 07f6a83..f926304 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -244,6 +244,7 @@ remap_ssa_name (tree name, copy_body_data *id)
   /* At least IPA points-to info can be directly transferred.  */
   if (id->src_cfun->gimple_df
 	  && id->src_cfun->gimple_df->ipa_pta
+	  && POINTER_TYPE_P (TREE_TYPE (name))
 	  && (pi = SSA_NAME_PTR_INFO (name))
 	  && !pi->pt.anything)
 	{
@@ -276,6 +277,7 @@ remap_ssa_name (tree name, copy_body_data *id)
   /* At least IPA points-to info can be directly transferred.  */
   if (id->src_cfun->gimple_df
 	  && id->src_cfun->gimple_df->ipa_pta
+	  && POINTER_TYPE_P (TREE_TYPE (name))
 	  && (pi = SSA_NAME_PTR_INFO (name))
 	  && !pi->pt.anything)
 	{
-- 
1.9.1