[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-17 Thread Erich Keane via cfe-commits

erichkeane wrote:

> Is there something else needed on my side to get that PR merged?

My apologies, I thought you'd been around LLVM enough that you had merge 
rights.  I've done it now.

https://github.com/llvm/llvm-project/pull/92126
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-17 Thread Erich Keane via cfe-commits

https://github.com/erichkeane closed 
https://github.com/llvm/llvm-project/pull/92126
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-17 Thread Romaric Jodin via cfe-commits

rjodinchr wrote:

Is there something else needed on my side to get that PR merged?

https://github.com/llvm/llvm-project/pull/92126
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-15 Thread Erich Keane via cfe-commits

https://github.com/erichkeane approved this pull request.

Still fine once CI approves

https://github.com/llvm/llvm-project/pull/92126
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-14 Thread Romaric Jodin via cfe-commits

https://github.com/rjodinchr updated 
https://github.com/llvm/llvm-project/pull/92126

>From c8798839ee93caa9e5a3db6d770801a4c22010c8 Mon Sep 17 00:00:00 2001
From: Romaric Jodin 
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/docs/ReleaseNotes.rst|  4 
 clang/include/clang/Basic/Attr.td  |  7 +++
 clang/include/clang/Basic/AttrDocs.td  | 14 ++
 clang/lib/CodeGen/CodeGenFunction.cpp  |  5 +
 clang/test/CodeGen/clspv_libclc_builtin.c  |  6 ++
 ...pragma-attribute-supported-attributes-list.test |  1 +
 libclc/generic/include/clc/clcfunc.h   |  3 +--
 7 files changed, 38 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/CodeGen/clspv_libclc_builtin.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 49ab222bec405..1cec6fb93a344 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -393,6 +393,10 @@ Attribute Changes in Clang
 - Clang now warns that the ``exclude_from_explicit_instantiation`` attribute
   is ignored when applied to a local class or a member thereof.
 
+- The ``clspv_libclc_builtin`` attribute has been added to allow clspv
+  (`OpenCL-C to Vulkan SPIR-V compiler `_) to 
identify functions coming from libclc
+  (`OpenCL-C builtin library `_).
+
 Improvements to Clang's diagnostics
 ---
 - Clang now applies syntax highlighting to the code snippets it
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 52552ba488560..38ee8356583be 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -4561,3 +4561,10 @@ def CodeAlign: StmtAttr {
 static constexpr int MaximumAlignment = 4096;
   }];
 }
+
+def ClspvLibclcBuiltin: InheritableAttr {
+  let Spellings = [Clang<"clspv_libclc_builtin">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [ClspvLibclcBuiltinDoc];
+  let SimpleHandler = 1;
+}
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index f351822ac74bd..b48aaf65558ac 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -8087,3 +8087,17 @@ requirement:
   }
   }];
 }
+
+def ClspvLibclcBuiltinDoc : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Attribute used by `clspv`_ (OpenCL-C to Vulkan SPIR-V compiler) to identify 
functions coming from `libclc`_ (OpenCL-C builtin library).
+
+.. code-block:: c
+
+  void __attribute__((clspv_libclc_builtin)) libclc_builtin() {}
+
+.. _`clspv`: https://github.com/google/clspv
+.. _`libclc`: https://libclc.llvm.org
+}];
+}
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()) {
+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/clang/test/CodeGen/clspv_libclc_builtin.c 
b/clang/test/CodeGen/clspv_libclc_builtin.c
new file mode 100644
index 0..ada2555c79e5b
--- /dev/null
+++ b/clang/test/CodeGen/clspv_libclc_builtin.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple spir -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: @foo()
+// CHECK-SAME: !clspv_libclc_builtin
+
+void __attribute__((clspv_libclc_builtin)) foo() {}
diff --git a/clang/test/Misc/pragma-attribute-supported-attributes-list.test 
b/clang/test/Misc/pragma-attribute-supported-attributes-list.test
index 318bfb2df2a7a..fd0e6d71baa80 100644
--- a/clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ b/clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -48,6 +48,7 @@
 // CHECK-NEXT: Capability (SubjectMatchRule_record, 
SubjectMatchRule_type_alias)
 // CHECK-NEXT: CarriesDependency (SubjectMatchRule_variable_is_parameter, 
