[clang] [llvm] [AMDGPU] Make cluster a target feature (PR #162040)

James Y Knight via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 6 15:53:43 PDT 2025


jyknight wrote:

The error arises because [AMDGPUAttributor.cpp](https://github.com/llvm/llvm-project/blob/3491738601ecb0c63f23d01bfb1653893b5ef2c7/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp#L1514) calls `TM.getSubtarget<GCNSubtarget>(*F);`, and despite appearances and its documentation, getSubtarget [does an unchecked static_cast](https://github.com/llvm/llvm-project/blob/3491738601ecb0c63f23d01bfb1653893b5ef2c7/llvm/include/llvm/Target/TargetMachine.h#L199) to the specified type. This code can apparently be invoked with an R600Subtarget, and casting an R600Subtarget to a GCNSubtarget is completely utterly broken.

The code in question was added to AMDGPUAttributor.cpp 3 weeks ago in #158076 -- so I guess it worked before only by complete accident...

https://github.com/llvm/llvm-project/pull/162040


More information about the llvm-commits mailing list