public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug jit/95426] New: libgccjit.so: error: RTL check: expected elt 2 type 'B', have '0' (rtx barrier) in BLOCK_FOR_INSN
@ 2020-05-29 23:30 bouanto at zoho dot com
  2020-05-31 13:56 ` [Bug jit/95426] " dmalcolm at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: bouanto at zoho dot com @ 2020-05-29 23:30 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95426
           Summary: libgccjit.so: error: RTL check: expected elt 2 type
                    'B', have '0' (rtx barrier) in BLOCK_FOR_INSN
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: jit
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: bouanto at zoho dot com
  Target Milestone: ---

Hi.
I found this bug that happens when generating some code with libgccjit:

during RTL pass: expand
libgccjit.so: error: RTL check: expected elt 2 type 'B', have '0' (rtx barrier)
in BLOCK_FOR_INSN, at rtl.h:1485
0x7f2a2317d365 rtl_check_failed_type1(rtx_def const*, int, int, char const*,
int, char const*)
        ../../gcc/gcc/rtl.c:860
0x7f2a23091bf7 BLOCK_FOR_INSN(rtx_def*)
        ../../gcc/gcc/rtl.h:1485
0x7f2a23091f82 BLOCK_FOR_INSN(rtx_def*)
        ../../gcc/gcc/rtl.h:1469
0x7f2a23091f82 rtl_verify_bb_pointers
        ../../gcc/gcc/cfgrtl.c:2778
0x7f2a2359e6e6 rtl_verify_flow_info_1
        ../../gcc/gcc/cfgrtl.c:2832
0x7f2a2359e6e6 rtl_verify_flow_info
        ../../gcc/gcc/cfgrtl.c:3076
0x7f2a23582a06 verify_flow_info()
        ../../gcc/gcc/cfghooks.c:267
0x7f2a244a966d checking_verify_flow_info
        ../../gcc/gcc/cfghooks.h:212
0x7f2a244a966d try_optimize_cfg
        ../../gcc/gcc/cfgcleanup.c:3009
0x7f2a244a966d cleanup_cfg(int)
        ../../gcc/gcc/cfgcleanup.c:3174
0x7f2a2357f90a execute
        ../../gcc/gcc/cfgexpand.c:6732

I'm not sure what causes this issue and, again, dumping a reproducer dumps a
file with an empty create_code function.
Is there any compile-time option I need to enable to be able to create a
reproducer?

Thanks to fix this issue.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug jit/95426] libgccjit.so: error: RTL check: expected elt 2 type 'B', have '0' (rtx barrier) in BLOCK_FOR_INSN
  2020-05-29 23:30 [Bug jit/95426] New: libgccjit.so: error: RTL check: expected elt 2 type 'B', have '0' (rtx barrier) in BLOCK_FOR_INSN bouanto at zoho dot com
@ 2020-05-31 13:56 ` dmalcolm at gcc dot gnu.org
  2020-05-31 14:54 ` bouanto at zoho dot com
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2020-05-31 13:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
gcc_jit_context_dump_reproducer_to_file runs in the testsuite, and I see it
generating sane-looking reproducers (with non-empty create_code functions).

Are you calling gcc_jit_context_dump_reproducer_to_file before or after calling
gcc_jit_context_compile?  (or when not calling gcc_jit_context_compile?)  I
have a feeling that calling it after an unsuccessful compile might break it
("unsuccessful" in the sense of a compile that generates a non-fatal error but
doesn't crash the process).

Can you attach the result of gcc_jit_context_dump_reproducer_to_file to this
bug please?

Another thing to try might be to use gcc_jit_context_set_logfile and to attach
the resulting logfile (though you may need to flush it and close it and not
call gcc_jit_context_compile).

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug jit/95426] libgccjit.so: error: RTL check: expected elt 2 type 'B', have '0' (rtx barrier) in BLOCK_FOR_INSN
  2020-05-29 23:30 [Bug jit/95426] New: libgccjit.so: error: RTL check: expected elt 2 type 'B', have '0' (rtx barrier) in BLOCK_FOR_INSN bouanto at zoho dot com
  2020-05-31 13:56 ` [Bug jit/95426] " dmalcolm at gcc dot gnu.org
