Bug 84068 - [8 Regression] ICE: qsort checking failed: qsort comparator non-negative on sorted output: 1 with -fno-sched-critical-path-heuristic --param=max-sched-extend-regions-iters=5 @ aarch64
Summary: [8 Regression] ICE: qsort checking failed: qsort comparator non-negative on s...
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: Wilco
URL:
Keywords: ice-checking, ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2018-01-26 17:12 UTC by Zdenek Sojka
Modified: 2018-02-08 12:33 UTC (History)
1 user (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: aarch64-unknown-linux-gnu
Build:
Known to work:
Known to fail: 8.0
Last reconfirmed: 2018-01-30 00:00:00


Attachments
reduced testcase (118 bytes, text/plain)
2018-01-26 17:12 UTC, Zdenek Sojka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2018-01-26 17:12:53 UTC
Created attachment 43258 [details]
reduced testcase

Compiler output:
$ aarch64-unknown-linux-gnu-gcc -O2 -fno-sched-critical-path-heuristic -fno-sched-rank-heuristic --param=max-sched-extend-regions-iters=5 testcase.c 
testcase.c: In function 'foo':
testcase.c:7:1: error: qsort comparator non-negative on sorted output: 1
 }
 ^
during RTL pass: sched1
testcase.c:7:1: internal compiler error: qsort checking failed
0x5ec995 qsort_chk_error
        /repo/gcc-trunk/gcc/vec.c:201
0x156d5ca qsort_chk(void*, unsigned long, unsigned long, int (*)(void const*, void const*))
        /repo/gcc-trunk/gcc/vec.c:253
0x146c640 ready_sort_real
        /repo/gcc-trunk/gcc/haifa-sched.c:3087
0x14756ca schedule_block(basic_block_def**, void*)
        /repo/gcc-trunk/gcc/haifa-sched.c:6675
0xc1b7da schedule_region
        /repo/gcc-trunk/gcc/sched-rgn.c:3174
0xc1b7da schedule_insns()
        /repo/gcc-trunk/gcc/sched-rgn.c:3513
0xc1bc03 schedule_insns()
        /repo/gcc-trunk/gcc/sched-rgn.c:3498
0xc1bc03 rest_of_handle_sched
        /repo/gcc-trunk/gcc/sched-rgn.c:3717
0xc1bc03 execute
        /repo/gcc-trunk/gcc/sched-rgn.c:3825
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.

$ aarch64-unknown-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-aarch64/bin/aarch64-unknown-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-257087-checking-yes-rtl-df-extra-aarch64/bin/../libexec/gcc/aarch64-unknown-linux-gnu/8.0.1/lto-wrapper
Target: aarch64-unknown-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++ --enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra --with-cloog --with-ppl --with-isl --with-sysroot=/usr/aarch64-unknown-linux-gnu --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=aarch64-unknown-linux-gnu --with-ld=/usr/bin/aarch64-unknown-linux-gnu-ld --with-as=/usr/bin/aarch64-unknown-linux-gnu-as --disable-libstdcxx-pch --prefix=/repo/gcc-trunk//binary-trunk-257087-checking-yes-rtl-df-extra-aarch64
Thread model: posix
gcc version 8.0.1 20180126 (experimental) (GCC)
Comment 1 Aldy Hernandez 2018-01-30 01:47:57 UTC
Confirmed.
Comment 2 Aldy Hernandez 2018-01-30 02:43:09 UTC
This may be a latent bug when the scheduling pressure model was changed, but FWIW, this started with r254378.
Comment 3 Wilco 2018-01-30 14:53:53 UTC
(In reply to Aldy Hernandez from comment #2)
> This may be a latent bug when the scheduling pressure model was changed, but
> FWIW, this started with r254378.

Yes it's latent and the fix is trivial. Testing to see whether it affects codequality.
Comment 4 Aldy Hernandez 2018-01-30 22:04:15 UTC
> Yes it's latent and the fix is trivial. Testing to see whether it affects
> codequality.

Thanks Wilco, I appreciate it.  Errr, we all do :).
Comment 5 Wilco 2018-02-08 12:30:00 UTC
Author: wilco
Date: Thu Feb  8 12:29:28 2018
New Revision: 257481

URL: https://gcc.gnu.org/viewcvs?rev=257481&root=gcc&view=rev
Log:
PR84068, PR83459: Fix sort order of SCHED_PRESSURE_MODEL

The comparison function for SCHED_PRESSURE_MODEL is incorrect.  If either
instruction is not in target_bb, the ordering is not well defined.  
Since all instructions outside the target_bb get the highest model_index,
all we need to do is sort on model_index.  If the model_index is the same
we defer to RFS_DEP_COUNT and/or RFS_TIE.

    gcc/
	PR rtl-optimization/84068
	PR rtl-optimization/83459
	* haifa-sched.c (rank_for_schedule): Fix SCHED_PRESSURE_MODEL sorting.

    gcc/testsuite
	PR rtl-optimization/84068
	PR rtl-optimization/83459
	* gcc.dg/pr84068.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr84068.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/haifa-sched.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 Wilco 2018-02-08 12:33:58 UTC
Fixed in r257481.