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

            Bug ID: 120143
           Summary: [16 Regression] RISC-V: ICE with -flto on undefined
                    extern var in verify_ssa
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ewlu at rivosinc dot com
  Target Milestone: ---

testcase:
short a;
extern _Bool b[][23];
short g = 6;
int v[4];
int x[3];
void c(short g, int v[], int x[]) {
  for (;;)
    for (unsigned y = 0; y < 023; y++) {
      b[y][y] = v[y];
      for (_Bool aa = 0; aa < (_Bool)g; aa = x[y])
        a = a > 0;
    }
}
int main() { c(g, v, x); }

command/backtrace:
$
/scratch/ewlu/daily-upstream-build/build-gcv/bin/riscv64-unknown-linux-gnu-gcc
-I/scratch/ewlu/ci/compiler-fuzz-ci/csmith-build/include -fsigned-char
-fno-strict-aliasing -fwrapv -march=rv64gcv_zvl256b -O3 -flto red.c -o
rv64gcv.out -w
red.c: In function 'main':
red.c:971:5: error: definition in block 43 follows the use
  971 | int main() {
      |     ^
for SSA_NAME: .MEM_1316 in statement:
# VUSE <.MEM_1316>
vect__272.57_1344 = MEM <vector(8) unsigned int> [(unsigned int
*)vectp_arr_15.55_1346];
during GIMPLE pass: vect
red.c:971:5: internal compiler error: verify_ssa failed
0x2fdd496 internal_error(char const*, ...)
        ../../../gcc/gcc/diagnostic-global-context.cc:517
0x158311f verify_ssa(bool, bool)
        ../../../gcc/gcc/tree-ssa.cc:1203
0x11be865 execute_function_todo
        ../../../gcc/gcc/passes.cc:2108
0x11becfe execute_todo
        ../../../gcc/gcc/passes.cc:2155
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.
lto-wrapper: fatal error:
/scratch/ewlu/daily-upstream-build/build-gcv/bin/riscv64-unknown-linux-gnu-gcc
returned 1 exit status
compilation terminated.
/scratch/ewlu/daily-upstream-build/build-gcv/lib/gcc/riscv64-unknown-linux-gnu/16.0.0/../../../../riscv64-unknown-linux-gnu/bin/ld:
error: lto-wrapper failed

We should be seeing an "undefined reference to `b'" error instead of an ice.
Problem is caused somewhere along the flto codepath. Not sure if it's an lto
bug or a RISC-V bug

godbolt: https://godbolt.org/z/Eqo4q5YTP

found via fuzzer

Reply via email to