https://github.com/hardikxk created 
https://github.com/llvm/llvm-project/pull/220526

The following warning is generated because of a mismatch in the object types.

```bash
/home/xane/Documents/shallowllvm/llvm-project/clang/lib/Basic/Targets/AMDGPU.cpp:
 In constructor ‘clang::targets::AMDGPUTargetInfo::AMDGPUTargetInfo(const 
llvm::Triple&, const clang::TargetOptions&)’:
/home/xane/Documents/shallowllvm/llvm-project/clang/lib/Basic/Targets/AMDGPU.cpp:200:37:
 warning: enumerated mismatch in conditional expression: 
‘llvm::AMDGPU::ArchFeatureKind’ vs ‘llvm::AMDGPU::R600FeatureKind’ 
[-Wenum-compare]
  200 |       GPUFeatures(Triple.isAMDGCN() ? llvm::AMDGPU::FEATURE_NONE
      |                   ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  201 |                                     : 
llvm::AMDGPU::getArchAttrR600(GPUKind)) {
      |                                     
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[1/166] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CodeGenPGO.cpp.o^C
```

The type of `GpuFeatures` and return value of `getArchAttrR600()` is ultimately 
an `unsigned` int value. Static cast the return value of the method to 
`unsigned` to resolve the warning without any functional or breaking changes.

>From aa98e176fbb5dfb02e916e52f4dc107288c349a8 Mon Sep 17 00:00:00 2001
From: Hardik Kumar <[email protected]>
Date: Wed, 2 Sep 2026 14:43:57 +0530
Subject: [PATCH] [clang][amdgpu] resolve type mismatch warning in conditional
 comparison
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The following warning is generated because of a mismatch in the object types.

```bash
/home/xane/Documents/shallowllvm/llvm-project/clang/lib/Basic/Targets/AMDGPU.cpp:
 In constructor ‘clang::targets::AMDGPUTargetInfo::AMDGPUTargetInfo(const 
llvm::Triple&, const clang::TargetOptions&)’:
/home/xane/Documents/shallowllvm/llvm-project/clang/lib/Basic/Targets/AMDGPU.cpp:200:37:
 warning: enumerated mismatch in conditional expression: 
‘llvm::AMDGPU::ArchFeatureKind’ vs ‘llvm::AMDGPU::R600FeatureKind’ 
[-Wenum-compare]
  200 |       GPUFeatures(Triple.isAMDGCN() ? llvm::AMDGPU::FEATURE_NONE
      |                   ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  201 |                                     : 
llvm::AMDGPU::getArchAttrR600(GPUKind)) {
      |                                     
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[1/166] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CodeGenPGO.cpp.o^C
```

The type of `GpuFeatures` and return value of `getArchAttrR600()` is
ultimately an `unsigned` int value. Static cast the return value of the
method to `unsigned` to resolve the warning without any functional
or breaking changes.

Signed-off-by: Hardik Kumar <[email protected]>
---
 clang/lib/Basic/Targets/AMDGPU.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index c9e3f6248f82d..c8e2a96f62f9b 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -197,8 +197,10 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple 
&Triple,
                                             Triple.getSubArch())
                                       : 
llvm::AMDGPU::parseArchAMDGCN(Opts.CPU))
                   : llvm::AMDGPU::parseArchR600(Opts.CPU)),
-      GPUFeatures(Triple.isAMDGCN() ? llvm::AMDGPU::FEATURE_NONE
-                                    : llvm::AMDGPU::getArchAttrR600(GPUKind)) {
+      GPUFeatures(
+          Triple.isAMDGCN()
+              ? llvm::AMDGPU::FEATURE_NONE
+              : static_cast<unsigned>(llvm::AMDGPU::getArchAttrR600(GPUKind))) 
{
   resetDataLayout();
 
   AddrSpaceMap = &AMDGPUAddrSpaceMap;

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to