https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110055
--- Comment #8 from Sprite <spriteovo at gmail dot com> ---
(In reply to Richard Biener from comment #7)
> The clobber is built by gimplify_target_expr and TARGET_EXPR_SLOT is changed
> in place to the static variable.
>
> Does the following fix the RISC-V issue?
>
> diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
> index ade6e335da7..aece89a3e9b 100644
> --- a/gcc/gimplify.cc
> +++ b/gcc/gimplify.cc
> @@ -7154,8 +7154,10 @@ gimplify_target_expr (tree *expr_p, gimple_seq
> *pre_p, gimple_seq *post_p)
> gimplify_and_add (init, &init_pre_p);
>
> /* Add a clobber for the temporary going out of scope, like
> - gimplify_bind_expr. */
> + gimplify_bind_expr. But only if we did not promote the
> + temporary to static storage. */
> if (gimplify_ctxp->in_cleanup_point_expr
> + && !TREE_STATIC (temp)
> && needs_to_live_in_memory (temp))
> {
> if (flag_stack_reuse == SR_ALL)
Yes, I have tested this patch on RISC-V platform, it fixes the issue. Thank
you!