[PATCH] libgccjit: Add ability to get the alignment of a type

Iain Sandoe idsandoe@googlemail.com
Sat Jun 29 01:28:56 GMT 2024


Hi Folks,

> On 28 Jun 2024, at 12:50, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
> 
> David Malcolm <dmalcolm@redhat.com> writes:
> 
>> On Thu, 2024-04-04 at 18:59 -0400, Antoni Boucher wrote:
>>> Hi.
>>> This patch adds a new API to produce an rvalue representing the 
>>> alignment of a type.
>>> Thanks for the review.
>> 
>> Patch looks good to me (but may need the usual ABI version updates when
>> merging).
> 
> This patch broke macOS bootstrap:
> 
> /vol/gcc/src/hg/master/darwin/gcc/jit/jit-recording.cc: In member function 'virtual gcc::jit::recording::string* gcc::jit::recording::memento_of_typeinfo::make_debug_string()': 
> /vol/gcc/src/hg/master/darwin/gcc/jit/jit-recording.cc:5529:30: error: 'ident' may be used uninitialized [-Werror=maybe-uninitialized]
> 5529 |   return string::from_printf (m_ctxt,
>      |          ~~~~~~~~~~~~~~~~~~~~^~~~~~~~
> 5530 |                               "%s (%s)",
>      |                               ~~~~~~~~~~
> 5531 |                               ident,
>      |                               ~~~~~~
> 5532 |                               m_type->get_debug_string ());
>      |                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /vol/gcc/src/hg/master/darwin/gcc/jit/jit-recording.cc:5519:15: note: 'ident' was declared here
> 5519 |   const char* ident;
>      |               ^~~~~
> 
> /vol/gcc/src/hg/master/darwin/gcc/jit/jit-recording.cc: In member function 'virtual void gcc::jit::recording::memento_of_typeinfo::write_reproducer(gcc::jit::reproducer&)':          
> /vol/gcc/src/hg/master/darwin/gcc/jit/jit-recording.cc:5552:11: error: 'type' may be used uninitialized [-Werror=maybe-uninitialized]
> 5552 |   r.write ("  gcc_jit_rvalue *%s =\n"
>      |   ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
> 5553 |     "    gcc_jit_context_new_%sof (%s, /* gcc_jit_context *ctxt */\n"
>      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 5554 |     "                                (gcc_jit_type *) %s); /* gcc_jit_type *type */\n",
>      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 5555 |     id,
>      |     ~~~
> 5556 |     type,
>      |     ~~~~~
> 5557 |     r.get_identifier (get_context ()),
>      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 5558 |     r.get_identifier (m_type));
>      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~
> /vol/gcc/src/hg/master/darwin/gcc/jit/jit-recording.cc:5541:15: note: 'type' was declared here
> 5541 |   const char* type;
>      |               ^~~~
> 
> I wonder how this can have worked anywhere (apart from jit not being
> enabled by default on non-Darwin targets).

Well, in principle, all values of the m_info_type enum are covered (there are only 2) - and therefore the two vars should be seen as initialized on some path.   It is quite disappointing that we cannot track this in a 12 line function with such a small enumeration… 

… I am going to fix this with the obvious (provide a default init for the vars) - later today.

Iain




More information about the Jit mailing list