@ 2020-05-31 14:54 ` bouanto at zoho dot com
  2020-05-31 15:20 ` dmalcolm at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: bouanto at zoho dot com @ 2020-05-31 14:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from bouanto at zoho dot com ---
Created attachment 48648
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48648&action=edit
Reproducer for the bug

Oh, I see what I was doing wrong: I thought it was an option, so I was calling
this function at the beginning.

Also, I had to comment the line creating the type GCC_JIT_TYPE_COMPLEX_DOUBLE
in order for this reproducer to reproduce the issue.
With that line, it does another error:
libgccjit.so: error: gcc_jit_context_get_type: unrecognized value for enum
gcc_jit_types: 21
That's probably another bug, though.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug jit/95426] libgccjit.so: error: RTL check: expected elt 2 type 'B', have '0' (rtx barrier) in BLOCK_FOR_INSN
  2020-05-29 23:30 [Bug jit/95426] New: libgccjit.so: error: RTL check: expected elt 2 type 'B', have '0' (rtx barrier) in BLOCK_FOR_INSN bouanto at zoho dot com
  2020-05-31 13:56 ` [Bug jit/95426] " dmalcolm at gcc dot gnu.org
  2020-05-31 14:54 ` bouanto at zoho dot com
@ 2020-05-31 15:20 ` dmalcolm at gcc dot gnu.org
  2020-05-31 17:08 ` dmalcolm at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2020-05-31 15:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Aha - thanks.

Re-reading
  https://gcc.gnu.org/onlinedocs/jit/topics/contexts.html#debugging
it looks like the documentation for these entrypoints could use some
clarification on whether each one relates to the current state of the context,
or whether it takes effect when the context is compiled.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug jit/95426] libgccjit.so: error: RTL check: expected elt 2 type 'B', have '0' (rtx barrier) in BLOCK_FOR_INSN
  2020-05-29 23:30 [Bug jit/95426] New: libgccjit.so: error: RTL check: expected elt 2 type 'B', have '0' (rtx barrier) in BLOCK_FOR_INSN bouanto at zoho dot com
                   ` (2 preceding siblings ...)
  2020-05-31 15:20 ` dmalcolm at gcc dot gnu.org
@ 2020-05-31 17:08 ` dmalcolm at gcc dot gnu.org
  2020-06-01 19:50 ` dmalcolm at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2020-05-31 17:08 UTC (permalink / raw)
  To: gcc-bugs

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

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2020-05-31
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #4 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
The reproducer you attached reproduces the crash from comment #0 for me;
marking as ASSIGNED.

(gdb) call debug(insn)
(barrier 29 28 30)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug jit/95426] libgccjit.so: error: RTL check: expected elt 2 type 'B', have '0' (rtx barrier) in BLOCK_FOR_INSN
  2020-05-29 23:30 [Bug jit/95426] New: libgccjit.so: error: RTL check: expected elt 2 type 'B', have '0' (rtx barrier) in BLOCK_FOR_INSN bouanto at zoho dot com
                   ` (3 preceding siblings ...)
  2020-05-31 17:08 ` dmalcolm at gcc dot gnu.org
@ 2020-06-01 19:50 ` dmalcolm at gcc dot gnu.org
  2020-06-02 12:43 ` bouanto at zoho dot com
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2020-06-01 19:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Created attachment 48657
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48657&action=edit
Reduced test case

I've reduced the reproducer you posted to this test case.

