llvm / llvm-project

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

[RISC-V] Unhandled encodeInstruction length! at RISCVMCCodeEmitter.cpp:338 with `-fglobal-isel -fstack-protector-all` #88046

Open patrick-rivos opened 5 months ago

patrick-rivos commented 5 months ago

Testcase:

int main() {}

Backtrace:

> /scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang -fglobal-isel -fstack-protector-all red.c -o rv64gcv.out -w
Unhandled encodeInstruction length!
UNREACHABLE executed at /scratch/tc-testing/tc-apr-4/llvm/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp:338!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19 -cc1 -triple riscv64-unknown-linux-gnu -emit-obj -mrelax-all -dumpdir rv64gcv.out- -disable-free -clear-ast-before-backend -main-file-name red.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic-rv64 -target-feature +m -target-feature +a -target-feature +f -target-feature +d -target-feature +c -target-feature +zicsr -target-feature -e -target-feature -h -target-feature -shcounterenw -target-feature -shgatpa -target-feature -shtvala -target-feature -shvsatpa -target-feature -shvstvala -target-feature -shvstvecd -target-feature -smaia -target-feature -smepmp -target-feature -ssaia -target-feature -ssccptr -target-feature -sscofpmf -target-feature -sscounterenw -target-feature -ssstateen -target-feature -ssstrict -target-feature -sstc -target-feature -sstvala -target-feature -sstvecd -target-feature -ssu64xl -target-feature -svade -target-feature -svadu -target-feature -svbare -target-feature -svinval -target-feature -svnapot -target-feature -svpbmt -target-feature -v -target-feature -xcvalu -target-feature -xcvbi -target-feature -xcvbitmanip -target-feature -xcvelw -target-feature -xcvmac -target-feature -xcvmem -target-feature -xcvsimd -target-feature -xsfcease -target-feature -xsfvcp -target-feature -xsfvfnrclipxfqf -target-feature -xsfvfwmaccqqq -target-feature -xsfvqmaccdod -target-feature -xsfvqmaccqoq -target-feature -xsifivecdiscarddlone -target-feature -xsifivecflushdlone -target-feature -xtheadba -target-feature -xtheadbb -target-feature -xtheadbs -target-feature -xtheadcmo -target-feature -xtheadcondmov -target-feature -xtheadfmemidx -target-feature -xtheadmac -target-feature -xtheadmemidx -target-feature -xtheadmempair -target-feature -xtheadsync -target-feature -xtheadvdot -target-feature -xventanacondops -target-feature -za128rs -target-feature -za64rs -target-feature -zacas -target-feature -zawrs -target-feature -zba -target-feature -zbb -target-feature -zbc -target-feature -zbkb -target-feature -zbkc -target-feature -zbkx -target-feature -zbs -target-feature -zca -target-feature -zcb -target-feature -zcd -target-feature -zce -target-feature -zcf -target-feature -zcmp -target-feature -zcmt -target-feature -zdinx -target-feature -zfa -target-feature -zfh -target-feature -zfhmin -target-feature -zfinx -target-feature -zhinx -target-feature -zhinxmin -target-feature -zic64b -target-feature -zicbom -target-feature -zicbop -target-feature -zicboz -target-feature -ziccamoa -target-feature -ziccif -target-feature -zicclsm -target-feature -ziccrse -target-feature -zicntr -target-feature -zicond -target-feature -zifencei -target-feature -zihintntl -target-feature -zihintpause -target-feature -zihpm -target-feature -zk -target-feature -zkn -target-feature -zknd -target-feature -zkne -target-feature -zknh -target-feature -zkr -target-feature -zks -target-feature -zksed -target-feature -zksh -target-feature -zkt -target-feature -zmmul -target-feature -zvbb -target-feature -zvbc -target-feature -zve32f -target-feature -zve32x -target-feature -zve64d -target-feature -zve64f -target-feature -zve64x -target-feature -zvfh -target-feature -zvfhmin -target-feature -zvkb -target-feature -zvkg -target-feature -zvkn -target-feature -zvknc -target-feature -zvkned -target-feature -zvkng -target-feature -zvknha -target-feature -zvknhb -target-feature -zvks -target-feature -zvksc -target-feature -zvksed -target-feature -zvksg -target-feature -zvksh -target-feature -zvkt -target-feature -zvl1024b -target-feature -zvl128b -target-feature -zvl16384b -target-feature -zvl2048b -target-feature -zvl256b -target-feature -zvl32768b -target-feature -zvl32b -target-feature -zvl4096b -target-feature -zvl512b -target-feature -zvl64b -target-feature -zvl65536b -target-feature -zvl8192b -target-feature -experimental-smmpm -target-feature -experimental-smnpm -target-feature -experimental-ssnpm -target-feature -experimental-sspm -target-feature -experimental-ssqosid -target-feature -experimental-supm -target-feature -experimental-zaamo -target-feature -experimental-zabha -target-feature -experimental-zalasr -target-feature -experimental-zalrsc -target-feature -experimental-zcmop -target-feature -experimental-zfbfmin -target-feature -experimental-zicfilp -target-feature -experimental-zicfiss -target-feature -experimental-zimop -target-feature -experimental-ztso -target-feature -experimental-zvfbfmin -target-feature -experimental-zvfbfwma -target-feature +relax -target-abi lp64d -msmall-data-limit 8 -debugger-tuning=gdb -fdebug-compilation-dir=/scratch/tc-testing/compiler-fuzz-ci/csmith-discoveries/llvm-rand-opt-28-2 -fcoverage-compilation-dir=/scratch/tc-testing/compiler-fuzz-ci/csmith-discoveries/llvm-rand-opt-28-2 -resource-dir /scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/lib/clang/19 -isysroot /scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/../sysroot -internal-isystem /scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/lib/clang/19/include -internal-isystem /scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/../sysroot/usr/local/include -internal-isystem /scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/../sysroot/lib/gcc/riscv64-unknown-linux-gnu/14.0.1/../../../../riscv64-unknown-linux-gnu/include -internal-externc-isystem /scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/../sysroot/include -internal-externc-isystem /scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/../sysroot/usr/include -w -ferror-limit 19 -stack-protector 3 -fno-signed-char -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -mllvm -global-isel=1 -mllvm -global-isel-abort=2 -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /scratch/tmp/red-433ceb.o -x c red.c
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'red.c'.
4.      Running pass 'RISC-V Assembly Printer' on function '@main'
 #0 0x00005e374f451730 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x1e50730)
 #1 0x00005e374f44eb3f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x1e4db3f)
 #2 0x00005e374f44ec95 SignalHandler(int) Signals.cpp:0:0
 #3 0x000070511b442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x000070511b4969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x000070511b4969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x000070511b4969fc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x000070511b442476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x000070511b4287f3 abort ./stdlib/abort.c:81:7
 #9 0x00005e374f3a703e (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x1da603e)
