public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Erick Ochoa <eochoa@gcc.gnu.org>
Cc: Martin Jambor <mjambor@suse.cz>, GCC Development <gcc@gcc.gnu.org>
Subject: Re: Question on updating function body on specialized functions
Date: Wed, 9 Mar 2022 09:36:41 +0100	[thread overview]
Message-ID: <CAFiYyc3FF6vGah7qx-enLk7UX920NY6Fx+9+5SUE494VRAx2Sg@mail.gmail.com> (raw)
In-Reply-To: <CAJ_nqzhyib_Qu1JpPa0MgKvx_pTsyhwacAbbJSPZ8fqV99Rs4w@mail.gmail.com>

On Tue, Mar 8, 2022 at 4:31 PM Erick Ochoa via Gcc <gcc@gcc.gnu.org> wrote:
>
> Hi Martin!
>
> Thanks for replying, turns out that while I was trying to reply to you I
> was able to get the answer. Turns out there is indeed one tree node which
> is shared across the two functions. And that is
>
> TREE_OPERAND (MEM_REF, 1).
>
> When I was assigning to
>
> TREE_TYPE ( TREE_OPERAND (MEM_REF, 1) ) in one function, I was modifying
> the other. The solution was to create a new tree and assign it directly to
> TREE_OPERAND (MEM_REF, 1) in both functions.

Yes, that's because TREE_OPERAND (MEM_REF, 1) is an INTEGER_CST and
we share those.  See tree_node_can_be_shared in the sharing verifier.  Note
sharing also includes trees like &a.b.c[1].d for example.  The general rule of
thumb is to never directly modify trees but call unshare_expr () on them when
you do.

Richard.

>
> Thanks!

      parent reply	other threads:[~2022-03-09  8:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-08 13:53 Erick Ochoa
2022-03-08 14:51 ` Martin Jambor
2022-03-08 15:29   ` Erick Ochoa
2022-03-08 22:11     ` Gary Oblock
2022-03-09  8:36     ` Richard Biener [this message]

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=CAFiYyc3FF6vGah7qx-enLk7UX920NY6Fx+9+5SUE494VRAx2Sg@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=eochoa@gcc.gnu.org \
    --cc=gcc@gcc.gnu.org \
    --cc=mjambor@suse.cz \
    /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).