Bug 96066 - Cannot use values from some builtins because they are of void type
Summary: Cannot use values from some builtins because they are of void type
Alias: None
Product: gcc
Classification: Unclassified
Component: jit (show other bugs)
Version: 10.1.0
: P3 normal
Target Milestone: ---
Assignee: David Malcolm
: 96067 (view as bug list)
Depends on:
Reported: 2020-07-05 12:43 UTC by Antoni
Modified: 2021-12-11 22:22 UTC (History)
1 user (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed:

Patch to fix the issues with using atomic builtins (1.61 KB, application/mbox)
2021-05-18 01:04 UTC, Antoni

Note You need to log in before you can comment on or make changes to this bug.
Description Antoni 2020-07-05 12:43:42 UTC
Some builtin functions, like __atomic_fetch_add, have a generic return type which libgccjit consider to be void.
That makes it impossible to use this value.
Thanks to fix this issue.
Comment 1 Andrew Pinski 2020-07-09 06:37:39 UTC
I think the builtin __atomic_fetch_add should not be used directly from the JIT front-end,  rather __atomic_fetch_add_N should be used instead.
Comment 2 Antoni 2020-07-10 23:57:25 UTC
An attempt to use, let's say, __atomic_fetch_add_4, will result in a error like:

libgccjit.so: error: unimplemented primitive type for builtin (type: BT_I4)
Comment 3 Antoni 2021-05-18 01:04:33 UTC
Created attachment 50832 [details]
Patch to fix the issues with using atomic builtins

I implemented the missing types and fixed the type checking.
Comment 4 Antoni 2021-05-18 01:06:22 UTC
*** Bug 96067 has been marked as a duplicate of this bug. ***
Comment 5 GCC Commits 2021-12-11 22:20:32 UTC
The master branch has been updated by Antoni Boucher <antoyo@gcc.gnu.org>:


commit r12-5912-g611fdb0fc5b95ee15215e2e3679834f311919096
Author: Antoni Boucher <bouanto@zoho.com>
Date:   Sat Dec 11 16:42:54 2021 -0500

    libgccjit: Add support for types used by atomic builtins [PR96066] [PR96067]
    2021-12-11  Antoni Boucher  <bouanto@zoho.com>
            PR target/96066
            PR target/96067
            * jit-builtins.c: Implement missing types for builtins.
            * jit-recording.c:: Allow sending a volatile const void * as
            * jit-recording.h: New functions (is_volatile, is_const) and
            allow comparing qualified types.
            PR target/96066
            PR target/96067
            * jit.dg/all-non-failing-tests.h: Add test-builtin-types.c.
            * jit.dg/test-builtin-types.c
            * jit.dg/test-error-bad-assignment.c
            * jit.dg/test-fuzzer.c: Add fuzzing for type qualifiers.
    Signed-off-by: Antoni Boucher <bouanto@zoho.com>
Comment 6 Antoni 2021-12-11 22:22:12 UTC
Fixed in master.