#10 0x00005e374e4e823b (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0xee723b)
#11 0x00005e374f14045d llvm::MCELFStreamer::emitInstToData(llvm::MCInst const&, llvm::MCSubtargetInfo const&) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x1b3f45d)
#12 0x00005e374f161bbe llvm::MCObjectStreamer::emitInstruction(llvm::MCInst const&, llvm::MCSubtargetInfo const&) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x1b60bbe)
#13 0x00005e374e30e37a (anonymous namespace)::RISCVAsmPrinter::EmitToStreamer(llvm::MCStreamer&, llvm::MCInst const&) (.constprop.0) RISCVAsmPrinter.cpp:0:0
#14 0x00005e374e31305f (anonymous namespace)::RISCVAsmPrinter::emitInstruction(llvm::MachineInstr const*) RISCVAsmPrinter.cpp:0:0
#15 0x00005e37501e29af llvm::AsmPrinter::emitFunctionBody() (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x2be19af)
#16 0x00005e374e310108 (anonymous namespace)::RISCVAsmPrinter::runOnMachineFunction(llvm::MachineFunction&) RISCVAsmPrinter.cpp:0:0
#17 0x00005e374e896717 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#18 0x00005e374ef03066 llvm::FPPassManager::runOnFunction(llvm::Function&) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x1902066)
#19 0x00005e374ef032b9 llvm::FPPassManager::runOnModule(llvm::Module&) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x19022b9)
#20 0x00005e374ef03c25 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x1902c25)
#21 0x00005e374f6ae92c clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x20ad92c)
#22 0x00005e374fccbab7 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x26caab7)
#23 0x00005e375194a15c clang::ParseAST(clang::Sema&, bool, bool) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x434915c)
#24 0x00005e374ff63539 clang::FrontendAction::Execute() (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x2962539)
#25 0x00005e374fee7856 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x28e6856)
#26 0x00005e3750034ee5 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x2a33ee5)
#27 0x00005e374e2feeaf cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0xcfdeaf)
#28 0x00005e374e2f8593 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#29 0x00005e374e2fb30f clang_main(int, char**, llvm::ToolContext const&) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0xcfa30f)
#30 0x00005e374e2399eb main (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0xc389eb)
#31 0x000070511b429d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#32 0x000070511b429e40 call_init ./csu/../csu/libc-start.c:128:20
#33 0x000070511b429e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#34 0x00005e374e2f7845 _start (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0xcf6845)
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 19.0.0git (https://github.com/llvm/llvm-project.git 1b761205f2686516cebadbcbc37f798197d9c482)
Target: riscv64-unknown-linux-gnu
Thread model: posix
InstalledDir: /scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin

Godbolt: https://godbolt.org/z/sj85e83jh

Found via fuzzer

llvmbot commented 5 months ago

@llvm/issue-subscribers-backend-risc-v

Author: Patrick O'Neill (patrick-rivos)

Testcase: ```c int main() {} ``` Backtrace: ``` > /scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang -fglobal-isel -fstack-protector-all red.c -o rv64gcv.out -w Unhandled encodeInstruction length! UNREACHABLE executed at /scratch/tc-testing/tc-apr-4/llvm/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp:338! PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump: 0. Program arguments: /scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19 -cc1 -triple riscv64-unknown-linux-gnu -emit-obj -mrelax-all -dumpdir rv64gcv.out- -disable-free -clear-ast-before-backend -main-file-name red.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic-rv64 -target-feature +m -target-feature +a -target-feature +f -target-feature +d -target-feature +c -target-feature +zicsr -target-feature -e -target-feature -h -target-feature -shcounterenw -target-feature -shgatpa -target-feature -shtvala -target-feature -shvsatpa -target-feature -shvstvala -target-feature -shvstvecd -target-feature -smaia -target-feature -smepmp -target-feature -ssaia -target-feature -ssccptr -target-feature -sscofpmf -target-feature -sscounterenw -target-feature -ssstateen -target-feature -ssstrict -target-feature -sstc -target-feature -sstvala -target-feature -sstvecd -target-feature -ssu64xl -target-feature -svade -target-feature -svadu -target-feature -svbare -target-feature -svinval -target-feature -svnapot -target-feature -svpbmt -target-feature -v -target-feature -xcvalu -target-feature -xcvbi -target-feature -xcvbitmanip -target-feature -xcvelw -target-feature -xcvmac -target-feature -xcvmem -target-feature -xcvsimd -target-feature -xsfcease -target-feature -xsfvcp -target-feature -xsfvfnrclipxfqf -target-feature -xsfvfwmaccqqq -target-feature -xsfvqmaccdod -target-feature -xsfvqmaccqoq -target-feature -xsifivecdiscarddlone -target-feature -xsifivecflushdlone -target-feature -xtheadba -target-feature -xtheadbb -target-feature -xtheadbs -target-feature -xtheadcmo -target-feature -xtheadcondmov -target-feature -xtheadfmemidx -target-feature -xtheadmac -target-feature -xtheadmemidx -target-feature -xtheadmempair -target-feature -xtheadsync -target-feature -xtheadvdot -target-feature -xventanacondops -target-feature -za128rs -target-feature -za64rs -target-feature -zacas -target-feature -zawrs -target-feature -zba -target-feature -zbb -target-feature -zbc -target-feature -zbkb -target-feature -zbkc -target-feature -zbkx -target-feature -zbs -target-feature -zca -target-feature -zcb -target-feature -zcd -target-feature -zce -target-feature -zcf -target-feature -zcmp -target-feature -zcmt -target-feature -zdinx -target-feature -zfa -target-feature -zfh -target-feature -zfhmin -target-feature -zfinx -target-feature -zhinx -target-feature -zhinxmin -target-feature -zic64b -target-feature -zicbom -target-feature -zicbop -target-feature -zicboz -target-feature -ziccamoa -target-feature -ziccif -target-feature -zicclsm -target-feature -ziccrse -target-feature -zicntr -target-feature -zicond -target-feature -zifencei -target-feature -zihintntl -target-feature -zihintpause -target-feature -zihpm -target-feature -zk -target-feature -zkn -target-feature -zknd -target-feature -zkne -target-feature -zknh -target-feature -zkr -target-feature -zks -target-feature -zksed -target-feature -zksh -target-feature -zkt -target-feature -zmmul -target-feature -zvbb -target-feature -zvbc -target-feature -zve32f -target-feature -zve32x -target-feature -zve64d -target-feature -zve64f -target-feature -zve64x -target-feature -zvfh -target-feature -zvfhmin -target-feature -zvkb -target-feature -zvkg -target-feature -zvkn -target-feature -zvknc -target-feature -zvkned -target-feature -zvkng -target-feature -zvknha -target-feature -zvknhb -target-feature -zvks -target-feature -zvksc -target-feature -zvksed -target-feature -zvksg -target-feature -zvksh -target-feature -zvkt -target-feature -zvl1024b -target-feature -zvl128b -target-feature -zvl16384b -target-feature -zvl2048b -target-feature -zvl256b -target-feature -zvl32768b -target-feature -zvl32b -target-feature -zvl4096b -target-feature -zvl512b -target-feature -zvl64b -target-feature -zvl65536b -target-feature -zvl8192b -target-feature -experimental-smmpm -target-feature -experimental-smnpm -target-feature -experimental-ssnpm -target-feature -experimental-sspm -target-feature -experimental-ssqosid -target-feature -experimental-supm -target-feature -experimental-zaamo -target-feature -experimental-zabha -target-feature -experimental-zalasr -target-feature -experimental-zalrsc -target-feature -experimental-zcmop -target-feature -experimental-zfbfmin -target-feature -experimental-zicfilp -target-feature -experimental-zicfiss -target-feature -experimental-zimop -target-feature -experimental-ztso -target-feature -experimental-zvfbfmin -target-feature -experimental-zvfbfwma -target-feature +relax -target-abi lp64d -msmall-data-limit 8 -debugger-tuning=gdb -fdebug-compilation-dir=/scratch/tc-testing/compiler-fuzz-ci/csmith-discoveries/llvm-rand-opt-28-2 -fcoverage-compilation-dir=/scratch/tc-testing/compiler-fuzz-ci/csmith-discoveries/llvm-rand-opt-28-2 -resource-dir /scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/lib/clang/19 -isysroot /scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/../sysroot -internal-isystem /scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/lib/clang/19/include -internal-isystem /scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/../sysroot/usr/local/include -internal-isystem /scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/../sysroot/lib/gcc/riscv64-unknown-linux-gnu/14.0.1/../../../../riscv64-unknown-linux-gnu/include -internal-externc-isystem /scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/../sysroot/include -internal-externc-isystem /scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/../sysroot/usr/include -w -ferror-limit 19 -stack-protector 3 -fno-signed-char -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -mllvm -global-isel=1 -mllvm -global-isel-abort=2 -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /scratch/tmp/red-433ceb.o -x c red.c 1. <eof> parser at end of file 2. Code generation 3. Running pass 'Function Pass Manager' on module 'red.c'. 4. Running pass 'RISC-V Assembly Printer' on function '@main' #0 0x00005e374f451730 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x1e50730) #1 0x00005e374f44eb3f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x1e4db3f) #2 0x00005e374f44ec95 SignalHandler(int) Signals.cpp:0:0 #3 0x000070511b442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520) #4 0x000070511b4969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76 #5 0x000070511b4969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10 #6 0x000070511b4969fc pthread_kill ./nptl/pthread_kill.c:89:10 #7 0x000070511b442476 gsignal ./signal/../sysdeps/posix/raise.c:27:6 #8 0x000070511b4287f3 abort ./stdlib/abort.c:81:7 #9 0x00005e374f3a703e (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x1da603e) #10 0x00005e374e4e823b (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0xee723b) #11 0x00005e374f14045d llvm::MCELFStreamer::emitInstToData(llvm::MCInst const&, llvm::MCSubtargetInfo const&) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x1b3f45d) #12 0x00005e374f161bbe llvm::MCObjectStreamer::emitInstruction(llvm::MCInst const&, llvm::MCSubtargetInfo const&) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x1b60bbe) #13 0x00005e374e30e37a (anonymous namespace)::RISCVAsmPrinter::EmitToStreamer(llvm::MCStreamer&, llvm::MCInst const&) (.constprop.0) RISCVAsmPrinter.cpp:0:0 #14 0x00005e374e31305f (anonymous namespace)::RISCVAsmPrinter::emitInstruction(llvm::MachineInstr const*) RISCVAsmPrinter.cpp:0:0 #15 0x00005e37501e29af llvm::AsmPrinter::emitFunctionBody() (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x2be19af) #16 0x00005e374e310108 (anonymous namespace)::RISCVAsmPrinter::runOnMachineFunction(llvm::MachineFunction&) RISCVAsmPrinter.cpp:0:0 #17 0x00005e374e896717 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0 #18 0x00005e374ef03066 llvm::FPPassManager::runOnFunction(llvm::Function&) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x1902066) #19 0x00005e374ef032b9 llvm::FPPassManager::runOnModule(llvm::Module&) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x19022b9) #20 0x00005e374ef03c25 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x1902c25) #21 0x00005e374f6ae92c clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x20ad92c) #22 0x00005e374fccbab7 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x26caab7) #23 0x00005e375194a15c clang::ParseAST(clang::Sema&, bool, bool) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x434915c) #24 0x00005e374ff63539 clang::FrontendAction::Execute() (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x2962539) #25 0x00005e374fee7856 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x28e6856) #26 0x00005e3750034ee5 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0x2a33ee5) #27 0x00005e374e2feeaf cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0xcfdeaf) #28 0x00005e374e2f8593 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0 #29 0x00005e374e2fb30f clang_main(int, char**, llvm::ToolContext const&) (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0xcfa30f) #30 0x00005e374e2399eb main (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0xc389eb) #31 0x000070511b429d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16 #32 0x000070511b429e40 call_init ./csu/../csu/libc-start.c:128:20 #33 0x000070511b429e40 __libc_start_main ./csu/../csu/libc-start.c:379:5 #34 0x00005e374e2f7845 _start (/scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin/clang-19+0xcf6845) clang: error: unable to execute command: Aborted (core dumped) clang: error: clang frontend command failed due to signal (use -v to see invocation) clang version 19.0.0git (https://github.com/llvm/llvm-project.git 1b761205f2686516cebadbcbc37f798197d9c482) Target: riscv64-unknown-linux-gnu Thread model: posix InstalledDir: /scratch/tc-testing/tc-apr-4/build-rv64gcv/build-llvm-linux/bin ``` Godbolt: https://godbolt.org/z/sj85e83jh Found via fuzzer
topperc commented 5 months ago

Failing instruction seems to be LOAD_STACK_GUARD created for an Intrinsic::stackguard. SelectionDAG does not create this instruction from that intrinsic for RISC-V.