[HIP][Driver] Assertion tripped when compiling with -E and multiple offload architectures
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
While investigating an issue with sccache (https://github.com/mozilla/sccache/issues/2762) I ran into another issue: the Clang driver crashes when running it in preprocessor-only mode with multiple offload architectures. To reproduce, run `clang++ ~/test.hip -E --offload-arch=gfx1200 --offload-arch=gfx1100`. Any contents of test.hip will do, even a completely empty file.
I bisected the issue and traced it to 23302678, and indeed running `clang++ ~/test.hip -E --offload-arch=gfx1200 --offload-arch=gfx1100 --no-offload-new-driver` does seems to resolve the issue. Running `clang++ ~/test.hip -E --offload-arch=gfx1200 --offload-arch=gfx110 --offload-new-driver` on the parent commit (a8f3c97d) also crashes, so the root cause seems to lie elsewhere.
The crash seems to hit this assertion, and indeed passing only a single --offload-arch seems to resolve the issue.
https://github.com/llvm/llvm-project/blob/4f06fa92b6cf16cec5bd0bfe7ef3efec17b91e24/clang/lib/Driver/ToolChains/Clang.cpp#L8278
Is processing a single input with the new offload driver a fundamental limitation or is this simply an oversight? I'm interested because in order to resolve https://github.com/mozilla/sccache/issues/2762 properly, I think that it really does need the preprocessed source of all offload architectures.
Contributor guide
Research direction
Start with clang/lib/Driver/ToolChains/Clang.cpp at the assertion near line 8278, then reproduce the crash with the two --offload-arch values and -E. Compare behavior with --no-offload-new-driver and with a single architecture. Done means multiple offload architectures no longer trigger the assertion while processing the preprocessor-only input.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100