* Handling of nonnull function attribute
@ 2023-09-21 14:47 Antoni Boucher
2023-09-21 19:48 ` Guillaume Gomez
0 siblings, 1 reply; 2+ messages in thread
From: Antoni Boucher @ 2023-09-21 14:47 UTC (permalink / raw)
To: gcc; +Cc: Guillaume Gomez, David Malcolm
Hi.
I'm working on adding the support for the nonnull attribute in
libgccjit.
I found out a way to make it working, but I need more help to find a
proper solution.
The problem is that the nonnull attribute should be added to the
fn_type while we added it to the fn_decl.
If we add it to the fn_type directly, it works.
However, it seems the other frontends do that automatically, by the way
of c_common_attribute_table (field type_required set to true).
Is this correct?
If so, how does this mechanism work and how can it be enabled for a
frontend?
I tried calling init_attributes at the end of jit_langhook_init, but
that doesn't work.
Thanks for your help.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Handling of nonnull function attribute
2023-09-21 14:47 Handling of nonnull function attribute Antoni Boucher
@ 2023-09-21 19:48 ` Guillaume Gomez
0 siblings, 0 replies; 2+ messages in thread
From: Guillaume Gomez @ 2023-09-21 19:48 UTC (permalink / raw)
To: Antoni Boucher; +Cc: gcc, David Malcolm
Hi,
We were able to make it work by calling:
```
decl_attributes (&fndecl, fn_attributes, 0);
```
We used to set the attributes directly in `fndecl` using equivalents of:
```
DECL_ATTRIBUTES (fndecl) =
tree_cons (ident, attribute_value, DECL_ATTRIBUTES (fndecl));
```
We now store inside `fn_attributes` using:
```
fn_attributes = tree_cons (ident, attribute_value, fn_attributes);
```
Like this, the function attributes seem to be correctly set and the
optimization is triggered as expected when using the `nonnull`
attribute.
I think with this it's all good. If you see something we did wrong,
please don't hesitate to tell us.
Le jeu. 21 sept. 2023 à 16:48, Antoni Boucher <bouanto@zoho.com> a écrit :
>
> Hi.
> I'm working on adding the support for the nonnull attribute in
> libgccjit.
> I found out a way to make it working, but I need more help to find a
> proper solution.
> The problem is that the nonnull attribute should be added to the
> fn_type while we added it to the fn_decl.
> If we add it to the fn_type directly, it works.
> However, it seems the other frontends do that automatically, by the way
> of c_common_attribute_table (field type_required set to true).
> Is this correct?
> If so, how does this mechanism work and how can it be enabled for a
> frontend?
> I tried calling init_attributes at the end of jit_langhook_init, but
> that doesn't work.
> Thanks for your help.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-09-21 19:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-21 14:47 Handling of nonnull function attribute Antoni Boucher
2023-09-21 19:48 ` Guillaume Gomez
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).