SubjectMatchRule_objc_method, SubjectMatchRule_function)
 // CHECK-NEXT: Cleanup (SubjectMatchRule_variable_is_local)
+// CHECK-NEXT: ClspvLibclcBuiltin (SubjectMatchRule_function)
 // CHECK-NEXT: CmseNSEntry (SubjectMatchRule_function)
 // CHECK-NEXT: Cold (SubjectMatchRule_function)
 // 

[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-14 Thread via cfe-commits

Sirraide wrote:

There’s a test that checks all attributes that we support 
(Misc/pragma-attribute-supported-attributes-list.test) and which is failing at 
the moment; you’ll have to add this attribute there as well.

https://github.com/llvm/llvm-project/pull/92126
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-14 Thread Romaric Jodin via cfe-commits

https://github.com/rjodinchr updated 
https://github.com/llvm/llvm-project/pull/92126

>From 4ce295d3dbd7a5b723cdf410d2023eb59120d27a Mon Sep 17 00:00:00 2001
From: Romaric Jodin 
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/docs/ReleaseNotes.rst   |  4 
 clang/include/clang/Basic/Attr.td |  7 +++
 clang/include/clang/Basic/AttrDocs.td | 14 ++
 clang/lib/CodeGen/CodeGenFunction.cpp |  5 +
 clang/test/CodeGen/clspv_libclc_builtin.c |  6 ++
 libclc/generic/include/clc/clcfunc.h  |  3 +--
 6 files changed, 37 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/CodeGen/clspv_libclc_builtin.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 49ab222bec405..1cec6fb93a344 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -393,6 +393,10 @@ Attribute Changes in Clang
 - Clang now warns that the ``exclude_from_explicit_instantiation`` attribute
   is ignored when applied to a local class or a member thereof.
 
+- The ``clspv_libclc_builtin`` attribute has been added to allow clspv
+  (`OpenCL-C to Vulkan SPIR-V compiler `_) to 
identify functions coming from libclc
+  (`OpenCL-C builtin library `_).
+
 Improvements to Clang's diagnostics
 ---
 - Clang now applies syntax highlighting to the code snippets it
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 52552ba488560..38ee8356583be 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -4561,3 +4561,10 @@ def CodeAlign: StmtAttr {
 static constexpr int MaximumAlignment = 4096;
   }];
 }
+
+def ClspvLibclcBuiltin: InheritableAttr {
+  let Spellings = [Clang<"clspv_libclc_builtin">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [ClspvLibclcBuiltinDoc];
+  let SimpleHandler = 1;
+}
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index f351822ac74bd..b48aaf65558ac 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -8087,3 +8087,17 @@ requirement:
   }
   }];
 }
