Issue 202894
Summary [LLVM] [RISCV] [LTO] Bad machine code generated at -O2/-O3 with unresolved extern globals and -march=rv64gcv
Labels new issue
Assignees
Reporter whileone-sk
    Compiling the testcase with clang LTO enabled (-flto) for RISC-V Vector (-march=rv64gcv) causes LLVM to generate invalid machine code, resulting in a "Bad machine code" backend failure during code generation. The issue reproduces at both -O2 and -O3 and appears related to unresolved extern globals during LTO processing.

Reproducer command:
```
/riscv-gnu-toolchain-build/bin/clang \
-I/compiler-fuzz-ci/csmith-build/include \
-fsigned-char -fno-strict-aliasing -fwrapv -march=rv64gcv -flto -O3 \
red.c -o rv64gcv.out -w
```

Attachments:
Reduced testcase [red.c](https://github.com/user-attachments/files/28787695/red.c)
Compiler opt [compiler-opts.txt](https://github.com/user-attachments/files/28787519/compiler-opts.txt)
Verbose trace [verbose.txt](https://github.com/user-attachments/files/28787526/verbose.txt)

Verbose error logs:
```
*** Bad machine code: Virtual register defs don't dominate all uses. ***
...
LLVM ERROR: Found 1 machine code errors.
```

Verified on clang version 23.0.0git (https://github.com/llvm/llvm-project.git 4b4d43da80fe66bf668a7b9a00fa5842db5c55d7)

This issue is Found via fuzzer.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to