[clang] [SYCL] SYCL host kernel launch support for the sycl_kernel_entry_point attribute. (PR #152403)

2025-08-25 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann updated https://github.com/llvm/llvm-project/pull/152403 >From d0b53b9550d4332049b3b28ca649e2cf47a0cfbc Mon Sep 17 00:00:00 2001 From: Tom Honermann Date: Wed, 6 Aug 2025 19:26:54 -0700 Subject: [PATCH 1/4] [SYCL] SYCL host kernel launch support for the sycl_kern

[clang] [NFC][SYCL] Test use of sycl_kernel_entry_point with null declarations and statements. (PR #154583)

2025-08-21 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann closed https://github.com/llvm/llvm-project/pull/154583 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NFC] Remove unneeded forward declaration of diagnoseUncapturableValueReferenceOrBinding() (PR #154591)

2025-08-20 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann closed https://github.com/llvm/llvm-project/pull/154591 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NFC] Remove unneeded forward declaration of diagnoseUncapturableValueReferenceOrBinding() (PR #154591)

2025-08-20 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann created https://github.com/llvm/llvm-project/pull/154591 The only (remaining) use of this forward declaration was removed in commit 127bf44385424891eb04cff8e52d3f157fc2cb7c. >From a35c62390074972fe272bc4f0f2a82da5b65 Mon Sep 17 00:00:00 2001 From: Tom Honerman

[clang] [NFC][SYCL] Test use of sycl_kernel_entry_point with null declarations and statements. (PR #154583)

2025-08-20 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann created https://github.com/llvm/llvm-project/pull/154583 The `sycl_kernel_entry_point` attribute only appertains to functions. This change adds missing tests to validate that an appropriate diagnostic is issued for likely unintentional application of the attribut

[clang] [SYCL] SYCL host kernel launch support for the sycl_kernel_entry_point attribute. (PR #152403)

2025-08-17 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann updated https://github.com/llvm/llvm-project/pull/152403 >From 5b42f6b9470a96a79b3474fcf384fa950449e095 Mon Sep 17 00:00:00 2001 From: Tom Honermann Date: Wed, 6 Aug 2025 19:26:54 -0700 Subject: [PATCH 1/4] [SYCL] SYCL host kernel launch support for the sycl_kern

[clang] [SYCL] SYCL host kernel launch support for the sycl_kernel_entry_point attribute. (PR #152403)

2025-08-16 Thread Tom Honermann via cfe-commits
@@ -410,6 +474,36 @@ class OutlinedFunctionDeclBodyInstantiator ParmDeclMap &MapRef; }; +OutlinedFunctionDecl *BuildSYCLKernelEntryPointOutline(Sema &SemaRef, + FunctionDecl *FD, +

[clang] [SYCL] SYCL host kernel launch support for the sycl_kernel_entry_point attribute. (PR #152403)

2025-08-16 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann updated https://github.com/llvm/llvm-project/pull/152403 >From 5b42f6b9470a96a79b3474fcf384fa950449e095 Mon Sep 17 00:00:00 2001 From: Tom Honermann Date: Wed, 6 Aug 2025 19:26:54 -0700 Subject: [PATCH 1/3] [SYCL] SYCL host kernel launch support for the sycl_kern

[clang] [SYCL] SYCL host kernel launch support for the sycl_kernel_entry_point attribute. (PR #152403)

2025-08-16 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann updated https://github.com/llvm/llvm-project/pull/152403 >From 5b42f6b9470a96a79b3474fcf384fa950449e095 Mon Sep 17 00:00:00 2001 From: Tom Honermann Date: Wed, 6 Aug 2025 19:26:54 -0700 Subject: [PATCH 1/2] [SYCL] SYCL host kernel launch support for the sycl_kern

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-08-15 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann approved this pull request. Thank you, @schittir, for all your hard work on this! It looks great! @erichkeane, @bader, please review at your earliest convenience! https://github.com/llvm/llvm-project/pull/140282 ___ cfe-

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-08-13 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,157 @@ +// RUN: %clang_cc1 -fsycl-is-host -std=c++17 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsycl-is-device -std=c++17 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsycl-is-host -std=c++20 -fsyntax-only -verify -DCPP20 %s +// RUN: %clang_cc1 -fsycl-is-device -st

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-08-13 Thread Tom Honermann via cfe-commits
@@ -250,6 +250,20 @@ static bool CheckSYCLKernelName(Sema &S, SourceLocation Loc, return false; } +void SemaSYCL::CheckSYCLExternalFunctionDecl(FunctionDecl *FD) { + const auto *SEAttr = FD->getAttr(); + assert(SEAttr && "Missing sycl_external attribute"); + if (!FD->isE

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-08-13 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,157 @@ +// RUN: %clang_cc1 -fsycl-is-host -std=c++17 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsycl-is-device -std=c++17 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsycl-is-host -std=c++20 -fsyntax-only -verify -DCPP20 %s +// RUN: %clang_cc1 -fsycl-is-device -st

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-08-13 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,78 @@ +// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s + +// This test code generation when sycl_external attribute is used + +// Function defined and not used - symbols emitted +[[clang::sycl_ex

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-08-13 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,78 @@ +// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s + +// This test code generation when sycl_external attribute is used + +// Function defined and not used - symbols emitted +[[clang::sycl_ex

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-08-13 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann edited https://github.com/llvm/llvm-project/pull/140282 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-08-13 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,157 @@ +// RUN: %clang_cc1 -fsycl-is-host -std=c++17 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsycl-is-device -std=c++17 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsycl-is-host -std=c++20 -fsyntax-only -verify -DCPP20 %s +// RUN: %clang_cc1 -fsycl-is-device -st

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-08-13 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann requested changes to this pull request. Suggestions to address the diagnostic issues with explicit and implicit template instantiations as well as a couple of additional tests. https://github.com/llvm/llvm-project/pull/140282 __

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-08-13 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,77 @@ +// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s + +// This test code generation when sycl_external attribute is used + +// Function defined and not used - symbols emitted +[[clang::sycl_ex

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-08-13 Thread Tom Honermann via cfe-commits
@@ -4084,6 +4084,19 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, Scope *S, diag::note_carries_dependency_missing_first_decl) << 0/*Function*/; } +// SYCL 2020 section 5.10.1, "SYCL functions and member functions linkage": +// W

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-08-13 Thread Tom Honermann via cfe-commits
@@ -12251,6 +12264,9 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, if (NewFD->hasAttr()) SYCL().CheckSYCLEntryPointFunctionDecl(NewFD); + if (NewFD->hasAttr()) +SYCL().CheckSYCLExternalFunctionDecl(NewFD); tahonermann wrote:

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-08-13 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,77 @@ +// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s + +// This test code generation when sycl_external attribute is used + +// Function defined and not used - symbols emitted +[[clang::sycl_ex

[clang] [SYCL] SYCL host kernel launch support for the sycl_kernel_entry_point attribute. (PR #152403)

2025-08-08 Thread Tom Honermann via cfe-commits
@@ -367,6 +370,67 @@ void SemaSYCL::CheckSYCLEntryPointFunctionDecl(FunctionDecl *FD) { namespace { +CompoundStmt *BuildSYCLKernelLaunchStmt(Sema &SemaRef, FunctionDecl *FD, +const std::string &KernelName) { + ASTContext &Ctx = SemaRe

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-08-07 Thread Tom Honermann via cfe-commits
@@ -12251,6 +12264,9 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, if (NewFD->hasAttr()) SYCL().CheckSYCLEntryPointFunctionDecl(NewFD); + if (NewFD->hasAttr()) +SYCL().CheckSYCLExternalFunctionDecl(NewFD); tahonermann wrote:

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-08-07 Thread Tom Honermann via cfe-commits
@@ -12251,6 +12264,9 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, if (NewFD->hasAttr()) SYCL().CheckSYCLEntryPointFunctionDecl(NewFD); + if (NewFD->hasAttr()) +SYCL().CheckSYCLExternalFunctionDecl(NewFD); tahonermann wrote:

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-08-07 Thread Tom Honermann via cfe-commits
@@ -4084,6 +4084,19 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, Scope *S, diag::note_carries_dependency_missing_first_decl) << 0/*Function*/; } +// SYCL 2020 section 5.10.1, "SYCL functions and member functions linkage": +// W

[clang] [SYCL] SYCL host kernel launch support for the sycl_kernel_entry_point attribute. (PR #152403)

2025-08-07 Thread Tom Honermann via cfe-commits
@@ -367,6 +370,67 @@ void SemaSYCL::CheckSYCLEntryPointFunctionDecl(FunctionDecl *FD) { namespace { +CompoundStmt *BuildSYCLKernelLaunchStmt(Sema &SemaRef, FunctionDecl *FD, +const std::string &KernelName) { + ASTContext &Ctx = SemaRe

[clang] [SYCL] SYCL host kernel launch support for the sycl_kernel_entry_point attribute. (PR #152403)

2025-08-06 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann updated https://github.com/llvm/llvm-project/pull/152403 >From 5b42f6b9470a96a79b3474fcf384fa950449e095 Mon Sep 17 00:00:00 2001 From: Tom Honermann Date: Wed, 6 Aug 2025 19:26:54 -0700 Subject: [PATCH] [SYCL] SYCL host kernel launch support for the sycl_kernel_e

[clang] [SYCL] Restrict the sycl_kernel_entry_point attribute spelling to C++11 style. (PR #151405)

2025-07-31 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann updated https://github.com/llvm/llvm-project/pull/151405 >From 17fd9871a422cb2b4c3697b66011ae7f5c84379d Mon Sep 17 00:00:00 2001 From: Tom Honermann Date: Wed, 30 Jul 2025 14:52:03 -0700 Subject: [PATCH 1/2] [SYCL] Restrict the sycl_kernel_entry_point attribute s

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-31 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,73 @@ +// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s + +// This test code generation when sycl_external attribute is used + +// Function defined and not used - symbols emitted +[[clang::sycl_ex

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-23 Thread Tom Honermann via cfe-commits
@@ -12251,6 +12264,9 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, if (NewFD->hasAttr()) SYCL().CheckSYCLEntryPointFunctionDecl(NewFD); + if (NewFD->hasAttr()) +SYCL().CheckSYCLExternalFunctionDecl(NewFD); tahonermann wrote:

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-23 Thread Tom Honermann via cfe-commits
@@ -12251,6 +12264,9 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, if (NewFD->hasAttr()) SYCL().CheckSYCLEntryPointFunctionDecl(NewFD); + if (NewFD->hasAttr()) +SYCL().CheckSYCLExternalFunctionDecl(NewFD); tahonermann wrote:

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-23 Thread Tom Honermann via cfe-commits
@@ -12937,6 +12937,10 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) { if (D->hasAttr()) return false; + if (LangOpts.SYCLIsDevice && !D->hasAttr() && + !D->hasAttr()) tahonermann wrote: Your suggested change would not be correct because it

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-23 Thread Tom Honermann via cfe-commits
@@ -12937,6 +12937,10 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) { if (D->hasAttr()) return false; + if (LangOpts.SYCLIsDevice && !D->hasAttr() && + !D->hasAttr()) tahonermann wrote: I mentioned global variables are just one example; we

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-23 Thread Tom Honermann via cfe-commits
@@ -1641,6 +1641,13 @@ def DeviceKernel : DeclOrTypeAttr { }]; } +def SYCLExternal : InheritableAttr { + let Spellings = [Clang<"sycl_external">]; tahonermann wrote: Ok, I'm fine with dropping the GNU spelling. But in that case, we should also change the `s

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-23 Thread Tom Honermann via cfe-commits
@@ -12251,6 +12264,9 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, if (NewFD->hasAttr()) SYCL().CheckSYCLEntryPointFunctionDecl(NewFD); + if (NewFD->hasAttr()) +SYCL().CheckSYCLExternalFunctionDecl(NewFD); tahonermann wrote:

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-23 Thread Tom Honermann via cfe-commits
@@ -16275,6 +16297,13 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, } } + if (FD && !FD->isInvalidDecl() && FD->hasAttr()) { +SYCLExternalAttr *SEAttr = FD->getAttr(); +if (FD->isDeletedAsWritten()) tahonermann wrote: Sindhu an

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-23 Thread Tom Honermann via cfe-commits
@@ -4084,6 +4084,19 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, Scope *S, diag::note_carries_dependency_missing_first_decl) << 0/*Function*/; } +// SYCL 2020 section 5.10.1, "SYCL functions and member functions linkage": +// W

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-23 Thread Tom Honermann via cfe-commits
@@ -12937,6 +12937,10 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) { if (D->hasAttr()) return false; + if (LangOpts.SYCLIsDevice && !D->hasAttr() && + !D->hasAttr()) tahonermann wrote: That is intentional and consistent with what DPC++ doe

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-23 Thread Tom Honermann via cfe-commits
@@ -12908,6 +12908,14 @@ def err_sycl_special_type_num_init_method : Error< "types with 'sycl_special_class' attribute must have one and only one '__init' " "method defined">; +// SYCL external attribute diagnostics +def err_sycl_attribute_invalid_linkage : Error< + "'sy

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-23 Thread Tom Honermann via cfe-commits
@@ -1641,6 +1641,13 @@ def DeviceKernel : DeclOrTypeAttr { }]; } +def SYCLExternal : InheritableAttr { + let Spellings = [Clang<"sycl_external">]; tahonermann wrote: We use the `Clang` spelling for `sycl_kernel_entry_point`, what would be the reason for doi

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-23 Thread Tom Honermann via cfe-commits
@@ -476,6 +476,47 @@ The SYCL kernel in the previous code sample meets these expectations. }]; } +def SYCLExternalDocs : Documentation { + let Category = DocCatFunction; + let Heading = "sycl_external"; + let Content = [{ +The ``sycl_external`` attribute indicates that a

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-22 Thread Tom Honermann via cfe-commits
@@ -12952,8 +12956,11 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) { if (LangOpts.SYCLIsDevice && FD->hasAttr()) return true; -// FIXME: Functions declared with SYCL_EXTERNAL are required during -// device compilation. +// Function definitions wit

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-18 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann approved this pull request. I love it @schittir, this looks great! @erichkeane, @bader, please review and lend your approval. Note that some of the changes to the tests are to synchronize them with continued evolution that happened in DPC++ but was not previously

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-15 Thread Tom Honermann via cfe-commits
@@ -476,6 +476,48 @@ The SYCL kernel in the previous code sample meets these expectations. }]; } +def SYCLExternalDocs : Documentation { + let Category = DocCatFunction; + let Heading = "sycl_external"; + let Content = [{ +The ``sycl_external`` attribute indicates that a

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-14 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify %s + +// expected-error@+1{{'clang::sycl_external' attribute only applies to functions}} +[[clang::sycl_external]] int a; + + +// expected-error@+2{{'clang::sycl_external' attribute only applies to funct

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-11 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,70 @@ +// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsycl-is-device -std=c++20 -fsyntax-only -verify -DCPP20 %s +// Semantic tests for sycl_external attribute + +[[clang::sycl_external]] // expected-error {{'sycl_external' can only b

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-11 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify %s + +// expected-error@+1{{'clang::sycl_external' attribute only applies to functions}} +[[clang::sycl_external]] int a; + + +// expected-error@+2{{'clang::sycl_external' attribute only applies to funct

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-11 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,70 @@ +// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsycl-is-device -std=c++20 -fsyntax-only -verify -DCPP20 %s +// Semantic tests for sycl_external attribute tahonermann wrote: Add spacing to avoid potential merge

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-11 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// expected-warning@+1{{'clang::sycl_external' attribute ignored}} tahonermann wrote: ```suggestion // These tests validate that the sycl_external attribute is ignored when SYCL // support is not en

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-11 Thread Tom Honermann via cfe-commits
@@ -12879,6 +12879,15 @@ def err_sycl_special_type_num_init_method : Error< "types with 'sycl_special_class' attribute must have one and only one '__init' " "method defined">; +// SYCL external attribute diagnostics +def err_sycl_attribute_invalid_linkage : Error< + "'sy

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-11 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// expected-warning@+1{{'clang::sycl_external' attribute ignored}} +[[clang::sycl_external]] void bar() {} + +// expected-warning@+1{{'clang::sycl_external' attribute ignored}} +[[clang::sycl_external]] int a; + +//

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-11 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann edited https://github.com/llvm/llvm-project/pull/140282 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-11 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann requested changes to this pull request. A few more comments. I still haven't finished my review of `sycl-external-attr.cpp`, but will try to later today or over the weekend. https://github.com/llvm/llvm-project/pull/140282 _

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-11 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann requested changes to this pull request. This is looking good @schittir! I added some comments for minor issues. I still need to review the tests more closely. https://github.com/llvm/llvm-project/pull/140282 ___ cfe-comm

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-11 Thread Tom Honermann via cfe-commits
@@ -1641,6 +1641,13 @@ def DeviceKernel : DeclOrTypeAttr { }]; } +def SYCLExternal : InheritableAttr { + let Spellings = [Clang<"sycl_external">]; + let Subjects = SubjectList<[Function], ErrorDiag>; + let LangOpts = [SYCLDevice]; tahonermann wrote: In res

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-11 Thread Tom Honermann via cfe-commits
@@ -4084,6 +4084,19 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, Scope *S, diag::note_carries_dependency_missing_first_decl) << 0/*Function*/; } +// SYCL spec 2020 +// The first declaration of a function with external linkage m

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-11 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann edited https://github.com/llvm/llvm-project/pull/140282 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-11 Thread Tom Honermann via cfe-commits
@@ -4084,6 +4084,19 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, Scope *S, diag::note_carries_dependency_missing_first_decl) << 0/*Function*/; } +// SYCL spec 2020 +// The first declaration of a function with external linkage m

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-11 Thread Tom Honermann via cfe-commits
@@ -4084,6 +4084,19 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, Scope *S, diag::note_carries_dependency_missing_first_decl) << 0/*Function*/; } +// SYCL spec 2020 +// The first declaration of a function with external linkage m

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-11 Thread Tom Honermann via cfe-commits
@@ -100,11 +100,9 @@ int main() { // Verify that SYCL kernel caller functions are emitted for each device target. // -// FIXME: The following set of matches are used to skip over the declaration of -// main(). main() shouldn't be emitted in device code, but that pruning isn't

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-07-11 Thread Tom Honermann via cfe-commits
@@ -12879,6 +12879,16 @@ def err_sycl_special_type_num_init_method : Error< "types with 'sycl_special_class' attribute must have one and only one '__init' " "method defined">; +// SYCL external attribute diagnostics +def err_sycl_attribute_invalid_linkage : Error< + "'sy

[clang] [NFC][clang] Fix CodeGenSYCL::unique_stable_name_windows_diff test (PR #146854)

2025-07-03 Thread Tom Honermann via cfe-commits
@@ -1,19 +1,19 @@ // RUN: %clang_cc1 -triple spir64-unknown-unknown-sycldevice -aux-triple x86_64-pc-windows-msvc -fsycl-is-device -disable-llvm-passes -fsycl-is-device -emit-llvm %s -o - | FileCheck %s '-D$ADDRSPACE=addrspace(1) ' -// RUN: %clang_cc1 -triple x86_64-pc-windows-

[clang] [NFC][clang] Fix CodeGenSYCL::unique_stable_name_windows_diff test (PR #146854)

2025-07-03 Thread Tom Honermann via cfe-commits
@@ -1,19 +1,19 @@ // RUN: %clang_cc1 -triple spir64-unknown-unknown-sycldevice -aux-triple x86_64-pc-windows-msvc -fsycl-is-device -disable-llvm-passes -fsycl-is-device -emit-llvm %s -o - | FileCheck %s '-D$ADDRSPACE=addrspace(1) ' tahonermann wrote: The redun

[clang] [NFC][clang] Fix CodeGenSYCL::unique_stable_name_windows_diff test (PR #146854)

2025-07-03 Thread Tom Honermann via cfe-commits
@@ -1,19 +1,19 @@ // RUN: %clang_cc1 -triple spir64-unknown-unknown-sycldevice -aux-triple x86_64-pc-windows-msvc -fsycl-is-device -disable-llvm-passes -fsycl-is-device -emit-llvm %s -o - | FileCheck %s '-D$ADDRSPACE=addrspace(1) ' -// RUN: %clang_cc1 -triple x86_64-pc-windows-

[clang] [NFC][clang] Fix CodeGenSYCL::unique_stable_name_windows_diff test (PR #146854)

2025-07-03 Thread Tom Honermann via cfe-commits
@@ -1,19 +1,19 @@ // RUN: %clang_cc1 -triple spir64-unknown-unknown-sycldevice -aux-triple x86_64-pc-windows-msvc -fsycl-is-device -disable-llvm-passes -fsycl-is-device -emit-llvm %s -o - | FileCheck %s '-D$ADDRSPACE=addrspace(1) ' -// RUN: %clang_cc1 -triple x86_64-pc-windows-

[clang] [NFC][clang] Fix CodeGenSYCL::unique_stable_name_windows_diff test (PR #146854)

2025-07-03 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann requested changes to this pull request. https://github.com/llvm/llvm-project/pull/146854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [win][clang] Align scalar deleting destructors with MSABI (PR #139566)

2025-06-25 Thread Tom Honermann via cfe-commits
@@ -1590,25 +1590,70 @@ namespace { void EmitConditionalDtorDeleteCall(CodeGenFunction &CGF, tahonermann wrote: Thanks, the new comment looks great. https://github.com/llvm/llvm-project/pull/139566 ___ cfe-commits m

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-24 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,54 @@ +// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify %s + +// Semantic tests for sycl_external attribute + +[[clang::sycl_external]] // expected-error {{'sycl_external' can only be applied to functions with external linkage}} +static void func1() {} + +name

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-24 Thread Tom Honermann via cfe-commits
@@ -208,6 +208,15 @@ void SemaSYCL::handleExternalAttr(Decl *D, const ParsedAttr &AL) { Diag(AL.getLoc(), diag::err_sycl_attribute_invalid_linkage); return; } + std::string FunctionName = StringRef(FD->getNameInfo().getAsString()).lower(); + if (FunctionName.find(

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-24 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,54 @@ +// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify %s + +// Semantic tests for sycl_external attribute + +[[clang::sycl_external]] // expected-error {{'sycl_external' can only be applied to functions with external linkage}} +static void func1() {} + +name

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-24 Thread Tom Honermann via cfe-commits
@@ -12856,6 +12856,14 @@ def err_sycl_special_type_num_init_method : Error< "types with 'sycl_special_class' attribute must have one and only one '__init' " "method defined">; +// SYCL external attribute diagnostics +def err_sycl_attribute_invalid_linkage : Error< + "'sy

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-24 Thread Tom Honermann via cfe-commits
@@ -202,6 +202,25 @@ void SemaSYCL::handleKernelAttr(Decl *D, const ParsedAttr &AL) { handleSimpleAttribute(*this, D, AL); } +void SemaSYCL::handleExternalAttr(Decl *D, const ParsedAttr &AL) { + auto *FD = cast(D); + if (!FD->isExternallyVisible()) { +Diag(AL.getLoc()

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-24 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann requested changes to this pull request. Additional comments for diagnostics and tests. https://github.com/llvm/llvm-project/pull/140282 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bi

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-24 Thread Tom Honermann via cfe-commits
@@ -7206,6 +7206,9 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL, case ParsedAttr::AT_EnumExtensibility: handleEnumExtensibilityAttr(S, D, AL); break; + case ParsedAttr::AT_SYCLExternal: +S.SYCL().handleExternalAttr(D, AL); ---

[clang] [win][clang] Align scalar deleting destructors with MSABI (PR #139566)

2025-06-24 Thread Tom Honermann via cfe-commits
@@ -2886,6 +2887,16 @@ class CXXDestructorDecl : public CXXMethodDecl { return getCanonicalDecl()->OperatorDelete; } + const FunctionDecl *getOperatorGlobalDelete() const { +return getCanonicalDecl()->OperatorGlobalDelete; + } + + void setOperatorGlobalDelete(Func

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-24 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,54 @@ +// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify %s + +// Semantic tests for sycl_external attribute + +[[clang::sycl_external]] // expected-error {{'sycl_external' can only be applied to functions with external linkage}} +static void func1() {} + +name

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-24 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,54 @@ +// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify %s + +// Semantic tests for sycl_external attribute + +[[clang::sycl_external]] // expected-error {{'sycl_external' can only be applied to functions with external linkage}} +static void func1() {} + +name

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-24 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,54 @@ +// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify %s + +// Semantic tests for sycl_external attribute + +[[clang::sycl_external]] // expected-error {{'sycl_external' can only be applied to functions with external linkage}} +static void func1() {} + +name

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-24 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann edited https://github.com/llvm/llvm-project/pull/140282 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-24 Thread Tom Honermann via cfe-commits
@@ -202,6 +202,25 @@ void SemaSYCL::handleKernelAttr(Decl *D, const ParsedAttr &AL) { handleSimpleAttribute(*this, D, AL); } +void SemaSYCL::handleExternalAttr(Decl *D, const ParsedAttr &AL) { + auto *FD = cast(D); + if (!FD->isExternallyVisible()) { +Diag(AL.getLoc()

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-24 Thread Tom Honermann via cfe-commits
@@ -12856,6 +12856,14 @@ def err_sycl_special_type_num_init_method : Error< "types with 'sycl_special_class' attribute must have one and only one '__init' " "method defined">; +// SYCL external attribute diagnostics +def err_sycl_attribute_invalid_linkage : Error< + "'sy

[clang] [win][clang] Align scalar deleting destructors with MSABI (PR #139566)

2025-06-24 Thread Tom Honermann via cfe-commits
@@ -2886,6 +2887,16 @@ class CXXDestructorDecl : public CXXMethodDecl { return getCanonicalDecl()->OperatorDelete; } + const FunctionDecl *getOperatorGlobalDelete() const { +return getCanonicalDecl()->OperatorGlobalDelete; + } + + void setOperatorGlobalDelete(Func

[clang] [win][clang] Align scalar deleting destructors with MSABI (PR #139566)

2025-06-23 Thread Tom Honermann via cfe-commits
@@ -2886,6 +2887,16 @@ class CXXDestructorDecl : public CXXMethodDecl { return getCanonicalDecl()->OperatorDelete; } + const FunctionDecl *getOperatorGlobalDelete() const { +return getCanonicalDecl()->OperatorGlobalDelete; + } + + void setOperatorGlobalDelete(Func

[clang] [win][clang] Align scalar deleting destructors with MSABI (PR #139566)

2025-06-23 Thread Tom Honermann via cfe-commits
@@ -46,6 +46,16 @@ Potentially Breaking Changes ``endbr64`` instruction at the labels named as possible branch destinations, so it is not safe to use a register-controlled branch instruction to branch to one. (In line with gcc.) +- Scalar deleting destructors emitted by c

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-19 Thread Tom Honermann via cfe-commits
@@ -476,6 +476,41 @@ The SYCL kernel in the previous code sample meets these expectations. }]; } +def SYCLExternalDocs : Documentation { + let Category = DocCatFunction; + let Heading = "sycl_external"; + let Content = [{ +The ``sycl_external`` attribute indicates that a

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-19 Thread Tom Honermann via cfe-commits
@@ -476,6 +476,41 @@ The SYCL kernel in the previous code sample meets these expectations. }]; } +def SYCLExternalDocs : Documentation { + let Category = DocCatFunction; + let Heading = "sycl_external"; + let Content = [{ +The ``sycl_external`` attribute indicates that a

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-19 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann edited https://github.com/llvm/llvm-project/pull/140282 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-19 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann requested changes to this pull request. Thanks for addressing most of my earlier comments. I took another quick look today and added a couple more comments. https://github.com/llvm/llvm-project/pull/140282 ___ cfe-commit

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-19 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// expected-warning@+1{{'sycl_external' attribute ignored}} +[[clang::sycl_external]] void bar() {} + +// expected-warning@+1{{'sycl_external' attribute ignored}} +[[clang::sycl_external]] int a; tah

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-16 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify %s + +// expected-warning@+1{{'sycl_external' attribute only applies to functions}} +[[clang::sycl_external]] int a; + + +// expected-warning@+2{{'sycl_external' attribute only applies to functions}} +stru

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-16 Thread Tom Honermann via cfe-commits
https://github.com/tahonermann requested changes to this pull request. Thanks @schittir, here are my initial review comments. I expect to review the newly added tests more closely once these comments are all addressed. https://github.com/llvm/llvm-project/pull/140282 ___

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-16 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// expected-warning@+1{{'sycl_external' attribute ignored}} +[[clang::sycl_external]] void bar() {} + +// expected-warning@+1{{'sycl_external' attribute ignored}} +[[clang::sycl_external]] int a; tah

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-16 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify %s + +// expected-warning@+1{{'sycl_external' attribute only applies to functions}} +[[clang::sycl_external]] int a; + + +// expected-warning@+2{{'sycl_external' attribute only applies to functions}} +stru

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-16 Thread Tom Honermann via cfe-commits
@@ -476,6 +476,31 @@ The SYCL kernel in the previous code sample meets these expectations. }]; } +def SYCLExternalDocs : Documentation { + let Category = DocCatFunction; + let Heading = "sycl_external"; + let Content = [{ +The ``sycl_external`` attribute can only be appl

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-16 Thread Tom Honermann via cfe-commits
@@ -202,6 +202,17 @@ void SemaSYCL::handleKernelAttr(Decl *D, const ParsedAttr &AL) { handleSimpleAttribute(*this, D, AL); } +void SemaSYCL::handleExternalAttr(Decl *D, const ParsedAttr &AL) { + auto *ND = cast(D); + if (!ND->isExternallyVisible()) { taho

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-16 Thread Tom Honermann via cfe-commits
@@ -1,128 +1,128 @@ // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fsycl-is-device -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s void bar(int &Data) {} -// CHECK: define dso_local void @[[RAW_REF:[a-zA-Z0-9_]+]](ptr noundef nonnull align 4 dereferenceable(4) % +// CHEC

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-16 Thread Tom Honermann via cfe-commits
@@ -202,6 +202,17 @@ void SemaSYCL::handleKernelAttr(Decl *D, const ParsedAttr &AL) { handleSimpleAttribute(*this, D, AL); } +void SemaSYCL::handleExternalAttr(Decl *D, const ParsedAttr &AL) { + auto *ND = cast(D); + if (!ND->isExternallyVisible()) { +Diag(AL.getLoc()

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-16 Thread Tom Honermann via cfe-commits
@@ -0,0 +1,38 @@ +// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify %s + +// Semantic tests for sycl_external attribute + +[[clang::sycl_external(3)]] // expected-error {{'sycl_external' attribute takes no arguments}} +void bar() {} + +[[clang::sycl_external]] // expected

[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

2025-06-16 Thread Tom Honermann via cfe-commits
@@ -12851,6 +12851,10 @@ def err_sycl_special_type_num_init_method : Error< "types with 'sycl_special_class' attribute must have one and only one '__init' " "method defined">; +//SYCL external attribute diagnostics tahonermann wrote: ```suggestion // SYC

  1   2   3   4   5   6   >