llvm / llvm/offload-test-suite

[Metal] Crash in AIRBuilder::patchClzCtz when compiling HLSL firstbitlow on 32-element vectors

Open
#1,495 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
18
Forks
39
Avg merge
2d 18h
Merged PRs (30d)
40

Description

We are seeing a failure on Metal via DXC but not clang-dxc likely because we scalarize clang-dxc.

https://feedbackassistant.apple.com/feedback/24450160

OffloadTest-mtl :: Feature/HLSLLib/long-vector/firstbitlow.long-vector.32.test

The issue is in libmetalirconverter.dylib. I am not on the newest shader converter I am on metal-irconverter version: 3.0.0

While vectorized DXIL is a new feature the metal-irconverter has been able to convert other vectorized instructions just fine. It is unclear what is unique in this case as it is an existing instruction just its vector form.

# | Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
# | 0  offloader                 0x000000010259d208 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
# | 1  offloader                 0x000000010259af50 llvm::sys::RunSignalHandlers() + 204
# | 2  offloader                 0x000000010259dd08 SignalHandler(int, __siginfo*, void*) + 320
# | 3  libsystem_platform.dylib  0x000000018a843744 _sigtramp + 56
# | 4  libmetalirconverter.dylib 0x0000000106a2e774 AIRBuilder::patchClzCtz(llvm::MDNode*, llvm::Instruction&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&) + 308
# | 5  libmetalirconverter.dylib 0x0000000106a2e774 AIRBuilder::patchClzCtz(llvm::MDNode*, llvm::Instruction&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&) + 308
# | 6  offloader                 0x00000001025d7c7c (anonymous namespace)::MTLDevice::createPipelineCs(llvm::StringRef, offloadtest::BindingsDesc const&, offloadtest::ShaderContainer) + 212
# | 7  offloader                 0x00000001025d72c4 (anonymous namespace)::MTLDevice::executeProgram(offloadtest::Pipeline&) + 3868
# | 8  offloader                 0x0000000102540998 main + 2072
# | 9  dyld                      0x000000018a471d54 start + 7184
# `-----------------------------

This is the HLSL causing the crash:

StructuredBuffer<uint> In0 : register(t0);
RWStructuredBuffer<uint> Out : register(u1);

[numthreads(1,1,1)]
void main() {
  vector<uint, 5> Input0_5;
  for (uint I = 0; I < 5; ++I)
    Input0_5[I] = In0[0 + I];
  vector<uint, 5> Result5 = firstbitlow(Input0_5);
  for (uint I = 0; I < 5; ++I)
    Out[0 + I] = Result5[I];
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with OffloadTest-mtl :: Feature/HLSLLib/long-vector/firstbitlow.long-vector.32.test and reproduce the crash using the supplied HLSL on Metal IR Converter 3.0.0. Compare the vectorized DXC path with clang-dxc, then determine whether the failure is actionable in this suite or belongs to libmetalirconverter; done means the named test no longer crashes.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, computer-graphics, testing-qa
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.