Question on updating function body on specialized functions
Richard Biener
richard.guenther@gmail.com
Wed Mar 9 08:36:41 GMT 2022
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!
More information about the Gcc
mailing list