public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/103437] New: gcc/ira-color.c:2813:5: runtime error: signed integer overflow: 15 * 147462000 cannot be represented in type 'int'
@ 2021-11-26  9:16 marxin at gcc dot gnu.org
  2021-11-26 10:18 ` [Bug rtl-optimization/103437] " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-26  9:16 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103437
           Summary: gcc/ira-color.c:2813:5: runtime error: signed integer
                    overflow: 15 * 147462000 cannot be represented in type
                    'int'
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
                CC: vmakarov at gcc dot gnu.org
            Blocks: 63426
  Target Milestone: ---

Happens for one of Go test-cases:

$ /home/marxin/Programming/gcc/objdir/gcc/testsuite/go5/../../gccgo
-B/home/marxin/Programming/gcc/objdir/gcc/testsuite/go5/../../
/home/marxin/Programming/gcc/gcc/testsuite/go.test/test/cmplxdivide.go
/home/marxin/Programming/gcc/gcc/testsuite/go.test/test/cmplxdivide1.go
-fdiagnostics-plain-output
-I/home/marxin/Programming/gcc/objdir/x86_64-pc-linux-gnu/./libgo
-pedantic-errors
-L/home/marxin/Programming/gcc/objdir/x86_64-pc-linux-gnu/./libgo
-L/home/marxin/Programming/gcc/objdir/x86_64-pc-linux-gnu/./libgo/.libs -lm -o
./cmplxdivide.o
../../gcc/ira-color.c:2813:5: runtime error: signed integer overflow: 15 *
147462000 cannot be represented in type 'int'
    #0 0x28667a3 in setup_allocno_priorities ../../gcc/ira-color.c:2813
    #1 0x288adcc in fast_allocation ../../gcc/ira-color.c:4920
    #2 0x288adcc in ira_color() ../../gcc/ira-color.c:5016
    #3 0x27e4b2c in ira ../../gcc/ira.c:5765
    #4 0x27e4b2c in execute ../../gcc/ira.c:6075
    #5 0x2dcf8f1 in execute_one_pass(opt_pass*) ../../gcc/passes.c:2567
    #6 0x2dd2e74 in execute_pass_list_1 ../../gcc/passes.c:2656
    #7 0x2dd2ebb in execute_pass_list_1 ../../gcc/passes.c:2657
    #8 0x2dd2f81 in execute_pass_list(function*, opt_pass*)
../../gcc/passes.c:2667
    #9 0x18b6eb0 in cgraph_node::expand() ../../gcc/cgraphunit.c:1834
    #10 0x18bc40b in output_in_order ../../gcc/cgraphunit.c:2141
    #11 0x18bc40b in symbol_table::compile() ../../gcc/cgraphunit.c:2345
    #12 0x18bc40b in symbol_table::compile() ../../gcc/cgraphunit.c:2259
    #13 0x18caa27 in symbol_table::finalize_compilation_unit()
../../gcc/cgraphunit.c:2529
    #14 0x335f42f in compile_file ../../gcc/toplev.c:479
    #15 0xd0655d in do_compile ../../gcc/toplev.c:2156
    #16 0xd0655d in toplev::main(int, char**) ../../gcc/toplev.c:2308
    #17 0xd0bc80 in main ../../gcc/main.c:39
    #18 0x7ffff6f175bf in __libc_start_call_main (/lib64/libc.so.6+0x405bf)
    #19 0x7ffff6f1767b in __libc_start_main_alias_2 (/lib64/libc.so.6+0x4067b)
    #20 0xd0c1a4 in _start
(/home/marxin/Programming/gcc/objdir/gcc/go1+0xd0c1a4)


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63426
[Bug 63426] [meta-bug] Issues found with -fsanitize=undefined

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

* [Bug rtl-optimization/103437] gcc/ira-color.c:2813:5: runtime error: signed integer overflow: 15 * 147462000 cannot be represented in type 'int'
  2021-11-26  9:16 [Bug rtl-optimization/103437] New: gcc/ira-color.c:2813:5: runtime error: signed integer overflow: 15 * 147462000 cannot be represented in type 'int' marxin at gcc dot gnu.org
@ 2021-11-26 10:18 ` rguenth at gcc dot gnu.org
  2021-11-26 15:06 ` marxin at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-11-26 10:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Huh, how come - the code doesn't look like 147462000 could happen.
log2(int) * nregs * (costa - costb), so it's likely ALLOCNO_MEMORY_COST
or ALLOCNO_CLASS_COST.  Maybe uninitialized?

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

* [Bug rtl-optimization/103437] gcc/ira-color.c:2813:5: runtime error: signed integer overflow: 15 * 147462000 cannot be represented in type 'int'
  2021-11-26  9:16 [Bug rtl-optimization/103437] New: gcc/ira-color.c:2813:5: runtime error: signed integer overflow: 15 * 147462000 cannot be represented in type 'int' marxin at gcc dot gnu.org
  2021-11-26 10:18 ` [Bug rtl-optimization/103437] " rguenth at gcc dot gnu.org