Seems to require a call to __builtin_unreachable followed by code, without
optimization, leading to a crash in the "expand" pass when transitioning from
gimple to RTL internally, due to an unexpected barrier insn in the RTL.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug jit/95426] libgccjit.so: error: RTL check: expected elt 2 type 'B', have '0' (rtx barrier) in BLOCK_FOR_INSN
  2020-05-29 23:30 [Bug jit/95426] New: libgccjit.so: error: RTL check: expected elt 2 type 'B', have '0' (rtx barrier) in BLOCK_FOR_INSN bouanto at zoho dot com
                   ` (4 preceding siblings ...)
  2020-06-01 19:50 ` dmalcolm at gcc dot gnu.org
@ 2020-06-02 12:43 ` bouanto at zoho dot com
  2020-06-02 12:50 ` dmalcolm at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: bouanto at zoho dot com @ 2020-06-02 12:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from bouanto at zoho dot com ---
Any idea how I should change the generated code to make it work?
Or will a patch not require changing the generated code?
Thanks.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug jit/95426] libgccjit.so: error: RTL check: expected elt 2 type 'B', have '0' (rtx barrier) in BLOCK_FOR_INSN
  2020-05-29 23:30 [Bug jit/95426] New: libgccjit.so: error: RTL check: expected elt 2 type 'B', have '0' (rtx barrier) in BLOCK_FOR_INSN bouanto at zoho dot com
                   ` (5 preceding siblings ...)
  2020-06-02 12:43 ` bouanto at zoho dot com
@ 2020-06-02 12:50 ` dmalcolm at gcc dot gnu.org
  2020-06-02 15:09 ` dmalcolm at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2020-06-02 12:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
This seems like a bug with how libgccjit interacts with __builtin_unreachable,
sorry.

As a workaround, try removing the __builtin_unreachable calls for now.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug jit/95426] libgccjit.so: error: RTL check: expected elt 2 type 'B', have '0' (rtx barrier) in BLOCK_FOR_INSN
  2020-05-29 23:30 [Bug jit/95426] New: libgccjit.so: error: RTL check: expected elt 2 type 'B', have '0' (rtx barrier) in BLOCK_FOR_INSN bouanto at zoho dot com
                   ` (6 preceding siblings ...)
  2020-06-02 12:50 ` dmalcolm at gcc dot gnu.org
