-
Notifications
You must be signed in to change notification settings - Fork 15.2k
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
- Preprocessed source file
The exact input given to clang is included:
➡️ test_linking_lib-hip-amdgcn-amd-amdhsa-gfx1200.hipi
- 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
Full diagnostics: valgrind.txt