llvm / llvm/llvm-project

HIPSPV toolchain not tested on macOS CI — missing aligned allocation case crashes compiler

Open
#186,313 2 comments 0 reactions 0 assignees View on GitHub
clang:driver crash
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

## Summary

The HIPSPV toolchain (`spirv64` / `spirv64-unknown-chipstar` targets) has no macOS CI test coverage, which allowed a crash to go undetected: `alignedAllocMinVersion()` in `AlignedAllocation.h` hits `llvm_unreachable` for `Triple::ChipStar` because it has no `case` in the switch.

## How to reproduce

On macOS, compile any C++17 code targeting chipStar:

```
clang++ -target x86_64-apple-darwin --offload=spirv64-unknown-chipstar test.hip
```

The Darwin host toolchain's `addClangTargetOptions()` checks aligned allocation support for the device triple's OS, calls `alignedAllocMinVersion(Triple::ChipStar)`, and crashes.

## Root cause

- `hipspv-toolchain.hip` is only marked `UNSUPPORTED: system-windows, system-cygwin` — it's not unsupported on macOS, but no macOS CI bot runs it
- The `ChipStar` OS type was added to the `Triple` enum but `AlignedAllocation.h` was not updated with a corresponding `case`
- Linux CI doesn't catch this because the Linux host toolchain doesn't check aligned allocation availability

## Suggestion

1. Add `case llvm::Triple::ChipStar:` to `alignedAllocMinVersion()` (fix already prepared in https://github.com/llvm/llvm-project/pull/183991 and CHIP-SPV fork)
2. Consider adding macOS test coverage for HIPSPV targets to catch similar issues in the future (e.g., a macOS bot that runs `check-clang-driver` with the SPIR-V backend enabled)

## Affected files

- `clang/include/clang/Basic/AlignedAllocation.h` — missing switch case
- `clang/lib/Driver/ToolChains/HIPSPV.cpp` — `HostTC->addClangTargetOptions()` delegation exposes the crash on macOS

Contributor guide

Open the contributing guide

Research direction

Start with clang/include/clang/Basic/AlignedAllocation.h and inspect alignedAllocMinVersion(), then trace the call from clang/lib/Driver/ToolChains/HIPSPV.cpp. Review hipspv-toolchain.hip and the check-clang-driver coverage described in the issue. Done means ChipStar no longer reaches the crash and macOS HIPSPV coverage exercises this path.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.