clang-20 crash when compiling HIP device code for gfx1200 (ROCm 7.0.2), and uninitialized-memory use in CodeGen detected by valgrind
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Summary
Using clang from ROCm 7.0.2 to compile a HIP device file for amdgcn-amd-amdhsa (gfx1200), we observe:
A clang crash during CodeGen when building rocPRIM test sources.
The crash appears in the build log at line 631 and following.
Use of uninitialized memory inside clang/LLVM CodeGen, detected via valgrind when re-running the same clang invocation in isolation.
The crash occurs during a parallel build.
However, the standalone invocation (provided below) does not itself crash, but it does consistently expose uninitialized-memory use under valgrind.
All required materials (crash log, preprocessed input, run script) are attached.
Environment
AMD clang version 20.0.0git
(https://github.com/RadeonOpenCompute/llvm-project roc-7.0.2 ...)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/rocm-7.0.2/lib/llvm/bin
Host triple: x86_64-unknown-linux-gnu
Device triple: amdgcn-amd-amdhsa
Target GPU: gfx1200
Crash observed in build log
During a build of rocPRIM tests, clang crashes during device-code emission.
The first failing entry in our log appears at:
build.log line 631
Complete build.log is attached.
Standalone reproduction setup
1. Preprocessed source file
The exact input given to clang is included:
➡️ test_linking_lib-hip-amdgcn-amd-amdhsa-gfx1200.hipi
2. Run script (standalone clang invocation)
The exact clang -cc1 command extracted from the build is contained in:
➡️ rpl
Running this script standalone:
does not reproduce the crash,
but is used for instrumentation and valgrind analysis described below.
Example excerpt of the invocation (truncated for readability):
/opt/rocm-7.0.2/lib/llvm/bin/clang-20 -cc1 \
-triple amdgcn-amd-amdhsa \
-aux-triple x86_64-unknown-linux-gnu \
-emit-llvm-bc -emit-llvm-uselists -save-temps=cwd \
-disable-free -clear-ast-before-backend \
-disable-llvm-verifier \
-main-file-name test_linking_lib.cpp \
-mrelocation-model pic -pic-level 2 \
-aux-target-cpu x86-64 \
-fcuda-is-device \
-fno-threadsafe-statics \
-target-cpu gfx1200 \
-debug-info-kind=constructor -dwarf-version=5 \
-std=c++17 \
-cuid=6366e6513e2eabac \
-o test_linking_lib-hip-amdgcn-amd-amdhsa-gfx1200.bc \
-x hip-cpp-output \
test_linking_lib-hip-amdgcn-amd-amdhsa-gfx1200.hipi
Valgrind analysis of the standalone invocation
Even though the standalone invocation does not crash, running it under valgrind consistently reports uninitialized-memory usage inside clang/LLVM:
Conditional jump or move depends on uninitialised value(s)
at clang::CodeGen::CodeGenModule::SetLLVMFunctionAttributesForDefinition
by clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition
by clang::CodeGen::CodeGenModule::EmitGlobalDefinition
...
Uninitialised value was created by a stack allocation
at llvm::Module::setDataLayout
Additional trace:
clang::CodeGen::CodeGenModule::codegenCXXStructor
clang::CodeGen::ItaniumCXXABI::emitCXXStructor
[llvm-hip-gfx1200-repro.tar.gz](https://github.com/user-attachments/files/23591464/llvm-hip-gfx1200-repro.tar.gz)
Full diagnostics: valgrind.txt
Contributor guide
Assessment
This issue has not been assessed yet.