[PR,83990] Fix location handling in ipa_modify_call_arguments

Message ID ri6vaf2xg98.fsf@suse.cz
State New
Headers show
Series
  • [PR,83990] Fix location handling in ipa_modify_call_arguments
Related show

Commit Message

Martin Jambor Feb. 12, 2018, 5:35 p.m.
Hi,

the callee-side arguments manipulation method used by IPA-SRA has two
issues with how it deals with locations.  First, it gets the location
from expressions in an unreliable way rather than the statements it sees
and then it forgets to set a location of one gimple assign it creates.
Both is fixed in the patch below.

I have bootstrapped and tested the patch on an x86_64-linux and consider
it pre-approved by Jakub in bugzilla so plan to commit it to trunk
tomorrow and to the gcc-7-branch soon afterwards (after testing there).

Thanks,

Martin


2018-01-30  Martin Jambor  <mjambor@suse.cz>

	PR c++/83990
	* ipa-param-manipulation.c (ipa_modify_call_arguments): Use location
	of call statements, also set location of a load to a temporary.

---
 gcc/ipa-param-manipulation.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jakub Jelinek Feb. 12, 2018, 5:37 p.m. | #1
On Mon, Feb 12, 2018 at 06:35:47PM +0100, Martin Jambor wrote:
> Hi,
> 
> the callee-side arguments manipulation method used by IPA-SRA has two
> issues with how it deals with locations.  First, it gets the location
> from expressions in an unreliable way rather than the statements it sees
> and then it forgets to set a location of one gimple assign it creates.
> Both is fixed in the patch below.
> 
> I have bootstrapped and tested the patch on an x86_64-linux and consider
> it pre-approved by Jakub in bugzilla so plan to commit it to trunk
> tomorrow and to the gcc-7-branch soon afterwards (after testing there).

Yeah, this is ok.

> 2018-01-30  Martin Jambor  <mjambor@suse.cz>
> 
> 	PR c++/83990
> 	* ipa-param-manipulation.c (ipa_modify_call_arguments): Use location
> 	of call statements, also set location of a load to a temporary.
> 
> --- a/gcc/ipa-param-manipulation.c
> +++ b/gcc/ipa-param-manipulation.c
> @@ -295,8 +295,7 @@ ipa_modify_call_arguments (struct cgraph_edge *cs, gcall *stmt,
>  
>  	  poly_int64 byte_offset = exact_div (adj->offset, BITS_PER_UNIT);
>  	  base = gimple_call_arg (stmt, adj->base_index);
> -	  loc = DECL_P (base) ? DECL_SOURCE_LOCATION (base)
> -			      : EXPR_LOCATION (base);
> +	  loc = gimple_location (stmt);
>  
>  	  if (TREE_CODE (base) != ADDR_EXPR
>  	      && POINTER_TYPE_P (TREE_TYPE (base)))
> @@ -385,6 +384,7 @@ ipa_modify_call_arguments (struct cgraph_edge *cs, gcall *stmt,
>  		  else
>  		    expr = create_tmp_reg (TREE_TYPE (expr));
>  		  gimple_assign_set_lhs (tem, expr);
> +		  gimple_set_location (tem, loc);
>  		  gsi_insert_before (&gsi, tem, GSI_SAME_STMT);
>  		}
>  	    }
> -- 
> 2.15.1

	Jakub

Patch

diff --git a/gcc/ipa-param-manipulation.c b/gcc/ipa-param-manipulation.c
index 36290704644..1ab1fcccdae 100644
--- a/gcc/ipa-param-manipulation.c
+++ b/gcc/ipa-param-manipulation.c
@@ -295,8 +295,7 @@  ipa_modify_call_arguments (struct cgraph_edge *cs, gcall *stmt,
 
 	  poly_int64 byte_offset = exact_div (adj->offset, BITS_PER_UNIT);
 	  base = gimple_call_arg (stmt, adj->base_index);
-	  loc = DECL_P (base) ? DECL_SOURCE_LOCATION (base)
-			      : EXPR_LOCATION (base);
+	  loc = gimple_location (stmt);
 
 	  if (TREE_CODE (base) != ADDR_EXPR
 	      && POINTER_TYPE_P (TREE_TYPE (base)))
@@ -385,6 +384,7 @@  ipa_modify_call_arguments (struct cgraph_edge *cs, gcall *stmt,
 		  else
 		    expr = create_tmp_reg (TREE_TYPE (expr));
 		  gimple_assign_set_lhs (tem, expr);
+		  gimple_set_location (tem, loc);
 		  gsi_insert_before (&gsi, tem, GSI_SAME_STMT);
 		}
 	    }