From c0f0d50653e16145beee474a3d0d602596502dde Mon Sep 17 00:00:00 2001 From: "Yaxun (Sam) Liu" Date: Wed, 24 May 2023 12:59:01 -0400 Subject: [HIP] emit macro `__HIP_NO_IMAGE_SUPPORT` HIP texture/image support is optional as some devices do not have image instructions. A macro __HIP_NO_IMAGE_SUPPORT is defined for device not supporting images (https://github.com/ROCm-Developer-Tools/HIP/blob/d0448aa4c4dd0f4b29ccf6a663b7f5ad9f5183e0/docs/reference/kernel_language.md?plain=1#L426 ) Currently the macro is defined by HIP header based on predefined macros for GPU, e.g __gfx*__ , which is error prone. This patch let clang emit the predefined macro. Reviewed by: Matt Arsenault, Artem Belevich Differential Revision: https://reviews.llvm.org/D151349 --- clang/lib/CodeGen/CodeGenModule.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index b5bd9f7c94f5..dd8c384d1317 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2299,6 +2299,9 @@ bool CodeGenModule::GetCPUAndFeaturesAttributes(GlobalDecl GD, AddedAttr = true; } if (!Features.empty() && SetTargetFeatures) { + llvm::erase_if(Features, [&](const std::string& F) { + return getTarget().isReadOnlyFeature(F.substr(1)); + }); llvm::sort(Features); Attrs.addAttribute("target-features", llvm::join(Features, ",")); AddedAttr = true; -- cgit v1.2.3