@ 2021-11-26 15:06 ` marxin at gcc dot gnu.org
  2021-11-26 15:08 ` marxin at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-26 15:06 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-11-26
     Ever confirmed|0                           |1

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
No, it's not uninitialized. The function is gigantic and we really end up with
so huge COSTS (costs, i).

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

* [Bug rtl-optimization/103437] gcc/ira-color.c:2813:5: runtime error: signed integer overflow: 15 * 147462000 cannot be represented in type 'int'
  2021-11-26  9:16 [Bug rtl-optimization/103437] New: gcc/ira-color.c:2813:5: runtime error: signed integer overflow: 15 * 147462000 cannot be represented in type 'int' marxin at gcc dot gnu.org
  2021-11-26 10:18 ` [Bug rtl-optimization/103437] " rguenth at gcc dot gnu.org
  2021-11-26 15:06 ` marxin at gcc dot gnu.org
@ 2021-11-26 15:08 ` marxin at gcc dot gnu.org
  2021-11-26 15:10 ` marxin at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-26 15:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
With:

diff --git a/gcc/ira-costs.c b/gcc/ira-costs.c
index cb5ca8bc21b..ac993a9fa7d 100644
--- a/gcc/ira-costs.c
+++ b/gcc/ira-costs.c
@@ -1241,7 +1241,10 @@ record_address_regs (machine_mode mode, addr_space_t as,
rtx x,
        if (INT_MAX - add_cost < pp->mem_cost)
          pp->mem_cost = INT_MAX;
        else
+         {
+           fprintf (stderr, "pp->mem_cost: %d\n", pp->mem_cost);
          pp->mem_cost += add_cost;
+         }
        cost_classes_ptr = regno_cost_classes[regno];
        cost_classes = cost_classes_ptr->classes;
        pp_costs = pp->cost;

One can see the following pp->mem_cost update:
https://gist.githubusercontent.com/marxin/208e122d34463392dc8d6681af1d82a8/raw/1eba6184d44cd308151f0b385f6d079f29bedbd1/gistfile1.txt

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

* [Bug rtl-optimization/103437] gcc/ira-color.c:2813:5: runtime error: signed integer overflow: 15 * 147462000 cannot be represented in type 'int'
  2021-11-26  9:16 [Bug rtl-optimization/103437] New: gcc/ira-color.c:2813:5: runtime error: signed integer overflow: 15 * 147462000 cannot be represented in type 'int' marxin at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-11-26 15:08 ` marxin at gcc dot gnu.org
@ 2021-11-26 15:10 ` marxin at gcc dot gnu.org
  2021-11-29 15:57 ` vmakarov at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-26 15:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
Created attachment 51882
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51882&action=edit
Dump

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

* [Bug rtl-optimization/103437] gcc/ira-color.c:2813:5: runtime error: signed integer overflow: 15 * 147462000 cannot be represented in type 'int'
  2021-11-26  9:16 [Bug rtl-optimization/103437] New: gcc/ira-color.c:2813:5: runtime error: signed integer overflow: 15 * 147462000 cannot be represented in type 'int' marxin at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-11-26 15:10 ` marxin at gcc dot gnu.org
@ 2021-11-29 15:57 ` vmakarov at gcc dot gnu.org
  2021-12-02 13:52 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: vmakarov at gcc dot gnu.org @ 2021-11-29 15:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Vladimir Makarov <vmakarov at gcc dot gnu.org> ---
Thank you for reporting this.  This problem seems not that important as it is
only about heuristic costs and might be result only in worse performance code
generation (but might be in better code -- it is hard to say).

Still it is better not to remove this warning.  I'll look into this.

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

* [Bug rtl-optimization/103437] gcc/ira-color.c:2813:5: runtime error: signed integer overflow: 15 * 147462000 cannot be represented in type 'int'
  2021-11-26  9:16 [Bug rtl-optimization/103437] New: gcc/ira-color.c:2813:5: runtime error: signed integer overflow: 15 * 147462000 cannot be represented in type 'int' marxin at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-11-29 15:57 ` vmakarov at gcc dot gnu.org
@ 2021-12-02 13:52 ` cvs-commit at gcc dot gnu.org
  2021-12-02 16:01 ` cvs-commit at gcc dot gnu.org
  2021-12-02 17:39 ` cvs-commit at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-12-02 13:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Vladimir Makarov <vmakarov@gcc.gnu.org>:

https://gcc.gnu.org/g:d47393d0b4d0d498795c4ae1353e6c156c1c4500

commit r12-5714-gd47393d0b4d0d498795c4ae1353e6c156c1c4500
Author: Vladimir N. Makarov <vmakarov@redhat.com>
Date:   Thu Dec 2 08:29:45 2021 -0500

    [PR103437] Process multiplication overflow in priority calculation for
allocno assignments

    We process overflows in cost calculations but for huge functions
    priority calculation can overflow as priority can be bigger the cost
    used for it.  The patch fixes the problem.

    gcc/ChangeLog:

            PR rtl-optimization/103437
            * ira-color.c (setup_allocno_priorities): Process multiplication
            overflow.

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

* [Bug rtl-optimization/103437] gcc/ira-color.c:2813:5: runtime error: signed integer overflow: 15 * 147462000 cannot be represented in type 'int'
  2021-11-26  9:16 [Bug rtl-optimization/103437] New: gcc/ira-color.c:2813:5: runtime error: signed integer overflow: 15 * 147462000 cannot be represented in type 'int' marxin at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-12-02 13:52 ` cvs-commit at gcc dot gnu.org
@ 2021-12-02 16:01 ` cvs-commit at gcc dot gnu.org
  2021-12-02 17:39 ` cvs-commit at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-12-02 16:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Vladimir Makarov <vmakarov@gcc.gnu.org>:

https://gcc.gnu.org/g:7d02c8bf75980fa2468f4167a82dd3a619e35cb4

commit r12-5717-g7d02c8bf75980fa2468f4167a82dd3a619e35cb4
Author: Vladimir N. Makarov <vmakarov@redhat.com>
Date:   Thu Dec 2 10:55:59 2021 -0500

    [PR103437] Use long long multiplication as backup for overflow processing

    __builtin_smul_overflow can be unavailable for some C++ compilers.
    Add long long multiplication as backup for overflow processing.

    gcc/ChangeLog:
            PR rtl-optimization/103437
            * ira-color.c (setup_allocno_priorities): Use long long
            multiplication as backup for overflow processing.

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

* [Bug rtl-optimization/103437] gcc/ira-color.c:2813:5: runtime error: signed integer overflow: 15 * 147462000 cannot be represented in type 'int'
  2021-11-26  9:16 [Bug rtl-optimization/103437] New: gcc/ira-color.c:2813:5: runtime error: signed integer overflow: 15 * 147462000 cannot be represented in type 'int' marxin at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2021-12-02 16:01 ` cvs-commit at gcc dot gnu.org
@ 2021-12-02 17:39 ` cvs-commit at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-12-02 17:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Vladimir Makarov <vmakarov@gcc.gnu.org>:

https://gcc.gnu.org/g:cd47cd4b5eb2dfa7a3190e46a3ae93cc87dbe6b1

commit r12-5756-gcd47cd4b5eb2dfa7a3190e46a3ae93cc87dbe6b1
Author: Vladimir N. Makarov <vmakarov@redhat.com>
Date:   Thu Dec 2 12:31:28 2021 -0500

    [PR103437] Make backup code for overflow conditional

    Switch off long long variant overflow code by preprocessor if the
    build compiler has __builtin_smul_overflow.

    gcc/ChangeLog:
            PR rtl-optimization/103437
            * ira-color.c (setup_allocno_priorities): Switch off backup code
            for overflow if compiler has __builtin_smul_overflow.  Use <
            for comparison with -INT_MAX.

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

end of thread, other threads:[~2021-12-02 17:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-26  9:16 [Bug rtl-optimization/103437] New: gcc/ira-color.c:2813:5: runtime error: signed integer overflow: 15 * 147462000 cannot be represented in type 'int' marxin at gcc dot gnu.org
2021-11-26 10:18 ` [Bug rtl-optimization/103437] " rguenth at gcc dot gnu.org
2021-11-26 15:06 ` marxin at gcc dot gnu.org
2021-11-26 15:08 ` marxin at gcc dot gnu.org
2021-11-26 15:10 ` marxin at gcc dot gnu.org
2021-11-29 15:57 ` vmakarov at gcc dot gnu.org
2021-12-02 13:52 ` cvs-commit at gcc dot gnu.org
2021-12-02 16:01 ` cvs-commit at gcc dot gnu.org
2021-12-02 17:39 ` cvs-commit 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).