> Am 12.01.2024 um 16:55 schrieb Qing Zhao <qing.z...@oracle.com>:
>
> Hi,
>
> I have some questions on using the utility routine “unshare_expr”:
>
> From my understanding, there should be NO shared nodes in a GENERIC function.
> Otherwise, gimplication might fail.
There is sharing and this is why we unshare everything before gimplification.
> Therefore, when we insert new tree nodes manually into the GENERIC function,
> we should
> Make sure there is no shared nodes introduced.
>
> 1. Is the above understanding correct?
No
> 2. Is there any tool to check there is no shared nodes in the GENERIC
> function?
> 3. Are there any tree nodes that are allowed to be shared in a GENERIC
> function? If so, what are they?
There’s some allowed sharing on GIMPLE and a verifier.
> 4. For the following:
>
> If both “op1” and “op2” are existing tree nodes in the current GENERIC
> function,
> and we will insert a new tree node:
>
> tree new_tree = build2 (CODE, TYPE, op1, op2)
>
>
> Should we add “unshare_expr” on both “op1” and “op2” as:
>
> Tree new_tree = build2 (CODE, TYPE, unshare_expr (op1), unshare_expr (op2))
> ?
Not necessarily but instead you have to watch for evaluating side-effects only
once. See save_expr.
>
> If op2 is a node that is allowed to be shared, whether the additional
> “unshare_expr” on it trigger any potential problem?
If you unshare side-effects that’s generating wrong-code. Otherwise unsharing
is safe.
Richard
> Thanks a lot for your help.
>
> Qing
>
>
>
>
>