public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Dehao Chen <dehao@google.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Cleanup last_location and update input_location in ipa_prop
Date: Tue, 27 Nov 2012 09:47:00 -0000	[thread overview]
Message-ID: <CAFiYyc3Fcmpc99Qrvr76FT1Y7tgoK4U1bp6_LgW-6n+SZdcpvw@mail.gmail.com> (raw)
In-Reply-To: <CAO2gOZXupbCOwLLvjKgUEsV_=aj99AwwdR4x1tKGQD-u_sL9bw@mail.gmail.com>

On Mon, Nov 26, 2012 at 11:54 PM, Dehao Chen <dehao@google.com> wrote:
> The new patch is attached. Bootstrapped and passed gcc regression test.
>
> Ok for trunk?

Hmm ... this merely avoids some UNKNOWN_LOCATIONs which should
be ok.  I think the issue is that gimplify_expr does:

  saved_location = input_location;
  if (save_expr != error_mark_node
      && EXPR_HAS_LOCATION (*expr_p))
    input_location = EXPR_LOCATION (*expr_p);

thus it retains input_location from previous recursive invocations (that's ok).

But it doesn't seem to be the case that input_location is UNKNOWN_LOCATION
during GIMPLE passes (which it really should be ...).  So to fix the
gimplification
issue I think that gimplify_ctx should have a location (initialized to
UNKNOWN_LOCATION), which it saves/restores across its push/pop
operation.

Or of course that inside the pass manager before executing passes assert
that input_location is UNKNOWN_LOCATION and fix up things according
to that.  First offender is in cgraphunit.c in cgraph_analyze_function:

  location_t saved_loc = input_location;
  input_location = DECL_SOURCE_LOCATION (decl);

that should be totally unnecessary (input_location shoud be and stay
UNKNOWN_LOCATION).  And finalize_compilation_unit (the last thing
the frontends should call) should have input_location = UNKNOWN_LOCATION
right at the point it clears current_function_decl / cfun.

I'd prefer the 2nd approach (maybe without the assert as we are in stage3
already, but the assert would certainly help).  And places in the middle-end
that set input_location for purpose of (re-)gimplifying should use the location
in the gimplify ctx (which would need to be added) instead of setting
input_location.

Maybe as a first try set input_location to UNKNOWN_LOCATION in
finalize_compilation_unit.

Thanks,
Richard.

> Thanks,
> Dehao
>
> gcc/ChangeLog:
> 2010-11-05  Dehao Chen  <dehao@google.com>
>
>         * ipa-prop.c (ipa_modify_call_arguments): Set loc correctly.
>         * emit-rtl.c (last_location): Remove unused variable.
>
> Index: gcc/emit-rtl.c
> ===================================================================
> --- gcc/emit-rtl.c (revision 193203)
> +++ gcc/emit-rtl.c (working copy)
> @@ -5937,7 +5937,7 @@ location_t epilogue_location;
>  /* Hold current location information and last location information, so the
>     datastructures are built lazily only when some instructions in given
>     place are needed.  */
> -static location_t curr_location, last_location;
> +static location_t curr_location;
>
>  /* Allocate insn location datastructure.  */
>  void
> @@ -5945,7 +5945,6 @@ insn_locations_init (void)
>  {
>    prologue_location = epilogue_location = 0;
>    curr_location = UNKNOWN_LOCATION;
> -  last_location = UNKNOWN_LOCATION;
>  }
>
>  /* At the end of emit stage, clear current location.  */
> Index: gcc/ipa-prop.c
> ===================================================================
> --- gcc/ipa-prop.c (revision 193203)
> +++ gcc/ipa-prop.c (working copy)
> @@ -2870,7 +2870,8 @@ ipa_modify_call_arguments (struct cgraph_edge *cs,
>
>    gcc_checking_assert (adj->offset % BITS_PER_UNIT == 0);
>    base = gimple_call_arg (stmt, adj->base_index);
> -  loc = EXPR_LOCATION (base);
> +  loc = DECL_P (base) ? DECL_SOURCE_LOCATION (base)
> +      : EXPR_LOCATION (base);
>
>    if (TREE_CODE (base) != ADDR_EXPR
>        && POINTER_TYPE_P (TREE_TYPE (base)))

  reply	other threads:[~2012-11-27  9:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-06  1:20 Dehao Chen
2012-11-08 17:39 ` Dehao Chen
2012-11-26 15:29   ` Richard Biener
2012-11-26 15:54     ` Dehao Chen
2012-11-26 16:10       ` Richard Biener
2012-11-26 17:27         ` Dehao Chen
2012-11-26 22:55           ` Dehao Chen
2012-11-27  9:47             ` Richard Biener [this message]
2012-11-27 14:54               ` Dehao Chen
2012-11-27 15:22                 ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFiYyc3Fcmpc99Qrvr76FT1Y7tgoK4U1bp6_LgW-6n+SZdcpvw@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=dehao@google.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).