KhronosGroup / KhronosGroup/SPIRV-LLVM-Translator

Failure about unsupported memset of variable length even though no memset in the code

Open
#711 5 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
LLVM
Stars
625
Forks
279
Avg merge
3d 5h
Merged PRs (30d)
34

Description

[test.cl.tar.gz](https://github.com/KhronosGroup/SPIRV-LLVM-Translator/files/5119749/test.cl.tar.gz)
The attached test case fails with clang 12 trunk and spirv-llvm trunk, compiled via
```
clang-12 -cl-std=clc++ -x cl -emit-llvm --target=spir64-unknown-unknown -O3 -cl-denorms-are-zero -cl-mad-enable -cl-no-signed-zeros -ferror-limit=1000 -Xclang -Dcl_clang_storage_class_specifiers -c test.cl -o test.bc
spirv-llvm test.bc
```
showing
```
llvm-spirv: /root/tmp/SPIRV-LLVM-Translator/lib/SPIRV/SPIRVWriter.cpp:2045: SPIRV::SPIRVValue* SPIRV::LLVMToSPIRV::transIntrinsicInst(llvm::IntrinsicInst*, SPIRV::SPIRVBasicBlock*): Assertion `!"Can't translate llvm.memset with non-const `length` argument"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0. Program arguments: llvm-spirv test.bc
1. Running pass 'LLVMToSPIRV' on module 'test.bc'.
llvm-spirv(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x1a)[0xe11438]
llvm-spirv(_ZN4llvm3sys17RunSignalHandlersEv+0x30)[0xe10238]
llvm-spirv[0xe1099b]
/lib64/libpthread.so.0(+0x12dd0)[0x7f9020feddd0]
/lib64/libc.so.6(gsignal+0x10f)[0x7f901fad070f]
/lib64/libc.so.6(abort+0x127)[0x7f901fabab25]
/lib64/libc.so.6(+0x219f9)[0x7f901faba9f9]
/lib64/libc.so.6(+0x2fcc6)[0x7f901fac8cc6]
llvm-spirv(_ZN5SPIRV11LLVMToSPIRV18transIntrinsicInstEPN4llvm13IntrinsicInstEPNS_15SPIRVBasicBlockE+0xfa1)[0xa71111]
llvm-spirv(_ZN5SPIRV11LLVMToSPIRV27transValueWithoutDecorationEPN4llvm5ValueEPNS_15SPIRVBasicBlockEbNS0_13FuncTransModeE+0x313b)[0xa6e13d]
llvm-spirv(_ZN5SPIRV11LLVMToSPIRV10transValueEPN4llvm5ValueEPNS_15SPIRVBasicBlockEbNS0_13FuncTransModeE+0x1d4)[0xa69eb8]
llvm-spirv(_ZN5SPIRV11LLVMToSPIRV13transFunctionEPN4llvm8FunctionE+0x1a7)[0xa74679]
llvm-spirv(_ZN5SPIRV11LLVMToSPIRV9translateEv+0x500)[0xa74c2c]
llvm-spirv(_ZN5SPIRV11LLVMToSPIRV11runOnModuleERN4llvm6ModuleE+0xca)[0xa65372]
llvm-spirv(_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE+0x234)[0xd8583a]
llvm-spirv(_ZN4llvm10writeSpirvEPNS_6ModuleERKN5SPIRV14TranslatorOptsERSoRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0xf4)[0xa785fc]
llvm-spirv[0x97f847]
llvm-spirv(main+0x42a)[0x982193]
/lib64/libc.so.6(__libc_start_main+0xf3)[0x7f901fabc6a3]
llvm-spirv(_start+0x2e)[0x97f4de]
Aborted (core dumped)
```

Contributor guide

Open the contributing guide

Research direction

The attached test.cl.tar.gz and the clang/spirv-llvm command reproduce the crash; start by inspecting lib/SPIRV/SPIRVWriter.cpp at line 2045 and the memset intrinsic translation path. Done means the reproducer completes translation without aborting on a variable-length memset.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.