https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116933

--- Comment #16 from qinzhao at gcc dot gnu.org ---
(In reply to Eric Botcazou from comment #12)
> > We added one more argument for __builtin_clear_padding to distinguish
> > whether this call is for AUTO_INIT or not. 
> > > 
> > > diff --git a/gcc/tree.cc b/gcc/tree.cc
> > > index bc50afca9a3..095c02c5474 100644
> > > --- a/gcc/tree.cc
> > > +++ b/gcc/tree.cc
> > > @@ -9848,7 +9848,6 @@ build_common_builtin_nodes (void)
> > >       ftype = build_function_type_list (void_type_node,
> > >                                        ptr_type_node,
> > >                                        ptr_type_node,
> > > -                                       integer_type_node,
> > 
> > This integer_type_node is for the new argument.
> 
> See this assertion in gimple_fold_builtin_clear_padding:
> 
>  gcc_assert (gimple_call_num_args (stmt) == 2);

Okay, by searching the history, looks like that the following patch forget to
update the above routine when merging the 2nd and 3rd parameters for
__builtin_clear_padding: 

>From b56ad95854f0b007afda60c057f10b04666953c9 Mon Sep 17 00:00:00 2001
From: Jakub Jelinek <ja...@redhat.com>
Date: Fri, 11 Feb 2022 19:47:14 +0100
Subject: [PATCH] middle-end: Small __builtin_clear_padding improvements

When looking at __builtin_clear_padding today, I've noticed that
it is quite wasteful to extend the original user one argument to 3,
2 is enough.  We need to encode the original type of the first argument
because pointer conversions are useless in GIMPLE, and we need to record
a boolean whether it is for -ftrivial-auto-var-init=* or not.
But for recording the type we don't need the value (we've always used
zero) and for recording the boolean we don't need the type (we've always
used integer_type_node).
So, this patch merges the two into one.

2022-02-11  Jakub Jelinek  <ja...@redhat.com>

        * tree.cc (build_common_builtin_nodes): Fix up formatting in
        __builtin_clear_padding decl creation.
        * gimplify.cc (gimple_add_padding_init_for_auto_var): Encode
        for_auto_init in the value of 2nd BUILT_IN_CLEAR_PADDING
        argument rather than in 3rd argument.
        (gimplify_call_expr): Likewise.  Fix up comment formatting.
        * gimple-fold.cc (gimple_fold_builtin_clear_padding): Expect
        2 arguments instead of 3, take for_auto_init from the value
        of 2nd argument.

Reply via email to