+
+def ClspvLibclcBuiltinDoc : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Attribute used by `clspv`_ (OpenCL-C to Vulkan SPIR-V compiler) to identify 
functions coming from `libclc`_ (OpenCL-C builtin library).
+
+.. code-block:: c
+
+  void __attribute__((clspv_libclc_builtin)) libclc_builtin() {}
+
+.. _`clspv`: https://github.com/google/clspv
+.. _`libclc`: https://libclc.llvm.org
+}];
+}
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()) {
+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/clang/test/CodeGen/clspv_libclc_builtin.c 
b/clang/test/CodeGen/clspv_libclc_builtin.c
new file mode 100644
index 0..ada2555c79e5b
--- /dev/null
+++ b/clang/test/CodeGen/clspv_libclc_builtin.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple spir -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: @foo()
+// CHECK-SAME: !clspv_libclc_builtin
+
+void __attribute__((clspv_libclc_builtin)) foo() {}
diff --git a/libclc/generic/include/clc/clcfunc.h 
b/libclc/generic/include/clc/clcfunc.h
index ad9eb23f29333..086d780b97085 100644
--- a/libclc/generic/include/clc/clcfunc.h
+++ b/libclc/generic/include/clc/clcfunc.h
@@ -7,8 +7,7 @@
 #if defined(CLC_SPIRV) || defined(CLC_SPIRV64)
 #define _CLC_DEF
 #elif defined(CLC_CLSPV) || defined(CLC_CLSPV64)
-#define _CLC_DEF   
\
-  __attribute__((noinline)) __attribute__((assume("clspv_libclc_builtin")))
+#define _CLC_DEF __attribute__((noinline)) 
__attribute__((clspv_libclc_builtin))
 #else
 #define _CLC_DEF __attribute__((always_inline))
 #endif

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-14 Thread Erich Keane via cfe-commits

https://github.com/erichkeane approved this pull request.


https://github.com/llvm/llvm-project/pull/92126
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-14 Thread Romaric Jodin via cfe-commits

https://github.com/rjodinchr updated 
https://github.com/llvm/llvm-project/pull/92126

>From df793384bdb689b3b74ca83102a539a1db623e9f Mon Sep 17 00:00:00 2001
From: Romaric Jodin 
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/docs/ReleaseNotes.rst   |  4 
 clang/include/clang/Basic/Attr.td |  7 +++
 clang/include/clang/Basic/AttrDocs.td | 14 ++
 clang/lib/CodeGen/CodeGenFunction.cpp |  5 +
 clang/test/CodeGen/clspv_libclc_builtin.c |  6 ++
 libclc/generic/include/clc/clcfunc.h  |  3 +--
 6 files changed, 37 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/CodeGen/clspv_libclc_builtin.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 49ab222bec405..2ba25e5a01846 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -393,6 +393,10 @@ Attribute Changes in Clang
 - Clang now warns that the ``exclude_from_explicit_instantiation`` attribute
   is ignored when applied to a local class or a member thereof.
 
+- The ``clspv_libclc_builtin`` attribute has been added to allow clspv
+  (`OpenCL-C to Vulkan SPIR-V compiler `_).
+
 Improvements to Clang's diagnostics
 ---
 - Clang now applies syntax highlighting to the code snippets it
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 52552ba488560..38ee8356583be 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -4561,3 +4561,10 @@ def CodeAlign: StmtAttr {
 static constexpr int MaximumAlignment = 4096;
   }];
 }
+
+def ClspvLibclcBuiltin: InheritableAttr {
+  let Spellings = [Clang<"clspv_libclc_builtin">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [ClspvLibclcBuiltinDoc];
+  let SimpleHandler = 1;
+}
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index f351822ac74bd..b48aaf65558ac 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -8087,3 +8087,17 @@ requirement:
   }
   }];
 }
