https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123478
Bug ID: 123478
Summary: ICE in probability_in_gcov_type, at
profile-count.h:323 with -O2 -fprofile-use
-fprofile-correction
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: gcov-profile
Assignee: unassigned at gcc dot gnu.org
Reporter: xintong.zhou1 at uwaterloo dot ca
Target Milestone: ---
Created attachment 63279
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63279&action=edit
The profile needed to reproduce the bug.
The ICE happens when I use the attached profile to compile test.c with PGO. I
only reduce the source file as much as possible. Sorry for not being able to
reduce the profile.
$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/home/x27zhou/compilers/gcc-trunk-install/libexec/gcc/x86_64-pc-linux-gnu/16.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --enable-checking=yes --disable-bootstrap
--disable-multilib --disable-shared --enable-languages=c,c++
--prefix=/home/x27zhou/compilers/gcc-trunk-install
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 16.0.0 20260107 (experimental) (GCC)
$
$
$ cat test.c
#include <assert.h>
#include <stdint.h>
int8_t a[1][7][7];
int32_t b, w, v, t, s, q, p, n, m, l, k, j, i, h, e, c;
int32_t d[1][1];
int32_t **f, **g;
long r, u;
static int32_t o(int8_t, int32_t, uint64_t);
static int32_t *func_20(int32_t, int16_t);
static uint8_t x() { o(0, a[0][1][4], 0); }
int32_t o(int8_t, int32_t aa, uint64_t) { func_20(0, aa); }
int32_t *func_20(int32_t, int16_t ad) {
int32_t *ae = &h;
int32_t *af = &d[5][0];
unsigned ag = 0;
for (; j - 3 && (p || ++ag); j = q) {
int32_t ah = r;
unsigned ai = 0;
for (; m <= 0 && (p || ai <= 0);) {
unsigned aj = 0;
for (b = s; b && (p || ++aj);) {
if (ad) {
unsigned ak = 0;
for (e = t; e && (p || ++ak); e++) {
if (c)
break;
u && (*ae = 0);
}
return *g;
}
*af = ah || *af;
}
for (ad = 3; ad;) {
for (i = 0; i < 2; i++)
for (c = 0; c < 2; c++)
for (k = 0; k < 10; k++)
;
unsigned al = 0;
for (c = 0; al <= 0;)
return 0;
}
}
}
assert(l || n);
for (e = 0; v && (p || b); e = w)
;
return *f;
}
void main() { x(); }
$
$
$ gcc-trunk -O2 -fprofile-use -fprofile-correction -o gcc-trunk.out test.c
test.c: In function ‘main’:
test.c:49:6: error: number of counters in profile data for function ‘main’ does
not match its profile data (counter ‘arcs’, expected 68 and have 2)
[-Werror=coverage-mismatch]
49 | void main() { x(); }
| ^~~~
test.c:49:6: error: the control flow of function ‘main’ does not match its
profile data (counter ‘time_profiler’) [-Werror=coverage-mismatch]
test.c: In function ‘func_20’:
test.c:12:10: error: source locations for function ‘func_20’ have changed, the
profile data may be out of date [-Werror=coverage-mismatch]
12 | int32_t *func_20(int32_t, int16_t ad) {
| ^~~~~~~
during IPA pass: profile
test.c:49:1: internal compiler error: in probability_in_gcov_type, at
profile-count.h:323
49 | void main() { x(); }
| ^~~~
cc1: some warnings being treated as errors
0x25b8ffb internal_error(char const*, ...)
../../gcc/gcc/diagnostic-global-context.cc:787
0xa1ba4e fancy_abort(char const*, int, char const*)
../../gcc/gcc/diagnostics/context.cc:1805
0x9fa18e profile_probability::probability_in_gcov_type(long, long)
../../gcc/gcc/profile-count.h:323
0x9fa18e profile_probability::probability_in_gcov_type(long, long)
../../gcc/gcc/profile-count.h:319
0x9fa18e adjust_cfg_counts
../../gcc/gcc/mcf.cc:1235
0x9fa18e mcf_smooth_cfg()
../../gcc/gcc/mcf.cc:1382
0x10d5d3a compute_branch_probabilities
../../gcc/gcc/profile.cc:663
0x10d8617 branch_prob(bool)
../../gcc/gcc/profile.cc:1605
0x12d7be6 tree_profiling
../../gcc/gcc/tree-profile.cc:1945
0x12d7be6 execute
../../gcc/gcc/tree-profile.cc:2075
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.