public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PR 83990] Fix location handling in ipa_modify_call_arguments
@ 2018-02-12 17:35 Martin Jambor
  2018-02-12 20:49 ` Jakub Jelinek
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Jambor @ 2018-02-12 17:35 UTC (permalink / raw)
  To: GCC Patches

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(-)

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);
 		}
 	    }
-- 
2.15.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PR 83990] Fix location handling in ipa_modify_call_arguments
  2018-02-12 17:35 [PR 83990] Fix location handling in ipa_modify_call_arguments Martin Jambor
@ 2018-02-12 20:49 ` Jakub Jelinek
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2018-02-12 20:49 UTC (permalink / raw)
  To: Martin Jambor; +Cc: GCC Patches

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-02-12 20:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-12 17:35 [PR 83990] Fix location handling in ipa_modify_call_arguments Martin Jambor
2018-02-12 20:49 ` Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).