diff mbox

[1/2] gimplify_modify_expr: avoid DECL_DEBUG_EXPR links across functions

Message ID 20170529075011.15538-1-derodat@adacore.com
State New
Headers show

Commit Message

Pierre-Marie de Rodat May 29, 2017, 7:50 a.m. UTC
Hello,

An upcoming patch exposes a bug in gimplify_modify_expr.  There, we try
not to create DECL_DEBUG_EXPR links across functions, however we don't
check that *FROM_P actually belongs to the current function before
modifying it.  This patch fixes this oversight.

Bootstrapped and regtested on x86_64-linux.  Ok to commit?  Thank you in
advance!

gcc/

	* gimplify.c (gimplify_modify_expr): Don't create a
	DECL_DEBUG_EXPR link if *FROM_P does not belong to the current
	function.
---
 gcc/gimplify.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Richard Biener May 30, 2017, 11:51 a.m. UTC | #1
On Mon, May 29, 2017 at 9:50 AM, Pierre-Marie de Rodat
<derodat@adacore.com> wrote:
> Hello,
>
> An upcoming patch exposes a bug in gimplify_modify_expr.  There, we try
> not to create DECL_DEBUG_EXPR links across functions, however we don't
> check that *FROM_P actually belongs to the current function before
> modifying it.  This patch fixes this oversight.
>
> Bootstrapped and regtested on x86_64-linux.  Ok to commit?  Thank you in
> advance!

Ok.

Richard.

> gcc/
>
>         * gimplify.c (gimplify_modify_expr): Don't create a
>         DECL_DEBUG_EXPR link if *FROM_P does not belong to the current
>         function.
> ---
>  gcc/gimplify.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/gimplify.c b/gcc/gimplify.c
> index 455a6993e15..2c7fc9fabd1 100644
> --- a/gcc/gimplify.c
> +++ b/gcc/gimplify.c
> @@ -5580,7 +5580,8 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
>        && DECL_IGNORED_P (*from_p)
>        && DECL_P (*to_p)
>        && !DECL_IGNORED_P (*to_p)
> -      && decl_function_context (*to_p) == current_function_decl)
> +      && decl_function_context (*to_p) == current_function_decl
> +      && decl_function_context (*from_p) == current_function_decl)
>      {
>        if (!DECL_NAME (*from_p) && DECL_NAME (*to_p))
>         DECL_NAME (*from_p)
> --
> 2.13.0
>
Pierre-Marie de Rodat May 30, 2017, 3:34 p.m. UTC | #2
On 05/30/2017 01:51 PM, Richard Biener wrote:
> Ok.

Thank you! This one is committed, now.
diff mbox

Patch

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 455a6993e15..2c7fc9fabd1 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -5580,7 +5580,8 @@  gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
       && DECL_IGNORED_P (*from_p)
       && DECL_P (*to_p)
       && !DECL_IGNORED_P (*to_p)
-      && decl_function_context (*to_p) == current_function_decl)
+      && decl_function_context (*to_p) == current_function_decl
+      && decl_function_context (*from_p) == current_function_decl)
     {
       if (!DECL_NAME (*from_p) && DECL_NAME (*to_p))
 	DECL_NAME (*from_p)