Skip to content

[SPIRV][OPENCL]"Assertion `Args.size() >= Call->Builtin->MinNumArgs && "Too few arguments to generate the builtin"' failed." #165237

@FinalEvilution

Description

@FinalEvilution

llc crashes with "Assertion `Args.size() >= Call->Builtin->MinNumArgs && "Too few arguments to generate the builtin"' failed." when building a spirv ir file with a declare and call of "void @barrier()" using llvm llc versions 19.1.7 to current main, but not 18.1.8.
Some additional history on how this bug was discovered is at https://github.com/ldc-developers/ldc/issues/4998#issuecomment-3449545048

Bugpoint output
Read input file      : 'kernels_ocl220_64.spv'
*** All input ok
Initializing execution environment: Found llc: /mnt/RAID1/Home/GitHub/llvm-project/llvm-build/bin/llc
Running the code generator to test for a crash: <llc>
Error running tool:
  /mnt/RAID1/Home/GitHub/llvm-project/llvm-build/bin/llc -o bugpoint-test-program-264785d.bc-49899e9.llc.s bugpoint-test-program-264785d.bc
llc: /mnt/RAID1/Home/GitHub/llvm-project/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp:2975: std::optional<bool> llvm::SPIRV::lowerBuiltin(llvm::StringRef, InstructionSet::InstructionSet, llvm::MachineIRBuilder&, llvm::Register, const llvm::Type*, const llvm::SmallVectorImpl<llvm::Register>&, llvm::SPIRVGlobalRegistry*, const llvm::CallBase&): Assertion `Args.size() >= Call->Builtin->MinNumArgs && "Too few arguments to generate the builtin"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.	Program arguments: /mnt/RAID1/Home/GitHub/llvm-project/llvm-build/bin/llc -o bugpoint-test-program-264785d.bc-49899e9.llc.s bugpoint-test-program-264785d.bc
1.	Running pass 'Function Pass Manager' on module 'bugpoint-test-program-264785d.bc'.
2.	Running pass 'IRTranslator' on function '@_D4testQfFZv'
 #0 0x00000000032aba56 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /mnt/RAID1/Home/GitHub/llvm-project/llvm/lib/Support/Unix/Signals.inc:834:22
 #1 0x00000000032abf26 PrintStackTraceSignalHandler(void*) /mnt/RAID1/Home/GitHub/llvm-project/llvm/lib/Support/Unix/Signals.inc:916:1
 #2 0x00000000032a9419 llvm::sys::RunSignalHandlers() /mnt/RAID1/Home/GitHub/llvm-project/llvm/lib/Support/Signals.cpp:104:20
 #3 0x00000000032ab38a SignalHandler(int, siginfo_t*, void*) /mnt/RAID1/Home/GitHub/llvm-project/llvm/lib/Support/Unix/Signals.inc:426:14
 #4 0x00007f2963247c00 __restore_rt libc_sigaction.c:0:0
 #5 0x00007f29632ac061 __pthread_kill_implementation /usr/src/debug/sys-libs/glibc-2.42-r1/glibc-2.42/nptl/pthread_kill.c:44:76
 #6 0x00007f29632ac061 __pthread_kill_internal /usr/src/debug/sys-libs/glibc-2.42-r1/glibc-2.42/nptl/pthread_kill.c:89:10
 #7 0x00007f29632ac061 pthread_kill@@GLIBC_2.34 /usr/src/debug/sys-libs/glibc-2.42-r1/glibc-2.42/nptl/pthread_kill.c:100:10
 #8 0x00007f2963247b06 gsignal /usr/src/debug/sys-libs/glibc-2.42-r1/glibc-2.42/signal/../sysdeps/posix/raise.c:27:6
 #9 0x00007f29632292ef internal_signal_block_all /usr/src/debug/sys-libs/glibc-2.42-r1/glibc-2.42/stdlib/../sysdeps/unix/sysv/linux/internal-signals.h:81:3
#10 0x00007f29632292ef __abort_lock_wrlock /usr/src/debug/sys-libs/glibc-2.42-r1/glibc-2.42/stdlib/abort.c:62:3
#11 0x00007f29632292ef abort /usr/src/debug/sys-libs/glibc-2.42-r1/glibc-2.42/stdlib/abort.c:85:3
#12 0x00007f296322927e __assert_perror_fail /usr/src/debug/sys-libs/glibc-2.42-r1/glibc-2.42/assert/assert-perr.c:31:1
#13 0x0000000001259721 llvm::SPIRV::lowerBuiltin(llvm::StringRef, llvm::SPIRV::InstructionSet::InstructionSet, llvm::MachineIRBuilder&, llvm::Register, llvm::Type const*, llvm::SmallVectorImpl<llvm::Register> const&, llvm::SPIRVGlobalRegistry*, llvm::CallBase const&) /mnt/RAID1/Home/GitHub/llvm-project/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp:2977:11
#14 0x0000000001127322 llvm::SPIRVCallLowering::lowerCall(llvm::MachineIRBuilder&, llvm::CallLowering::CallLoweringInfo&) const /mnt/RAID1/Home/GitHub/llvm-project/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp:634:39
#15 0x00000000039d7c99 llvm::CallLowering::lowerCall(llvm::MachineIRBuilder&, llvm::CallBase const&, llvm::ArrayRef<llvm::Register>, llvm::ArrayRef<llvm::ArrayRef<llvm::Register>>, llvm::Register, std::optional<llvm::CallLowering::PtrAuthInfo>, llvm::Register, std::function<llvm::Register ()>) const /mnt/RAID1/Home/GitHub/llvm-project/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp:208:7
#16 0x0000000003a6e588 llvm::IRTranslator::translateCallBase(llvm::CallBase const&, llvm::MachineIRBuilder&) /mnt/RAID1/Home/GitHub/llvm-project/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp:2767:32
#17 0x0000000003a6e897 llvm::IRTranslator::translateCall(llvm::User const&, llvm::MachineIRBuilder&) /mnt/RAID1/Home/GitHub/llvm-project/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp:2808:5
#18 0x0000000003a74b29 llvm::IRTranslator::translate(llvm::Instruction const&) /mnt/RAID1/Home/GitHub/llvm-project/llvm/include/llvm/IR/Instruction.def:210:1
#19 0x0000000003a790dc llvm::IRTranslator::runOnMachineFunction(llvm::MachineFunction&) /mnt/RAID1/Home/GitHub/llvm-project/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp:4221:9
#20 0x0000000001baf125 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /mnt/RAID1/Home/GitHub/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:108:30
#21 0x000000000248f0d9 llvm::FPPassManager::runOnFunction(llvm::Function&) /mnt/RAID1/Home/GitHub/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1398:20
#22 0x000000000248f33f llvm::FPPassManager::runOnModule(llvm::Module&) /mnt/RAID1/Home/GitHub/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1444:13
#23 0x000000000248f756 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /mnt/RAID1/Home/GitHub/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1513:20
#24 0x000000000248ae50 llvm::legacy::PassManagerImpl::run(llvm::Module&) /mnt/RAID1/Home/GitHub/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:531:13
#25 0x000000000248ff97 llvm::legacy::PassManager::run(llvm::Module&) /mnt/RAID1/Home/GitHub/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1641:1
#26 0x0000000000a25277 compileModule(char**, llvm::LLVMContext&) /mnt/RAID1/Home/GitHub/llvm-project/llvm/tools/llc/llc.cpp:833:34
#27 0x0000000000a22948 main /mnt/RAID1/Home/GitHub/llvm-project/llvm/tools/llc/llc.cpp:446:35
#28 0x00007f296322b43a __libc_start_call_main /usr/src/debug/sys-libs/glibc-2.42-r1/glibc-2.42/csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#29 0x00007f296322b4ea call_init /usr/src/debug/sys-libs/glibc-2.42-r1/glibc-2.42/csu/../csu/libc-start.c:128:20
#30 0x00007f296322b4ea __libc_start_main@GLIBC_2.2.5 /usr/src/debug/sys-libs/glibc-2.42-r1/glibc-2.42/csu/../csu/libc-start.c:347:5
#31 0x0000000000a212e5 _start /usr/src/debug/sys-libs/glibc-2.42-r1/glibc-2.42/csu/../sysdeps/x86_64/start.S:117:0
*** Debugging code generator crash!

*** Attempting to reduce the number of function attributes in the testcase
Checking for crash with changing conditionals to always jump to true: : <llc><crash>
Emitted bitcode to 'bugpoint-reduced-conditionals.bc'
Checking for crash with only these blocks: : <llc><crash>
Emitted bitcode to 'bugpoint-reduced-blocks.bc'
Checking for crash with CFG simplifying: : <llc><crash>
Emitted bitcode to 'bugpoint-reduced-simplifycfg.bc'
Checking for crash with only 1 instruction: <llc><crash>

*** Attempting to reduce testcase by deleting instructions: Simplification Level #1
Checking instruction:   call spir_func void @barrier()<llc>

*** Attempting to reduce testcase by deleting instructions: Simplification Level #0
Checking instruction:   call spir_func void @barrier()<llc>
Checking for crash with metadata retained from 2 instructions: <llc><crash>
Checking for crash with metadata retained from 1 instruction: <llc><crash>
Emitted bitcode to 'bugpoint-reduced-instructions.bc'

*** Attempting to strip the debug info: <llc><crash>

*** Attempting to strip the debug type info: <llc><crash>

*** Attempting to remove named metadata: Checking for crash with only these named metadata nodes: opencl.spir.version opencl.ocl.version: <llc><crash>
Checking for crash with only these named metadata nodes: opencl.ocl.version: <llc><crash>
Checking for crash with only 1 named metadata operand: <llc><crash>
Emitted bitcode to 'bugpoint-reduced-named-md.bc'

*** Attempting to perform final cleanups: <llc><crash>
Emitted bitcode to 'bugpoint-reduced-simplified.bc'
bugpoint-reduced-simplified.ll
; ModuleID = 'bugpoint-reduced-simplified.bc'
source_filename = "dcomputeTargetOCL"
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
target triple = "spirv64-unknown-unknown"

define spir_func void @_D4testQfFZv() {
  call spir_func void @barrier()
  ret void
}

declare spir_func void @barrier()

!opencl.ocl.version = !{!0}

!0 = !{i32 2, i32 2}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions