Bug 104072 - Register variables in libgccjit
Summary: Register variables in libgccjit
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: jit (show other bugs)
Version: 12.0
: P3 normal
Target Milestone: ---
Assignee: David Malcolm
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-17 21:06 UTC by Antoni
Modified: 2024-04-24 20:18 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Antoni 2022-01-17 21:06:52 UTC
Hi.
I'm opening this issue to track my upcoming patch adding support for register variables in libgccjit.
Comment 1 GCC Commits 2022-04-12 21:22:52 UTC
The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:

https://gcc.gnu.org/g:5780ff348ad4430383fd67c6f0c572d8c3e721ad

commit r12-8118-g5780ff348ad4430383fd67c6f0c572d8c3e721ad
Author: Antoni Boucher <bouanto@zoho.com>
Date:   Tue Apr 12 17:20:30 2022 -0400

    libgccjit: Add support for register variables [PR104072]
    
    gcc/jit/
            PR jit/104072
            * docs/_build/texinfo/libgccjit.texi: Regenerate.
            * docs/topics/compatibility.rst (LIBGCCJIT_ABI_22): New ABI tag.
            * docs/topics/expressions.rst: Add documentation for the
            function gcc_jit_lvalue_set_register_name.
            * jit-playback.h: New function (set_register_name).
            * jit-recording.cc: New function (set_register_name) and add
            support for register variables.
            * jit-recording.h: New field (m_reg_name) and new function
            (set_register_name).
            * libgccjit.cc: New function (gcc_jit_lvalue_set_register_name).
            * libgccjit.h: New function (gcc_jit_lvalue_set_register_name).
            * libgccjit.map (LIBGCCJIT_ABI_22): New ABI tag.
    
    gcc/
            PR jit/104072
            * reginfo.cc: New functions (clear_global_regs_cache,
            reginfo_cc_finalize) to avoid an issue where compiling the same
            code multiple times gives an error about assigning the same
            register to 2 global variables.
            * rtl.h: New function (reginfo_cc_finalize).
            * toplev.cc: Call it.
    
    gcc/testsuite/
            PR jit/104072
            * jit.dg/all-non-failing-tests.h: Add new
            test-register-variable.
            * jit.dg/harness.h: Add -fdiagnostics-color=never to context's
            command-line options.
            * jit.dg/test-error-register-variable-bad-name.c: New test.
            * jit.dg/test-error-register-variable-size-mismatch.c: New test.
            * jit.dg/test-register-variable.c: New test.
Comment 2 David Malcolm 2022-04-13 20:38:40 UTC
Marking as resolved; please reopen if there's an issue integrating the version of the patch I committed with rustc_codegen_gcc.
Comment 3 Andreas Schwab 2024-04-24 08:04:13 UTC
FAIL: test-error-register-variable-size-mismatch.c.exe iteration 1 of 5: verify_code: actual: "invalid register name for 'global_variable'" != expected: "data type of 'global_variable' isn't suitable for a register"
Comment 4 Andrew Pinski 2024-04-24 20:18:48 UTC
(In reply to Andreas Schwab from comment #3)
> FAIL: test-error-register-variable-size-mismatch.c.exe iteration 1 of 5:
> verify_code: actual: "invalid register name for 'global_variable'" !=
> expected: "data type of 'global_variable' isn't suitable for a register"

Yes looks like a testcase issue. What target is from? r12 is sometimes a valid register name but not always.