+
+def ClspvLibclcBuiltinDoc : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Attribute used by `clspv`_ (OpenCL-C to Vulkan SPIR-V compiler) to identify 
functions coming from `libclc`_ (OpenCL-C builtin library).
+
+.. code-block:: c
+
+  void __attribute__((clspv_libclc_builtin)) libclc_builtin() {}
+
+.. _`clspv`: https://github.com/google/clspv
+.. _`libclc`: https://libclc.llvm.org
+}];
+}
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()) {
+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/clang/test/CodeGen/clspv_libclc_builtin.c 
b/clang/test/CodeGen/clspv_libclc_builtin.c
new file mode 100644
index 0..ada2555c79e5b
--- /dev/null
+++ b/clang/test/CodeGen/clspv_libclc_builtin.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple spir -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: @foo()
+// CHECK-SAME: !clspv_libclc_builtin
+
+void __attribute__((clspv_libclc_builtin)) foo() {}
diff --git a/libclc/generic/include/clc/clcfunc.h 
b/libclc/generic/include/clc/clcfunc.h
index ad9eb23f29333..086d780b97085 100644
--- a/libclc/generic/include/clc/clcfunc.h
+++ b/libclc/generic/include/clc/clcfunc.h
@@ -7,8 +7,7 @@
 #if defined(CLC_SPIRV) || defined(CLC_SPIRV64)
 #define _CLC_DEF
 #elif defined(CLC_CLSPV) || defined(CLC_CLSPV64)
-#define _CLC_DEF   
\
-  __attribute__((noinline)) __attribute__((assume("clspv_libclc_builtin")))
+#define _CLC_DEF __attribute__((noinline)) 
__attribute__((clspv_libclc_builtin))
 #else
 #define _CLC_DEF __attribute__((always_inline))
 #endif

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-14 Thread Erich Keane via cfe-commits


@@ -393,6 +393,8 @@ Attribute Changes in Clang
 - Clang now warns that the ``exclude_from_explicit_instantiation`` attribute
   is ignored when applied to a local class or a member thereof.
 
+- The ``clspv_libclc_builtin`` attribute has been added to allow clspv to 
identified functions coming from libclc.

erichkeane wrote:

```suggestion
- The ``clspv_libclc_builtin`` attribute has been added to allow clspv to 
identify functions coming from libclc.
```

I'd suggest clarifying via a parenthetical what clspv and libclc are.

https://github.com/llvm/llvm-project/pull/92126
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-14 Thread Erich Keane via cfe-commits


@@ -8087,3 +8087,10 @@ requirement:
   }
   }];
 }
+
+def ClspvLibclcBuiltinDoc : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Attribute used by clspv to identified functions coming from libclc.

erichkeane wrote:

I think this needs quite a bit more details, please see the rest of the 
AttrDocs examples, they typically go into examples, and at least specify what 
things like clspv and libclc would mean.

https://github.com/llvm/llvm-project/pull/92126
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-14 Thread Romaric Jodin via cfe-commits

https://github.com/rjodinchr updated 
https://github.com/llvm/llvm-project/pull/92126

>From 05fd8c24146a5237c7c4cc425beb205524429ba7 Mon Sep 17 00:00:00 2001
From: Romaric Jodin 
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/docs/ReleaseNotes.rst   | 2 ++
 clang/include/clang/Basic/Attr.td | 7 +++
 clang/include/clang/Basic/AttrDocs.td | 7 +++
 clang/lib/CodeGen/CodeGenFunction.cpp | 5 +
 clang/test/CodeGen/clspv_libclc_builtin.c | 6 ++
 libclc/generic/include/clc/clcfunc.h  | 3 +--
 6 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/CodeGen/clspv_libclc_builtin.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 49ab222bec405..6fc8a5771a9a8 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -393,6 +393,8 @@ Attribute Changes in Clang
 - Clang now warns that the ``exclude_from_explicit_instantiation`` attribute
   is ignored when applied to a local class or a member thereof.
 
+- The ``clspv_libclc_builtin`` attribute has been added to allow clspv to 
identified functions coming from libclc.
+
 Improvements to Clang's diagnostics
 ---
 - Clang now applies syntax highlighting to the code snippets it
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 52552ba488560..38ee8356583be 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -4561,3 +4561,10 @@ def CodeAlign: StmtAttr {
 static constexpr int MaximumAlignment = 4096;
   }];
 }
+
+def ClspvLibclcBuiltin: InheritableAttr {
+  let Spellings = [Clang<"clspv_libclc_builtin">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [ClspvLibclcBuiltinDoc];
+  let SimpleHandler = 1;
+}
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index f351822ac74bd..1d4ba5b602a01 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -8087,3 +8087,10 @@ requirement:
   }
   }];
 }
