[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)
Romaric Jodin via cfe-commits
cfe-commits at lists.llvm.org
Tue May 14 07:11:31 PDT 2024
https://github.com/rjodinchr created https://github.com/llvm/llvm-project/pull/92126
Instead add a proper attribute in clang, and add convert it to function metadata to keep the information in the IR. The goal is to remove the dependency on __attribute__((assume)) that should have not be there in the first place.
Ref https://github.com/llvm/llvm-project/pull/84934
>From 4dc2646a51a05abe7cfb539325dbd57d507dfceb Mon Sep 17 00:00:00 2001
From: Romaric Jodin <rjodin at chromium.org>
Date: Tue, 14 May 2024 16:08:26 +0200
Subject: [PATCH] libclc: remove __attribute__((assume)) for clspv targets
Instead add a proper attribute in clang, and add convert it to
function metadata to keep the information in the IR.
The goal is to remove the dependency on __attribute__((assume)) that
should have not be there in the first place.
Ref https://github.com/llvm/llvm-project/pull/84934
---
clang/include/clang/Basic/Attr.td | 6 ++++++
clang/lib/CodeGen/CodeGenFunction.cpp | 5 +++++
libclc/generic/include/clc/clcfunc.h | 2 +-
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index 52552ba488560..0970110ee581d 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -4561,3 +4561,9 @@ def CodeAlign: StmtAttr {
static constexpr int MaximumAlignment = 4096;
}];
}
+
+def ClspvLibclcBuiltin: DeclOrStmtAttr {
+ let Spellings = [Clang<"clspv_libclc_builtin">];
+ let Documentation = [Undocumented];
+ let SimpleHandler = 1;
+}
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 9f16fcb438557..4c4f368ddeba1 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -979,6 +979,11 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
EmitKernelMetadata(FD, Fn);
}
+ if (FD && FD->hasAttr<ClspvLibclcBuiltinAttr>()) {
+ Fn->setMetadata("clspv_libclc_builtin",
+ llvm::MDNode::get(getLLVMContext(), {}));
+ }
+
// If we are checking function types, emit a function type signature as
// prologue data.
if (FD && SanOpts.has(SanitizerKind::Function)) {
diff --git a/libclc/generic/include/clc/clcfunc.h b/libclc/generic/include/clc/clcfunc.h
index ad9eb23f29333..59f45c27019d6 100644
--- a/libclc/generic/include/clc/clcfunc.h
+++ b/libclc/generic/include/clc/clcfunc.h
@@ -8,7 +8,7 @@
#define _CLC_DEF
#elif defined(CLC_CLSPV) || defined(CLC_CLSPV64)
#define _CLC_DEF \
- __attribute__((noinline)) __attribute__((assume("clspv_libclc_builtin")))
+ __attribute__((noinline)) __attribute__((clspv_libclc_builtin))
#else
#define _CLC_DEF __attribute__((always_inline))
#endif
More information about the cfe-commits
mailing list