@ 2020-06-02 15:09 ` dmalcolm at gcc dot gnu.org
  2020-06-02 22:30 ` cvs-commit at gcc dot gnu.org
  2020-06-02 22:34 ` dmalcolm at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2020-06-02 15:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Looks like the way libgccjit sets up attributes (such as "noreturn") on
builtins has somehow become a no-op.  Am investigating.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug jit/95426] libgccjit.so: error: RTL check: expected elt 2 type 'B', have '0' (rtx barrier) in BLOCK_FOR_INSN
  2020-05-29 23:30 [Bug jit/95426] New: libgccjit.so: error: RTL check: expected elt 2 type 'B', have '0' (rtx barrier) in BLOCK_FOR_INSN bouanto at zoho dot com
                   ` (7 preceding siblings ...)
  2020-06-02 15:09 ` dmalcolm at gcc dot gnu.org
@ 2020-06-02 22:30 ` cvs-commit at gcc dot gnu.org
  2020-06-02 22:34 ` dmalcolm at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-02 22:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:

https://gcc.gnu.org/g:44564c4c811f4751daf363ca019a9f9bed702f4f

commit r11-839-g44564c4c811f4751daf363ca019a9f9bed702f4f
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Sun May 31 13:28:41 2020 -0400

    jit: fix __builtin_unreachable [PR 95426]

    PR jit/95426 reports a crash deep inside "expand" when using
    __builtin_unreachable via gcc_jit_context_get_builtin_function,
    due to BLOCK_FOR_INSN being erroneously used on a barrier within
    rtl_verify_bb_pointers.

    The root cause turns out to be that I didn't implement
    LANG_HOOKS_COMMON_ATTRIBUTE_TABLE and LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE
    for the jit "frontend".  When building a decl for the builtin, the
    libgccjit frontend generates a chain of attributes names, but when
    this is passed to decl_attributes and the attributes are looked up by
    namespace and name within lookup_scoped_attribute_spec, attributes_table
    is empty.  Hence no attributes were being associated with the fndecl,
    and so ECF_NORETURN was not set on the gimple_call (along with various
    other flags missing on the decl, etc), and so the call is treated as
    not terminating its BB, and so the CFG rapidly diverges from the
    equivalent created by the C frontend.

    This patch fixes things by implementing these langhooks, copying the
    minimal attribute-handling code from LTO.  I stepped through the
    creation of the fndecl and verified that with this fix it has the same
    attributes as the equivalent created by the C frontend.

    gcc/jit/ChangeLog:
            PR jit/95426
            * dummy-frontend.c: Include "options.h", "stringpool.h", and
            "attribs.h".
            (ATTR_EXCL): New, copied from lto/lto-lang.c.
            (attr_noreturn_exclusions): Likewise.
            (attr_returns_twice_exclusions): Likewise.
            (attr_const_pure_exclusions): Likewise.
            (jit_attribute_table): Likewise, copied from lto_attribute_table.
            (jit_format_attribute_table): Likewise, copied from
            lto_format_attribute_table.
            (handle_noreturn_attribute): New, copied from lto/lto-lang.c.
            (handle_leaf_attribute): Likewise.
            (handle_const_attribute): Likewise.
            (handle_malloc_attribute): Likewise.
            (handle_pure_attribute): Likewise.
            (handle_novops_attribute): Likewise.
            (get_nonnull_operand): Likewise.
            (handle_nonnull_attribute): Likewise.
            (handle_nothrow_attribute): Likewise.
            (handle_sentinel_attribute): Likewise.
            (handle_type_generic_attribute): Likewise.
            (handle_transaction_pure_attribute): Likewise.
            (handle_returns_twice_attribute): Likewise.
            (handle_patchable_function_entry_attribute): Likewise.
            (ignore_attribute): Likewise.
            (handle_format_attribute): Likewise.
            (handle_format_arg_attribute): Likewise.
            (handle_fnspec_attribute): Likewise.
            (LANG_HOOKS_COMMON_ATTRIBUTE_TABLE): Define.
            (LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE): Define.

    gcc/testsuite/ChangeLog:
            PR jit/95426
            * jit.dg/all-non-failing-tests.h: Add note about...
            * jit.dg/test-builtin-unreachable.c: New test.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug jit/95426] libgccjit.so: error: RTL check: expected elt 2 type 'B', have '0' (rtx barrier) in BLOCK_FOR_INSN
  2020-05-29 23:30 [Bug jit/95426] New: libgccjit.so: error: RTL check: expected elt 2 type 'B', have '0' (rtx barrier) in BLOCK_FOR_INSN bouanto at zoho dot com
                   ` (8 preceding siblings ...)
  2020-06-02 22:30 ` cvs-commit at gcc dot gnu.org
@ 2020-06-02 22:34 ` dmalcolm at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2020-06-02 22:34 UTC (permalink / raw)
  To: gcc-bugs

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

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #10 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Should be fixed by the above commit.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-06-02 22:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-29 23:30 [Bug jit/95426] New: libgccjit.so: error: RTL check: expected elt 2 type 'B', have '0' (rtx barrier) in BLOCK_FOR_INSN bouanto at zoho dot com
2020-05-31 13:56 ` [Bug jit/95426] " dmalcolm at gcc dot gnu.org
2020-05-31 14:54 ` bouanto at zoho dot com
2020-05-31 15:20 ` dmalcolm at gcc dot gnu.org
2020-05-31 17:08 ` dmalcolm at gcc dot gnu.org
2020-06-01 19:50 ` dmalcolm at gcc dot gnu.org
2020-06-02 12:43 ` bouanto at zoho dot com
2020-06-02 12:50 ` dmalcolm at gcc dot gnu.org
2020-06-02 15:09 ` dmalcolm at gcc dot gnu.org
2020-06-02 22:30 ` cvs-commit at gcc dot gnu.org
2020-06-02 22:34 ` dmalcolm at gcc dot gnu.org

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).