`CodeGen/SPIRV/legalization/matrix-wide-vector-shader.ll` fails on Cygwin
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
`llc` crashes in `CodeGen/SPIRV/legalization/matrix-wide-vector-shader.ll` on Cygwin after #218467, but it seems that this PR is merely a trigger rather than the actual cause.
from nightly build https://github.com/kikairoya/llvm-cygwin-patches/actions/runs/32907738123
(That build includes a lot of patches, but the result is the same without any of the patches.)
```
FAIL: LLVM :: CodeGen/SPIRV/legalization/matrix-wide-vector-shader.ll (51701 of 96892)
******************** TEST 'LLVM %3A%3A CodeGen/SPIRV/legalization/matrix-wide-vector-shader.ll' FAILED ********************
Exit Code: 2
Command Output (stdout):
--
# RUN: at line 1
/opt/w/build-llvm-76f971b1e+mod-41b0146/bin/llc -O0 -mtriple=spirv1.6-unknown-vulkan1.3 /opt/w/llvm-project/llvm/test/CodeGen/SPIRV/legalization/matrix-wide-vector-shader.ll -o - | /opt/w/build-llvm-76f971b1e+mod-41b0146/bin/FileCheck /opt/w/llvm-project/llvm/test/CodeGen/SPIRV/legalization/matrix-wide-vector-shader.ll
# executed command: /opt/w/build-llvm-76f971b1e+mod-41b0146/bin/llc -O0 -mtriple=spirv1.6-unknown-vulkan1.3 /opt/w/llvm-project/llvm/test/CodeGen/SPIRV/legalization/matrix-wide-vector-shader.ll -o -
# .---command stderr------------
# | 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: /opt/w/build-llvm-76f971b1e+mod-41b0146/bin/llc -O0 -mtriple=spirv1.6-unknown-vulkan1.3 /opt/w/llvm-project/llvm/test/CodeGen/SPIRV/legalization/matrix-wide-vector-shader.ll -o -
# | 1. Running pass 'Function Pass Manager' on module '/opt/w/llvm-project/llvm/test/CodeGen/SPIRV/legalization/matrix-wide-vector-shader.ll'.
# | 2. Running pass 'SPIRV legalize pointer cast pass' on function '@copy_bool4x4'
# `-----------------------------
# error: command failed with exit status: -11
# executed command: /opt/w/build-llvm-76f971b1e+mod-41b0146/bin/FileCheck /opt/w/llvm-project/llvm/test/CodeGen/SPIRV/legalization/matrix-wide-vector-shader.ll
# .---command stderr------------
# | FileCheck error: '' is empty.
# | FileCheck command line: /opt/w/build-llvm-76f971b1e+mod-41b0146/bin/FileCheck /opt/w/llvm-project/llvm/test/CodeGen/SPIRV/legalization/matrix-wide-vector-shader.ll
# `-----------------------------
# error: command failed with exit status: 2
```
```
Thread 1 "llc" received signal SIGSEGV, Segmentation fault.
0x00007ff8926be460 in llvm::SPIRVGlobalRegistry::buildAssignPtr (this=0xa0006c9a0, B=..., ElemTy=0xa000662b0, Arg=Arg@entry=0xa000dcf70)
at /k/llvm/cygwinmod/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp:2309
2309 AssignPtrTyCI->getParent()->getParent() != CurrF) {
(gdb) bt
#0 0x00007ff8926be460 in llvm::SPIRVGlobalRegistry::buildAssignPtr (this=0xa0006c9a0, B=..., ElemTy=0xa000662b0, Arg=Arg@entry=0xa000dcf70)
at /k/llvm/cygwinmod/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp:2309
#1 0x00007ff8926f4e24 in (anonymous namespace)::SPIRVLegalizePointerCastImpl::loadVectorFromArray (this=0x7ffffbbd0, B=..., TargetType=0xa00084be0, Source=0xa000869f0,
OriginalAlign=...) at /k/llvm/cygwinmod/llvm/lib/Target/SPIRV/SPIRVLegalizePointerCast.cpp:531
#2 (anonymous namespace)::SPIRVLegalizePointerCastImpl::buildLegalizedLoad (this=0x7ffffbbd0, B=..., ElementType=0xa00084be0, Source=0xa000869f0, IllegalLoad=0xa00087c60,
CastedPtr=0xa0008ae50) at /k/llvm/cygwinmod/llvm/lib/Target/SPIRV/SPIRVLegalizePointerCast.cpp:449
#3 (anonymous namespace)::SPIRVLegalizePointerCastImpl::transformLoad (this=0x7ffffbbd0, B=..., LI=0xa00087c60, CastedOperand=0xa0008ae50, OriginalOperand=0xa000869f0)
at /k/llvm/cygwinmod/llvm/lib/Target/SPIRV/SPIRVLegalizePointerCast.cpp:620
#4 (anonymous namespace)::SPIRVLegalizePointerCastImpl::legalizePointerCast (this=0x7ffffbbd0, II=0xa0008ae50)
at /k/llvm/cygwinmod/llvm/lib/Target/SPIRV/SPIRVLegalizePointerCast.cpp:780
#5 (anonymous namespace)::SPIRVLegalizePointerCastImpl::run (this=this@entry=0x7ffffbbd0, F=...) at /k/llvm/cygwinmod/llvm/lib/Target/SPIRV/SPIRVLegalizePointerCast.cpp:836
#6 0x00007ff8926f8836 in (anonymous namespace)::SPIRVLegalizePointerCastLegacy::runOnFunction (this=, F=...)
at /k/llvm/cygwinmod/llvm/lib/Target/SPIRV/SPIRVLegalizePointerCast.cpp:857
#7 0x00007ff8902a1cac in llvm::FPPassManager::runOnFunction (this=this@entry=0xa00093ee0, F=...) at /k/llvm/cygwinmod/llvm/lib/IR/LegacyPassManager.cpp:1416
#8 0x00007ff8902a770c in llvm::FPPassManager::runOnModule (this=0xa00093ee0, M=...) at /k/llvm/cygwinmod/llvm/lib/IR/LegacyPassManager.cpp:1470
#9 0x00007ff8902a276b in (anonymous namespace)::MPPassManager::runOnModule (this=0xa0008cd70, M=...) at /k/llvm/cygwinmod/llvm/lib/IR/LegacyPassManager.cpp:1561
#10 llvm::legacy::PassManagerImpl::run (this=0xa00068320, M=...) at /k/llvm/cygwinmod/llvm/lib/IR/LegacyPassManager.cpp:533
#11 0x00007ff682563718 in compileModule (argv=0xa0002c800, PluginList=..., Context=..., OutputFilename="-") at /k/llvm/cygwinmod/llvm/tools/llc/llc.cpp:883
#12 0x00007ff6825616a5 in main (argc=6, argv=0xa0002c800) at /k/llvm/cygwinmod/llvm/tools/llc/llc.cpp:459
```
https://github.com/llvm/llvm-project/blob/13643167013a7c84b6eceebd5248908bd858e56f/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp#L2302-L2320
Actually `AssignPtrTyCI->getParent()` returns `nullptr` and causes a crash, even if `SPIRVLegalizerInfo.cpp` is reverted.
However, reordering `@copy_bool4x4` in `matrix-wide-vector-shader.ll`, which triggers the crash, before the other functions resolves the issue.
Contributor guide
Research direction
Start by running llvm/test/CodeGen/SPIRV/legalization/matrix-wide-vector-shader.ll with llc and FileCheck using the reported SPIR-V triple. Read SPIRVGlobalRegistry.cpp around buildAssignPtr and SPIRVLegalizePointerCast.cpp around loadVectorFromArray, then compare the behavior when @copy_bool4x4 is reordered. Done means the test no longer crashes on Cygwin and its FileCheck assertions pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100