[clang] 6fecfbc - [AMDGPU] Correctly exclude the HIP host from arch macros
Joseph Huber via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 30 11:45:07 PST 2024
Author: Joseph Huber
Date: 2024-01-30T13:45:01-06:00
New Revision: 6fecfbc7b62f54bd633e83c22630d7c2a3e5741e
URL: https://github.com/llvm/llvm-project/commit/6fecfbc7b62f54bd633e83c22630d7c2a3e5741e
DIFF: https://github.com/llvm/llvm-project/commit/6fecfbc7b62f54bd633e83c22630d7c2a3e5741e.diff
LOG: [AMDGPU] Correctly exclude the HIP host from arch macros
Summary:
This logic was wrong and accidentally appling to OpenCL.
Added:
Modified:
clang/lib/Basic/Targets/AMDGPU.cpp
Removed:
################################################################################
diff --git a/clang/lib/Basic/Targets/AMDGPU.cpp b/clang/lib/Basic/Targets/AMDGPU.cpp
index d2ef3dafc6b3e..141501e8a4d9a 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -275,14 +275,15 @@ void AMDGPUTargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__R600__");
// Legacy HIP host code relies on these default attributes to be defined.
- if (GPUKind == llvm::AMDGPU::GK_NONE && !(Opts.HIP && !Opts.CUDAIsDevice))
+ bool IsHIPHost = Opts.HIP && !Opts.CUDAIsDevice;
+ if (GPUKind == llvm::AMDGPU::GK_NONE && !IsHIPHost)
return;
StringRef CanonName = isAMDGCN(getTriple()) ? getArchNameAMDGCN(GPUKind)
: getArchNameR600(GPUKind);
Builder.defineMacro(Twine("__") + Twine(CanonName) + Twine("__"));
// Emit macros for gfx family e.g. gfx906 -> __GFX9__, gfx1030 -> __GFX10___
- if (isAMDGCN(getTriple()) && Opts.CUDAIsDevice) {
+ if (isAMDGCN(getTriple()) && !IsHIPHost) {
assert(CanonName.starts_with("gfx") && "Invalid amdgcn canonical name");
Builder.defineMacro(Twine("__") + Twine(CanonName.drop_back(2).upper()) +
Twine("__"));
More information about the cfe-commits
mailing list