+
+def ClspvLibclcBuiltinDoc : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Attribute used by clspv to identified functions coming from libclc.
+}];
+}
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()) {
+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/clang/test/CodeGen/clspv_libclc_builtin.c 
b/clang/test/CodeGen/clspv_libclc_builtin.c
new file mode 100644
index 0..ada2555c79e5b
--- /dev/null
+++ b/clang/test/CodeGen/clspv_libclc_builtin.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple spir -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: @foo()
+// CHECK-SAME: !clspv_libclc_builtin
+
+void __attribute__((clspv_libclc_builtin)) foo() {}
diff --git a/libclc/generic/include/clc/clcfunc.h 
b/libclc/generic/include/clc/clcfunc.h
index ad9eb23f29333..086d780b97085 100644
--- a/libclc/generic/include/clc/clcfunc.h
+++ b/libclc/generic/include/clc/clcfunc.h
@@ -7,8 +7,7 @@
 #if defined(CLC_SPIRV) || defined(CLC_SPIRV64)
 #define _CLC_DEF
 #elif defined(CLC_CLSPV) || defined(CLC_CLSPV64)
-#define _CLC_DEF   
\
-  __attribute__((noinline)) __attribute__((assume("clspv_libclc_builtin")))
+#define _CLC_DEF __attribute__((noinline)) 
__attribute__((clspv_libclc_builtin))
 #else
 #define _CLC_DEF __attribute__((always_inline))
 #endif

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-14 Thread Erich Keane via cfe-commits

erichkeane wrote:

> @erichkeane, I don't know what you expect for the release note, where should 
> I write something?

See `ReleaseNotes.rst`, find a section that makes sense (probably attribute 
changes), and write a quick blurb about the attribute, likely a very condensed 
version of the docs.

https://github.com/llvm/llvm-project/pull/92126
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-14 Thread Romaric Jodin via cfe-commits

rjodinchr wrote:

@erichkeane, I don't know what you expect for the release note, where should I 
write something?

https://github.com/llvm/llvm-project/pull/92126
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-14 Thread Erich Keane via cfe-commits


@@ -4561,3 +4561,9 @@ def CodeAlign: StmtAttr {
 static constexpr int MaximumAlignment = 4096;
   }];
 }
+
+def ClspvLibclcBuiltin: DeclOrStmtAttr {
+  let Spellings = [Clang<"clspv_libclc_builtin">];
+  let Documentation = [Undocumented];

erichkeane wrote:

`DocCatFunction`?  As it seems to be a function decl attribute.  Subjects 
should be functions only it appears.

https://github.com/llvm/llvm-project/pull/92126
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-14 Thread Romaric Jodin via cfe-commits


@@ -4561,3 +4561,9 @@ def CodeAlign: StmtAttr {
 static constexpr int MaximumAlignment = 4096;
   }];
 }
+
+def ClspvLibclcBuiltin: DeclOrStmtAttr {
+  let Spellings = [Clang<"clspv_libclc_builtin">];
+  let Documentation = [Undocumented];

rjodinchr wrote:

What should be the documentation category?

https://github.com/llvm/llvm-project/pull/92126
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-14 Thread Romaric Jodin via cfe-commits


@@ -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;

rjodinchr wrote:

I have never dealt with clang attribute implementation, so I have no idea 
whether `DeclOrStmtAttr` or `InheritableAttr` should be used. I'll change it 
for `InheritableAttr`.

https://github.com/llvm/llvm-project/pull/92126
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-14 Thread via cfe-commits


@@ -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;

Sirraide wrote:

Also, is there a reason as to why it’s a `DeclOrStmtAttr` instead of an 
`InheritableAttr`? Because afaik most of the other function attributes use the 
latter.

https://github.com/llvm/llvm-project/pull/92126
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-14 Thread Erich Keane via cfe-commits


@@ -4561,3 +4561,9 @@ def CodeAlign: StmtAttr {
 static constexpr int MaximumAlignment = 4096;
   }];
 }
