Bug 82395 - [8 Regression] qsort comparator non-negative on sorted output: 1 in color_allocnos
Summary: [8 Regression] qsort comparator non-negative on sorted output: 1 in color_all...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: 8.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-checking, ice-on-valid-code
: 82482 (view as bug list)
Depends on:
Blocks: qsort_chk
  Show dependency treegraph
 
Reported: 2017-10-02 11:39 UTC by Martin Liška
Modified: 2017-10-19 16:50 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-10-05 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2017-10-02 11:39:53 UTC
After Alexander added the validation (r253295), we ICE on:

./xgcc -B. /home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/tree-prof/pr44777.c  -fira-algorithm=priority -Og
/home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/tree-prof/pr44777.c: In function ‘y’:
/home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/tree-prof/pr44777.c:31:5: error: qsort comparator non-negative on sorted output: 1
     }
     ^
during RTL pass: ira
/home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/tree-prof/pr44777.c:31:5: internal compiler error: qsort checking failed
0x1b54377 qsort_chk_error
	../../gcc/vec.c:222
0x1b5473f qsort_chk(void*, unsigned long, unsigned long, int (*)(void const*, void const*))
	../../gcc/vec.c:274
0xd12e34 color_allocnos
	../../gcc/ira-color.c:3087
0xd13887 color_pass
	../../gcc/ira-color.c:3261
0xcf81b3 ira_traverse_loop_tree(bool, ira_loop_tree_node*, void (*)(ira_loop_tree_node*), void (*)(ira_loop_tree_node*))
	../../gcc/ira-build.c:1781
0xd141f6 do_coloring
	../../gcc/ira-color.c:3412
0xd17f38 color
	../../gcc/ira-color.c:4782
0xd185a4 ira_color()
	../../gcc/ira-color.c:4897
0xcf2c3f ira
	../../gcc/ira.c:5283
0xcf340e execute
	../../gcc/ira.c:5581
Comment 1 Alexander Monakov 2017-10-05 15:26:10 UTC
I posted a candidate patch for review at https://gcc.gnu.org/ml/gcc-patches/2017-10/msg00271.html
Comment 2 Steve Ellcey 2017-10-05 16:04:31 UTC
I tried the patch on an aarch64 bootstrap and it still fails, though the trace looks different.

/home/sellcey/gcc-stdc/obj/gcc/aarch64-unknown-linux-gnu/libstdc++-v3/include/bits/deque.tcc:626:7: error: qsort comparator non-negative on sorted output: 8
       }
       ^
during RTL pass: sched2
/home/sellcey/gcc-stdc/obj/gcc/aarch64-unknown-linux-gnu/libstdc++-v3/include/bits/deque.tcc:626:7: internal compiler error: qsort checking failed
0x1d1c5c7 qsort_chk_error
        ../../../src/gcc/gcc/vec.c:222
0x1d1c9e7 qsort_chk(void*, unsigned long, unsigned long, int (*)(void const*, void const*))
        ../../../src/gcc/gcc/vec.c:274
0x1be2ebf ready_sort_real
        ../../../src/gcc/gcc/haifa-sched.c:3087
0x1be2f53 ready_sort
        ../../../src/gcc/gcc/haifa-sched.c:3103
0x1bede13 schedule_block(basic_block_def**, void*)
        ../../../src/gcc/gcc/haifa-sched.c:6749
0x1285b9f schedule_region
        ../../../src/gcc/gcc/sched-rgn.c:3174
0x1286da3 schedule_insns()
        ../../../src/gcc/gcc/sched-rgn.c:3513
0x1287acf rest_of_handle_sched2
        ../../../src/gcc/gcc/sched-rgn.c:3737
0x1287d2f execute
        ../../../src/gcc/gcc/sched-rgn.c:3873
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Comment 3 Steve Ellcey 2017-10-05 16:33:41 UTC
I am not sure if PR 82385 and PR 82396 are different bugs or not, they both involve qsort problems.  I guess the aarch64 failure is PR 82396 and not this one, PR 82395.
Comment 4 Alexander Monakov 2017-10-09 08:53:24 UTC
*** Bug 82482 has been marked as a duplicate of this bug. ***
Comment 5 Alexander Monakov 2017-10-19 16:49:05 UTC
Author: amonakov
Date: Thu Oct 19 16:48:34 2017
New Revision: 253904

URL: https://gcc.gnu.org/viewcvs?rev=253904&root=gcc&view=rev
Log:
ira-color: fix allocno_priority_compare_func for qsort (PR 82395)

	PR rtl-optimization/82395
	* ira-color.c (allocno_priority_compare_func): Fix comparison step
	based on non_spilled_static_chain_regno_p.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ira-color.c
Comment 6 Alexander Monakov 2017-10-19 16:50:19 UTC
Fixed.