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

--- Comment #2 from Xingbang He <qingren2hxb at gmail dot com> ---
https://godbolt.org/z/PnYdq77f8

When I only used gcc -x c for compilation, it triggered the bug. However, when
I added the compilation options as required by the test file, it passed.
=======================================
# gcc -x c

/* { dg-do run { target { { i?86-*-* x86_64-*-* } && lp64 } } } */
/* { dg-options "-fdump-rtl-fwprop1 -O2" } */

extern void abort (void);

int __RTL (startwith ("fwprop1")) test_returning_constant (void)
{
  /* C code:
     return 42; */
(function "test_returning_constant"
  (insn-chain
    (block 2
      (edge-from entry (flags "FALLTHRU"))
      (cnote 3 [bb 2] NOTE_INSN_BASIC_BLOCK)
      (cnote 2 NOTE_INSN_FUNCTION_BEG)
      (cinsn 5 (set (reg:SI <0> [ <retval> ])
                    (const_int 42)) "../../src/test-return-const.c":3)
      (cinsn 9 (set (reg/i:SI ax)
                    (const_int 42)) "../../src/test-return-const.c":4
                 (expr_list:REG_DEAD (reg:SI <0> [ <retval> ])))
      (cinsn 10 (use (reg/i:SI ax)) "../../src/test-return-const.c":4)
      (edge-to exit (flags "FALLTHRU"))
    ) ;; block 2
  ) ;; insn-chain
  (crtl
    (return_rtx 
      (reg/i:SI ax)
    ) ;; return_rtx
  ) ;; crtl
) ;; function "test_returning_constant"
}

/* Verify that insn 5 is eliminated.  */
/* { dg-final { scan-rtl-dump "deleting insn with uid = 5" "fwprop1" } } */
/* { dg-final { scan-rtl-dump "Deleted 1 trivially dead insns" "fwprop1" } } */

int main (void)
{
  if (test_returning_constant () != 42)
    abort ();
  return 0;
}
=======================================
<source>: In function 'main':
<source>:37:5: internal compiler error: in prepare_function_start, at
function.cc:4946
   37 | int main (void)
      |     ^~~~
0x20bd0f5 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
        ???:0
0x20ce646 internal_error(char const*, ...)
        ???:0
0x7a56c6 fancy_abort(char const*, int, char const*)
        ???:0
0xaa6b51 init_function_start(tree_node*)
        ???:0
0x970c48 cgraph_node::expand()
        ???:0
0x974891 symbol_table::finalize_compilation_unit()
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1

Reply via email to