+
+def ClspvLibclcBuiltin: DeclOrStmtAttr {
+  let Spellings = [Clang<"clspv_libclc_builtin">];
+  let Documentation = [Undocumented];

erichkeane wrote:

Please add documentation anyway.  See `AttrDocs.td`

https://github.com/llvm/llvm-project/pull/92126
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-14 Thread Erich Keane via cfe-commits


@@ -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;

erichkeane wrote:

This should also probably set 'appertainment' via `Subjects`.

https://github.com/llvm/llvm-project/pull/92126
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-14 Thread Erich Keane via cfe-commits

https://github.com/erichkeane commented:

Also needs:
-a release note
-A test: At least a test against LLVM-IR (CodeGen test).

https://github.com/llvm/llvm-project/pull/92126
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-14 Thread Erich Keane via cfe-commits

https://github.com/erichkeane edited 
https://github.com/llvm/llvm-project/pull/92126
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-14 Thread Romaric Jodin via cfe-commits

https://github.com/rjodinchr updated 
https://github.com/llvm/llvm-project/pull/92126

>From 41e2a5c3fd693fad20e2f76d1a39a1ac9468a33b Mon Sep 17 00:00:00 2001
From: Romaric Jodin 
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  | 3 +--
 3 files changed, 12 insertions(+), 2 deletions(-)

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()) {
+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..086d780b97085 100644
--- a/libclc/generic/include/clc/clcfunc.h
+++ b/libclc/generic/include/clc/clcfunc.h
@@ -7,8 +7,7 @@
 #if defined(CLC_SPIRV) || defined(CLC_SPIRV64)
 #define _CLC_DEF
 #elif defined(CLC_CLSPV) || defined(CLC_CLSPV64)
-#define _CLC_DEF   
\
-  __attribute__((noinline)) __attribute__((assume("clspv_libclc_builtin")))
+#define _CLC_DEF __attribute__((noinline)) 
__attribute__((clspv_libclc_builtin))
 #else
 #define _CLC_DEF __attribute__((always_inline))
 #endif

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-14 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 041baf2f60ac3e107399641aea04c77019e7eab8 
4dc2646a51a05abe7cfb539325dbd57d507dfceb -- 
clang/lib/CodeGen/CodeGenFunction.cpp libclc/generic/include/clc/clcfunc.h
``





View the diff from clang-format here.


``diff
diff --git a/libclc/generic/include/clc/clcfunc.h 
b/libclc/generic/include/clc/clcfunc.h
index 59f45c2701..086d780b97 100644
--- a/libclc/generic/include/clc/clcfunc.h
+++ b/libclc/generic/include/clc/clcfunc.h
@@ -7,8 +7,7 @@
 #if defined(CLC_SPIRV) || defined(CLC_SPIRV64)
 #define _CLC_DEF
 #elif defined(CLC_CLSPV) || defined(CLC_CLSPV64)
-#define _CLC_DEF   
\
-  __attribute__((noinline)) __attribute__((clspv_libclc_builtin))
+#define _CLC_DEF __attribute__((noinline)) 
__attribute__((clspv_libclc_builtin))
 #else
 #define _CLC_DEF __attribute__((always_inline))
 #endif

``




https://github.com/llvm/llvm-project/pull/92126
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-14 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-codegen

@llvm/pr-subscribers-clang

Author: Romaric Jodin (rjodinchr)


Changes

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

---
Full diff: https://github.com/llvm/llvm-project/pull/92126.diff


3 Files Affected:

- (modified) clang/include/clang/Basic/Attr.td (+6) 
- (modified) clang/lib/CodeGen/CodeGenFunction.cpp (+5) 
- (modified) libclc/generic/include/clc/clcfunc.h (+1-1) 


``diff
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()) {
+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

``




https://github.com/llvm/llvm-project/pull/92126
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclc] libclc: remove __attribute__((assume)) for clspv targets (PR #92126)

2024-05-14 Thread Romaric Jodin via cfe-commits

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 
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()) {
+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

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits