Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RISC-V] Assertion `(TLI.getTypeAction(*DAG.getContext(), Op.getValueType()) == TargetLowering::TypeLegal || Op.getOpcode() == ISD::TargetConstant || Op.getOpcode() == ISD::Register) && "Unexpected illegal type!"' failed. #117349

Closed
hvdijk opened this issue Nov 22, 2024 · 2 comments · Fixed by #117396
Assignees
Labels
backend:RISC-V bug Indicates an unexpected problem or unintended behavior rejects-valid

Comments

@hvdijk
Copy link
Contributor

hvdijk commented Nov 22, 2024

Please consider this automatically reduced (courtesy of llvm-reduce) tmp.ll:

; ModuleID = 'tmp.bc'
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"
target triple = "riscv64-unknown-linux-gnu"

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare half @llvm.ldexp.f16.i32(half, i32) #0

define spir_kernel void @_ZTS6kernelILi4330275EE() #1 {
entry:
  call void @_Z17__spirv_ocl_ldexpDv16_DF16_Dv16_i()
  ret void
}

; Function Attrs: alwaysinline
define void @_Z17__spirv_ocl_ldexpDv16_DF16_Dv16_i() #2 {
entry:
  %args_1 = load <16 x i32>, ptr null, align 64
  %0 = extractelement <16 x i32> %args_1, i64 0
  %1 = tail call half @llvm.ldexp.f16.i32(half 0xH3C00, i32 %0)
  %vecinit4.i21.i24.i.i = insertelement <2 x half> zeroinitializer, half %1, i64 0
  %vecinit11.i36.i.i = shufflevector <2 x half> %vecinit4.i21.i24.i.i, <2 x half> zeroinitializer, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  %vecinit9.i.i = shufflevector <4 x half> %vecinit11.i36.i.i, <4 x half> zeroinitializer, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
  %vecinit7.i = shufflevector <8 x half> zeroinitializer, <8 x half> %vecinit9.i.i, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
  store <16 x half> %vecinit7.i, ptr null, align 32
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,+zfh,+zfhmin,+zicsr,+zmmul,-b,-e,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssqosid,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-v,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zacas,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zifencei,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zve32f,-zve32x,-zve64d,-zve64f,-zve64x,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl128b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl32b,-zvl4096b,-zvl512b,-zvl64b,-zvl65536b,-zvl8192b" }
attributes #2 = { alwaysinline }

Compiling this with clang --target=riscv64-linux-gnu -c tmp.ll results in:

clang: /home/harald/llvm-project/main/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:969: void {anonymous}::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*): Assertion `(TLI.getTypeAction(*DAG.getContext(), Op.getValueType()) == TargetLowering::TypeLegal || Op.getOpcode() == ISD::TargetConstant || Op.getOpcode() == ISD::Register) && "Unexpected illegal type!"' failed.
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: /home/harald/llvm-project/main/build/aarch64-linux/bin/clang --target=riscv64-linux-gnu -c tmp.ll
1.	Code generation
2.	Running pass 'Function Pass Manager' on module 'tmp.ll'.
3.	Running pass 'RISC-V DAG->DAG Pattern Instruction Selection' on function '@_ZTS6kernelILi4330275EE'
 #0 0x0000e41bf4a86748 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0xe86748)
 #1 0x0000e41bf4a84288 llvm::sys::CleanupOnSignal(unsigned long) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0xe84288)
 #2 0x0000e41bf4983e3c CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x0000e41c02d3a8f8 (linux-vdso.so.1+0x8f8)
 #4 0x0000e41bf36c7628 (/lib/aarch64-linux-gnu/libc.so.6+0x87628)
 #5 0x0000e41bf367cb3c raise (/lib/aarch64-linux-gnu/libc.so.6+0x3cb3c)
 #6 0x0000e41bf3667e00 abort (/lib/aarch64-linux-gnu/libc.so.6+0x27e00)
 #7 0x0000e41bf3675cbc (/lib/aarch64-linux-gnu/libc.so.6+0x35cbc)
 #8 0x0000e41bf3675d2c (/lib/aarch64-linux-gnu/libc.so.6+0x35d2c)
 #9 0x0000e41bf556a7c0 (anonymous namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*) LegalizeDAG.cpp:0:0
#10 0x0000e41bf556ab94 llvm::SelectionDAG::Legalize() (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x196ab94)
#11 0x0000e41bf573a6e8 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x1b3a6e8)
#12 0x0000e41bf573e184 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x1b3e184)
#13 0x0000e41bf573f89c llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x1b3f89c)
#14 0x0000e41bf572c3dc llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x1b2c3dc)
#15 0x0000e41bf50528fc llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#16 0x0000e41bf4c7ef60 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x107ef60)
#17 0x0000e41bf4c7f1dc llvm::FPPassManager::runOnModule(llvm::Module&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x107f1dc)
#18 0x0000e41bf4c7fd0c llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x107fd0c)
#19 0x0000e41c00106fa4 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) BackendUtil.cpp:0:0
#20 0x0000e41c00107234 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*) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x2307234)
#21 0x0000e41c005ec910 clang::CodeGenAction::ExecuteAction() (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x27ec910)
#22 0x0000e41c010f97d8 clang::FrontendAction::Execute() (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x32f97d8)
#23 0x0000e41c0108a19c clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x328a19c)
#24 0x0000e41c01192310 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x3392310)
#25 0x0000bf94157a4ce0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/harald/llvm-project/main/build/aarch64-linux/bin/clang+0x14ce0)
#26 0x0000bf941579d144 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#27 0x0000e41c00c7d680 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#28 0x0000e41bf49843b0 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0xd843b0)
#29 0x0000e41c00c7f694 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#30 0x0000e41c00c46974 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x2e46974)
#31 0x0000e41c00c47674 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x2e47674)
#32 0x0000e41c00c54734 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x2e54734)
#33 0x0000bf94157a1764 clang_main(int, char**, llvm::ToolContext const&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/clang+0x11764)
#34 0x0000bf941579c6c0 main (/home/harald/llvm-project/main/build/aarch64-linux/bin/clang+0xc6c0)
#35 0x0000e41bf36684c4 (/lib/aarch64-linux-gnu/libc.so.6+0x284c4)
#36 0x0000e41bf3668598 __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x28598)
#37 0x0000bf941579c7b0 _start (/home/harald/llvm-project/main/build/aarch64-linux/bin/clang+0xc7b0)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 20.0.0git (https://github.com/llvm/llvm-project cec52960fdc8eeecab340ffe4cd12f8a8c43bd3b)
Target: riscv64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/harald/llvm-project/main/build/aarch64-linux/bin
Build config: +assertions
clang: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.

The original input before reduction was too large to submit here, apologies if llvm-reduce turned it into something less sensible.

@hvdijk hvdijk added bug Indicates an unexpected problem or unintended behavior backend:RISC-V rejects-valid labels Nov 22, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 22, 2024

@llvm/issue-subscribers-bug

Author: Harald van Dijk (hvdijk)

Please consider this automatically reduced (courtesy of `llvm-reduce`) `tmp.ll`: ```llvm ; ModuleID = 'tmp.bc' target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128" target triple = "riscv64-unknown-linux-gnu"

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare half @llvm.ldexp.f16.i32(half, i32) #0

define spir_kernel void @_ZTS6kernelILi4330275EE() #1 {
entry:
call void @_Z17__spirv_ocl_ldexpDv16_DF16_Dv16_i()
ret void
}

; Function Attrs: alwaysinline
define void @_Z17__spirv_ocl_ldexpDv16_DF16_Dv16_i() #2 {
entry:
%args_1 = load <16 x i32>, ptr null, align 64
%0 = extractelement <16 x i32> %args_1, i64 0
%1 = tail call half @llvm.ldexp.f16.i32(half 0xH3C00, i32 %0)
%vecinit4.i21.i24.i.i = insertelement <2 x half> zeroinitializer, half %1, i64 0
%vecinit11.i36.i.i = shufflevector <2 x half> %vecinit4.i21.i24.i.i, <2 x half> zeroinitializer, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
%vecinit9.i.i = shufflevector <4 x half> %vecinit11.i36.i.i, <4 x half> zeroinitializer, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
%vecinit7.i = shufflevector <8 x half> zeroinitializer, <8 x half> %vecinit9.i.i, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
store <16 x half> %vecinit7.i, ptr null, align 32
ret void
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,+zfh,+zfhmin,+zicsr,+zmmul,-b,-e,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssqosid,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-v,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zacas,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zifencei,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zve32f,-zve32x,-zve64d,-zve64f,-zve64x,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl128b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl32b,-zvl4096b,-zvl512b,-zvl64b,-zvl65536b,-zvl8192b" }
attributes #2 = { alwaysinline }

Compiling this with `clang --target=riscv64-linux-gnu -c tmp.ll` results in:

clang: /home/harald/llvm-project/main/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:969: void {anonymous}::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*): Assertion `(TLI.getTypeAction(*DAG.getContext(), Op.getValueType()) == TargetLowering::TypeLegal || Op.getOpcode() == ISD::TargetConstant || Op.getOpcode() == ISD::Register) && "Unexpected illegal type!"' failed.
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: /home/harald/llvm-project/main/build/aarch64-linux/bin/clang --target=riscv64-linux-gnu -c tmp.ll

  1. Code generation
  2. Running pass 'Function Pass Manager' on module 'tmp.ll'.
  3. Running pass 'RISC-V DAG->DAG Pattern Instruction Selection' on function '@_ZTS6kernelILi4330275EE'
    #0 0x0000e41bf4a86748 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0xe86748)
    #1 0x0000e41bf4a84288 llvm::sys::CleanupOnSignal(unsigned long) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0xe84288)
    #2 0x0000e41bf4983e3c CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
    #3 0x0000e41c02d3a8f8 (linux-vdso.so.1+0x8f8)
    #4 0x0000e41bf36c7628 (/lib/aarch64-linux-gnu/libc.so.6+0x87628)
    #5 0x0000e41bf367cb3c raise (/lib/aarch64-linux-gnu/libc.so.6+0x3cb3c)
    #6 0x0000e41bf3667e00 abort (/lib/aarch64-linux-gnu/libc.so.6+0x27e00)
    #7 0x0000e41bf3675cbc (/lib/aarch64-linux-gnu/libc.so.6+0x35cbc)
    #8 0x0000e41bf3675d2c (/lib/aarch64-linux-gnu/libc.so.6+0x35d2c)
    #9 0x0000e41bf556a7c0 (anonymous namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*) LegalizeDAG.cpp:0:0
    #10 0x0000e41bf556ab94 llvm::SelectionDAG::Legalize() (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x196ab94)
    #11 0x0000e41bf573a6e8 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x1b3a6e8)
    #12 0x0000e41bf573e184 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x1b3e184)
    #13 0x0000e41bf573f89c llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x1b3f89c)
    #14 0x0000e41bf572c3dc llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x1b2c3dc)
    #15 0x0000e41bf50528fc llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
    #16 0x0000e41bf4c7ef60 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x107ef60)
    #17 0x0000e41bf4c7f1dc llvm::FPPassManager::runOnModule(llvm::Module&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x107f1dc)
    #18 0x0000e41bf4c7fd0c llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x107fd0c)
    #19 0x0000e41c00106fa4 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) BackendUtil.cpp:0:0
    #20 0x0000e41c00107234 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*) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x2307234)
    #21 0x0000e41c005ec910 clang::CodeGenAction::ExecuteAction() (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x27ec910)
    #22 0x0000e41c010f97d8 clang::FrontendAction::Execute() (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x32f97d8)
    #23 0x0000e41c0108a19c clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x328a19c)
    #24 0x0000e41c01192310 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x3392310)
    #25 0x0000bf94157a4ce0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/harald/llvm-project/main/build/aarch64-linux/bin/clang+0x14ce0)
    #26 0x0000bf941579d144 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
    #27 0x0000e41c00c7d680 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool) const::'lambda'()>(long) Job.cpp:0:0
    #28 0x0000e41bf49843b0 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0xd843b0)
    #29 0x0000e41c00c7f694 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool) const (.part.0) Job.cpp:0:0
    #30 0x0000e41c00c46974 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x2e46974)
    #31 0x0000e41c00c47674 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x2e47674)
    #32 0x0000e41c00c54734 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x2e54734)
    #33 0x0000bf94157a1764 clang_main(int, char**, llvm::ToolContext const&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/clang+0x11764)
    #34 0x0000bf941579c6c0 main (/home/harald/llvm-project/main/build/aarch64-linux/bin/clang+0xc6c0)
    #35 0x0000e41bf36684c4 (/lib/aarch64-linux-gnu/libc.so.6+0x284c4)
    #36 0x0000e41bf3668598 __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x28598)
    #37 0x0000bf941579c7b0 _start (/home/harald/llvm-project/main/build/aarch64-linux/bin/clang+0xc7b0)
    clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
    clang version 20.0.0git (https://github.com/llvm/llvm-project cec5296)
    Target: riscv64-unknown-linux-gnu
    Thread model: posix
    InstalledDir: /home/harald/llvm-project/main/build/aarch64-linux/bin
    Build config: +assertions
    clang: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.
The original input before reduction was too large to submit here, apologies if `llvm-reduce` turned it into something less sensible.
</details>

@llvmbot
Copy link
Member

llvmbot commented Nov 22, 2024

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

Author: Harald van Dijk (hvdijk)

Please consider this automatically reduced (courtesy of `llvm-reduce`) `tmp.ll`: ```llvm ; ModuleID = 'tmp.bc' target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128" target triple = "riscv64-unknown-linux-gnu"

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare half @llvm.ldexp.f16.i32(half, i32) #0

define spir_kernel void @_ZTS6kernelILi4330275EE() #1 {
entry:
call void @_Z17__spirv_ocl_ldexpDv16_DF16_Dv16_i()
ret void
}

; Function Attrs: alwaysinline
define void @_Z17__spirv_ocl_ldexpDv16_DF16_Dv16_i() #2 {
entry:
%args_1 = load <16 x i32>, ptr null, align 64
%0 = extractelement <16 x i32> %args_1, i64 0
%1 = tail call half @llvm.ldexp.f16.i32(half 0xH3C00, i32 %0)
%vecinit4.i21.i24.i.i = insertelement <2 x half> zeroinitializer, half %1, i64 0
%vecinit11.i36.i.i = shufflevector <2 x half> %vecinit4.i21.i24.i.i, <2 x half> zeroinitializer, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
%vecinit9.i.i = shufflevector <4 x half> %vecinit11.i36.i.i, <4 x half> zeroinitializer, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
%vecinit7.i = shufflevector <8 x half> zeroinitializer, <8 x half> %vecinit9.i.i, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
store <16 x half> %vecinit7.i, ptr null, align 32
ret void
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,+zfh,+zfhmin,+zicsr,+zmmul,-b,-e,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssqosid,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-v,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zacas,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zifencei,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zve32f,-zve32x,-zve64d,-zve64f,-zve64x,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl128b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl32b,-zvl4096b,-zvl512b,-zvl64b,-zvl65536b,-zvl8192b" }
attributes #2 = { alwaysinline }

Compiling this with `clang --target=riscv64-linux-gnu -c tmp.ll` results in:

clang: /home/harald/llvm-project/main/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:969: void {anonymous}::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*): Assertion `(TLI.getTypeAction(*DAG.getContext(), Op.getValueType()) == TargetLowering::TypeLegal || Op.getOpcode() == ISD::TargetConstant || Op.getOpcode() == ISD::Register) && "Unexpected illegal type!"' failed.
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: /home/harald/llvm-project/main/build/aarch64-linux/bin/clang --target=riscv64-linux-gnu -c tmp.ll

  1. Code generation
  2. Running pass 'Function Pass Manager' on module 'tmp.ll'.
  3. Running pass 'RISC-V DAG->DAG Pattern Instruction Selection' on function '@_ZTS6kernelILi4330275EE'
    #0 0x0000e41bf4a86748 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0xe86748)
    #1 0x0000e41bf4a84288 llvm::sys::CleanupOnSignal(unsigned long) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0xe84288)
    #2 0x0000e41bf4983e3c CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
    #3 0x0000e41c02d3a8f8 (linux-vdso.so.1+0x8f8)
    #4 0x0000e41bf36c7628 (/lib/aarch64-linux-gnu/libc.so.6+0x87628)
    #5 0x0000e41bf367cb3c raise (/lib/aarch64-linux-gnu/libc.so.6+0x3cb3c)
    #6 0x0000e41bf3667e00 abort (/lib/aarch64-linux-gnu/libc.so.6+0x27e00)
    #7 0x0000e41bf3675cbc (/lib/aarch64-linux-gnu/libc.so.6+0x35cbc)
    #8 0x0000e41bf3675d2c (/lib/aarch64-linux-gnu/libc.so.6+0x35d2c)
    #9 0x0000e41bf556a7c0 (anonymous namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*) LegalizeDAG.cpp:0:0
    #10 0x0000e41bf556ab94 llvm::SelectionDAG::Legalize() (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x196ab94)
    #11 0x0000e41bf573a6e8 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x1b3a6e8)
    #12 0x0000e41bf573e184 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x1b3e184)
    #13 0x0000e41bf573f89c llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x1b3f89c)
    #14 0x0000e41bf572c3dc llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x1b2c3dc)
    #15 0x0000e41bf50528fc llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
    #16 0x0000e41bf4c7ef60 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x107ef60)
    #17 0x0000e41bf4c7f1dc llvm::FPPassManager::runOnModule(llvm::Module&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x107f1dc)
    #18 0x0000e41bf4c7fd0c llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0x107fd0c)
    #19 0x0000e41c00106fa4 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) BackendUtil.cpp:0:0
    #20 0x0000e41c00107234 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*) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x2307234)
    #21 0x0000e41c005ec910 clang::CodeGenAction::ExecuteAction() (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x27ec910)
    #22 0x0000e41c010f97d8 clang::FrontendAction::Execute() (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x32f97d8)
    #23 0x0000e41c0108a19c clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x328a19c)
    #24 0x0000e41c01192310 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x3392310)
    #25 0x0000bf94157a4ce0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/harald/llvm-project/main/build/aarch64-linux/bin/clang+0x14ce0)
    #26 0x0000bf941579d144 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
    #27 0x0000e41c00c7d680 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool) const::'lambda'()>(long) Job.cpp:0:0
    #28 0x0000e41bf49843b0 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libLLVM.so.20.0git+0xd843b0)
    #29 0x0000e41c00c7f694 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool) const (.part.0) Job.cpp:0:0
    #30 0x0000e41c00c46974 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x2e46974)
    #31 0x0000e41c00c47674 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x2e47674)
    #32 0x0000e41c00c54734 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/../lib/libclang-cpp.so.20.0git+0x2e54734)
    #33 0x0000bf94157a1764 clang_main(int, char**, llvm::ToolContext const&) (/home/harald/llvm-project/main/build/aarch64-linux/bin/clang+0x11764)
    #34 0x0000bf941579c6c0 main (/home/harald/llvm-project/main/build/aarch64-linux/bin/clang+0xc6c0)
    #35 0x0000e41bf36684c4 (/lib/aarch64-linux-gnu/libc.so.6+0x284c4)
    #36 0x0000e41bf3668598 __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x28598)
    #37 0x0000bf941579c7b0 _start (/home/harald/llvm-project/main/build/aarch64-linux/bin/clang+0xc7b0)
    clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
    clang version 20.0.0git (https://github.com/llvm/llvm-project cec5296)
    Target: riscv64-unknown-linux-gnu
    Thread model: posix
    InstalledDir: /home/harald/llvm-project/main/build/aarch64-linux/bin
    Build config: +assertions
    clang: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.
The original input before reduction was too large to submit here, apologies if `llvm-reduce` turned it into something less sensible.
</details>

@topperc topperc self-assigned this Nov 22, 2024
topperc added a commit to topperc/llvm-project that referenced this issue Nov 22, 2024
The default expansion tries to create i16 operations after
type legalization.

Fixes llvm#117349
topperc added a commit that referenced this issue Nov 25, 2024
The default expansion tries to create i16 operations after type
legalization.

Fixes #117349
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:RISC-V bug Indicates an unexpected problem or unintended behavior rejects-valid
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants