llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.8k stars 11.9k forks source link

clang15/mips backend: failed to perform tail call elimination on a call site marked musttail #57795

Open kraj opened 2 years ago

kraj commented 2 years ago

clang crashed with the attached testcase from grpcio-tools on mips

1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'third_party/protobuf/src/google/protobuf/generated_message_tctable_lite.cc'.
4.      Running pass 'MIPS DAG->DAG Pattern Instruction Selection' on function '@_ZN6google8protobuf8internal8TcParser13SingularFixedIyhEEPKcPNS0_11MessageLiteES5_PNS1_12ParseContextEPKNS1_16TcParseTableBaseEyNS1_11TcFieldDataE'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):

generated_message_tctable_lite-9b6bf4.tar.gz

llvmbot commented 2 years ago

@llvm/issue-subscribers-backend-mips

kraj commented 2 years ago

a workaround for now is to disable musttail attribute usage in grpcio-tools

icepic commented 1 year ago

I see that while compiling protobuf on MIPS64/OpenBSD too.

fatal error: error in backend: failed to perform tail call elimination on a call site marked musttail
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /usr/bin/c++ -B /usr/ports/pobj/protobuf-3.21.12/bin -DHAVE_CONFIG_H -I. -I/usr/ports/pobj/protobuf-3.21.12/protobuf-3.21.12/src -I.. -pthread -DHAVE_PTHREAD=1 -DHAVE_ZLIB=1 -Wall -Wno-sign-compare -O2 -pipe -MT google/protobuf/generated_message_tctable_lite.lo -MD -MP -MF google/protobuf/.deps/generated_message_tctable_lite.Tpo -c /usr/ports/pobj/protobuf-3.21.12/protobuf-3.21.12/src/google/protobuf/generated_message_tctable_lite.cc -fPIC -DPIC -o google/protobuf/.libs/generated_message_tctable_lite.o
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module '/usr/ports/pobj/protobuf-3.21.12/protobuf-3.21.12/src/google/protobuf/generated_message_tctable_lite.cc'.
4.      Running pass 'MIPS DAG->DAG Pattern Instruction Selection' on function '@_ZN6google8protobuf8internal8TcParser9MiniParseEPNS0_11MessageLiteEPKcPNS1_12ParseContextEPKNS1_16TcParseTableBaseEyNS1_11TcFieldDataE'
c++: error: clang frontend command failed with exit code 70 (use -v to see invocation)
OpenBSD clang version 13.0.0
Target: mips64-unknown-openbsd7.2
Thread model: posix
InstalledDir: /usr/bin
c++: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
c++: note: diagnostic msg: /tmp/generated_message_tctable_lite-e5cce2.cpp
c++: note: diagnostic msg: /tmp/generated_message_tctable_lite-e5cce2.sh
c++: note: diagnostic msg: 

********************
Error while executing c++ -DHAVE_CONFIG_H -I. -I/usr/ports/pobj/protobuf-3.21.12/protobuf-3.21.12/src -I.. -pthread -DHAVE_PTHREAD=1 -DHAVE_ZLIB=1 -Wall -Wno-sign-compare -O2 -pipe -MT google/protobuf/generated_message_tctable_lite.lo -MD -MP -MF google/protobuf/.deps/generated_message_tctable_lite.Tpo -c /usr/ports/pobj/protobuf-3.21.12/protobuf-3.21.12/src/google/protobuf/generated_message_tctable_lite.cc -fPIC -DPIC -o google/protobuf/.libs/generated_message_tctable_lite.o
InBetweenNames commented 1 month ago

This can be worked around with -mllvm -mips-tail-calls=1, which seems to enable tail call optimization for MIPS in Clang. It appears this option is off by default at all optimization levels, but it is unclear why.