llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-backend-spir-v Author: Ian Li (ianayl) <details> <summary>Changes</summary> This PR adds a new diagnostic error when Sema(SYCL) encounters sycl_external attributes but -fgpu-rdc is not enabled; sycl_external functions in one TU can't be resolved in another TU without -fgpu-rdc. This diagnostic can be enabled/disabled via `-Wsycl-external-ignored`. Worth noting that: - I'm only issuing diagnostics during -fsycl-is-device; This seems like a device code issue anyway, and diagnosing twice on `-Wno-error=sycl-external-ignored` doesn't seem to make sense. - I've opted to leave the sycl_external attributes intact despite knowing that there will be ramifications since I assume the default behavior of my diagnostic is an error. Let me know if I should actually do something with the sycl_external attribute. Assisted-by: Tests were generated using Claude (along with adding -fgpu-rdc to all the existing tests that now need it) --- Patch is 22.01 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/232934.diff 28 Files Affected: - (modified) clang/include/clang/Basic/DiagnosticGroups.td (+1) - (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+4) - (modified) clang/include/clang/Sema/SemaSYCL.h (+1) - (modified) clang/lib/Sema/SemaDeclAttr.cpp (+1-1) - (modified) clang/lib/Sema/SemaSYCL.cpp (+7) - (modified) clang/test/CodeGenSPIRV/Builtins/generic_cast_to_ptr_explicit.c (+1-1) - (modified) clang/test/CodeGenSPIRV/Builtins/group.c (+1-1) - (modified) clang/test/CodeGenSPIRV/Builtins/ids_and_ranges.c (+1-1) - (modified) clang/test/CodeGenSPIRV/Builtins/subgroup.c (+1-1) - (modified) clang/test/CodeGenSPIRV/spirv-host-adaptation-valist.cpp (+2-2) - (modified) clang/test/CodeGenSYCL/address-space-conversions.cpp (+1-1) - (modified) clang/test/CodeGenSYCL/address-space-deduction.cpp (+1-1) - (modified) clang/test/CodeGenSYCL/address-space-mangling.cpp (+1-1) - (modified) clang/test/CodeGenSYCL/amd-address-space-conversions.cpp (+1-1) - (modified) clang/test/CodeGenSYCL/cuda-address-space-conversions.cpp (+1-1) - (modified) clang/test/CodeGenSYCL/debug-info-kernel-variables.cpp (+1-1) - (modified) clang/test/CodeGenSYCL/field-annotate-addr-space.cpp (+1-1) - (modified) clang/test/CodeGenSYCL/functionptr-addrspace.cpp (+1-1) - (modified) clang/test/CodeGenSYCL/sycl-external-attr.cpp (+1-1) - (modified) clang/test/CodeGenSYCL/sycl-module-id.cpp (+1-1) - (modified) clang/test/Headers/gpuintrin_lang.c (+1-1) - (modified) clang/test/Headers/spirv_functions.cpp (+2-2) - (modified) clang/test/Headers/spirv_ids.cpp (+3-3) - (modified) clang/test/SemaSYCL/sycl-cconv.cpp (+1-1) - (modified) clang/test/SemaSYCL/sycl-external-attr-grammar.cpp (+1-1) - (added) clang/test/SemaSYCL/sycl-external-attr-no-gpu-rdc.cpp (+27) - (modified) clang/test/SemaSYCL/sycl-external-attr.cpp (+2-2) - (modified) clang/test/SemaSYCL/sycl-kernel-entry-point-attr-device-odr-use.cpp (+1-1) ``````````diff diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 1da7698944b24..ebc30985e94a2 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -870,6 +870,7 @@ def NonPODVarargs : DiagGroup<"non-pod-varargs">; def ClassVarargs : DiagGroup<"class-varargs", [NonPODVarargs]>; def : DiagGroup<"nonportable-cfstrings">; def NonPortableSYCL : DiagGroup<"nonportable-sycl">; +def SYCLExternalIgnored : DiagGroup<"sycl-external-ignored">; def NonVirtualDtor : DiagGroup<"non-virtual-dtor">; def GNUNullPointerArithmetic : DiagGroup<"gnu-null-pointer-arithmetic">; def NullPointerArithmetic diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index fd54b76932164..96596a3b1baa1 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -13557,6 +13557,10 @@ def err_sycl_external_invalid_deleted_function : Error< def warn_sycl_external_missing_on_first_decl : Warning< "%0 attribute does not appear on the first declaration">, InGroup<NonPortableSYCL>; +def warn_sycl_external_ignored : Warning< + "%0 attribute is ignored %enum_select<IgnoredSyclExternalReason>{" + "%NoGpuRDC{when GPU relocatable device code (-fgpu-rdc) is disabled}}1">, + InGroup<SYCLExternalIgnored>, DefaultError; // SYCL kernel entry point diagnostics def err_sycl_entry_point_invalid : Error< diff --git a/clang/include/clang/Sema/SemaSYCL.h b/clang/include/clang/Sema/SemaSYCL.h index 4980aa44c3012..63fab0428dc54 100644 --- a/clang/include/clang/Sema/SemaSYCL.h +++ b/clang/include/clang/Sema/SemaSYCL.h @@ -63,6 +63,7 @@ class SemaSYCL : public SemaBase { void handleKernelAttr(Decl *D, const ParsedAttr &AL); void handleKernelEntryPointAttr(Decl *D, const ParsedAttr &AL); + void handleExternalAttr(Decl *D, const ParsedAttr &AL); /// Issues a deferred diagnostic if use of the declaration designated /// by 'ND' is invalid in a device context. diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index eb4a8c2ab9ae0..38e7b029fbffa 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -7848,7 +7848,7 @@ ProcessDeclAttribute(Sema &S, Decl *D, const ParsedAttr &AL, S.SYCL().handleKernelAttr(D, AL); break; case ParsedAttr::AT_SYCLExternal: - handleSimpleAttribute<SYCLExternalAttr>(S, D, AL); + S.SYCL().handleExternalAttr(D, AL); break; case ParsedAttr::AT_SYCLKernelEntryPoint: S.SYCL().handleKernelEntryPointAttr(D, AL); diff --git a/clang/lib/Sema/SemaSYCL.cpp b/clang/lib/Sema/SemaSYCL.cpp index e180b3655bd73..b07af23ce9348 100644 --- a/clang/lib/Sema/SemaSYCL.cpp +++ b/clang/lib/Sema/SemaSYCL.cpp @@ -222,6 +222,13 @@ void SemaSYCL::handleKernelEntryPointAttr(Decl *D, const ParsedAttr &AL) { SYCLKernelEntryPointAttr(SemaRef.Context, AL, TSI)); } +void SemaSYCL::handleExternalAttr(Decl *D, const ParsedAttr &AL) { + if (getLangOpts().SYCLIsDevice && !getLangOpts().GPURelocatableDeviceCode) + Diag(AL.getLoc(), diag::warn_sycl_external_ignored) + << AL << diag::IgnoredSyclExternalReason::NoGpuRDC; + handleSimpleAttribute<SYCLExternalAttr>(*this, D, AL); +} + void SemaSYCL::CheckDeviceUseOfDecl(NamedDecl *ND, SourceLocation Loc) { assert(getLangOpts().SYCLIsDevice && "Should only be called during SYCL device compilation"); diff --git a/clang/test/CodeGenSPIRV/Builtins/generic_cast_to_ptr_explicit.c b/clang/test/CodeGenSPIRV/Builtins/generic_cast_to_ptr_explicit.c index 5f138410931cf..d66390ea9441c 100644 --- a/clang/test/CodeGenSPIRV/Builtins/generic_cast_to_ptr_explicit.c +++ b/clang/test/CodeGenSPIRV/Builtins/generic_cast_to_ptr_explicit.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -O1 -triple spirv64 -fsycl-is-device -x c++ %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -O1 -triple spirv64 -fsycl-is-device -fgpu-rdc -x c++ %s -emit-llvm -o - | FileCheck %s // RUN: %clang_cc1 -O1 -triple spirv64 -cl-std=CL3.0 -x cl %s -emit-llvm -o - | FileCheck %s // RUN: %clang_cc1 -O1 -triple spirv32 -cl-std=CL3.0 -x cl %s -emit-llvm -o - | FileCheck %s diff --git a/clang/test/CodeGenSPIRV/Builtins/group.c b/clang/test/CodeGenSPIRV/Builtins/group.c index 7275edf66e438..e6ab1dc5c9bf0 100644 --- a/clang/test/CodeGenSPIRV/Builtins/group.c +++ b/clang/test/CodeGenSPIRV/Builtins/group.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -O1 -triple spirv64 -fsycl-is-device -x c++ %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK +// RUN: %clang_cc1 -O1 -triple spirv64 -fsycl-is-device -fgpu-rdc -x c++ %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK // RUN: %clang_cc1 -O1 -triple spirv64 -cl-std=CL3.0 -x cl %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK // RUN: %clang_cc1 -O1 -triple spirv32 -cl-std=CL3.0 -x cl %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK diff --git a/clang/test/CodeGenSPIRV/Builtins/ids_and_ranges.c b/clang/test/CodeGenSPIRV/Builtins/ids_and_ranges.c index bff850b3622b9..1843221458d2e 100644 --- a/clang/test/CodeGenSPIRV/Builtins/ids_and_ranges.c +++ b/clang/test/CodeGenSPIRV/Builtins/ids_and_ranges.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -O1 -triple spirv64 -fsycl-is-device -x c++ %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK64 +// RUN: %clang_cc1 -O1 -triple spirv64 -fsycl-is-device -fgpu-rdc -x c++ %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK64 // RUN: %clang_cc1 -O1 -triple spirv64 -cl-std=CL3.0 -x cl %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK64 // RUN: %clang_cc1 -O1 -triple spirv32 -cl-std=CL3.0 -x cl %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK32 diff --git a/clang/test/CodeGenSPIRV/Builtins/subgroup.c b/clang/test/CodeGenSPIRV/Builtins/subgroup.c index ba6b48e3f3848..908c82866a0c6 100644 --- a/clang/test/CodeGenSPIRV/Builtins/subgroup.c +++ b/clang/test/CodeGenSPIRV/Builtins/subgroup.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -O1 -triple spirv64 -fsycl-is-device -x c++ %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK +// RUN: %clang_cc1 -O1 -triple spirv64 -fsycl-is-device -fgpu-rdc -x c++ %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK // RUN: %clang_cc1 -O1 -triple spirv64 -cl-std=CL3.0 -x cl %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK // RUN: %clang_cc1 -O1 -triple spirv32 -cl-std=CL3.0 -x cl %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK diff --git a/clang/test/CodeGenSPIRV/spirv-host-adaptation-valist.cpp b/clang/test/CodeGenSPIRV/spirv-host-adaptation-valist.cpp index d926e30376b18..7bb20c3ec5461 100644 --- a/clang/test/CodeGenSPIRV/spirv-host-adaptation-valist.cpp +++ b/clang/test/CodeGenSPIRV/spirv-host-adaptation-valist.cpp @@ -1,9 +1,9 @@ /// Tests that va_list layout matches the host target's getBuiltinVaListKind(). // RUN: %clang_cc1 -triple spirv64-unknown-unknown -aux-triple x86_64-unknown-linux-gnu \ -// RUN: -fsycl-is-device -emit-llvm -o - %s | FileCheck --check-prefix=LINUX %s +// RUN: -fsycl-is-device -fgpu-rdc -emit-llvm -o - %s | FileCheck --check-prefix=LINUX %s // RUN: %clang_cc1 -triple spirv64-unknown-unknown -aux-triple x86_64-pc-windows-msvc \ -// RUN: -fsycl-is-device -emit-llvm -o - %s | FileCheck --check-prefix=WINDOWS %s +// RUN: -fsycl-is-device -fgpu-rdc -emit-llvm -o - %s | FileCheck --check-prefix=WINDOWS %s [[clang::sycl_external]] int f(int n, ...) { __builtin_va_list ap1, ap2; diff --git a/clang/test/CodeGenSYCL/address-space-conversions.cpp b/clang/test/CodeGenSYCL/address-space-conversions.cpp index 38fde3096b8c0..34d86c0477088 100644 --- a/clang/test/CodeGenSYCL/address-space-conversions.cpp +++ b/clang/test/CodeGenSYCL/address-space-conversions.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple spir64 -fsycl-is-device -disable-llvm-passes -emit-llvm %s -o - -Wno-deprecated-attributes | FileCheck %s +// RUN: %clang_cc1 -triple spir64 -fsycl-is-device -fgpu-rdc -disable-llvm-passes -emit-llvm %s -o - -Wno-deprecated-attributes | FileCheck %s void bar(int &Data) {} // CHECK-DAG: define{{.*}} void @[[RAW_REF:[a-zA-Z0-9_]+]](ptr addrspace(4) noundef align 4 dereferenceable(4) % void bar2(int &Data) {} diff --git a/clang/test/CodeGenSYCL/address-space-deduction.cpp b/clang/test/CodeGenSYCL/address-space-deduction.cpp index 0fb5c41d630cc..f3757e08cac9c 100644 --- a/clang/test/CodeGenSYCL/address-space-deduction.cpp +++ b/clang/test/CodeGenSYCL/address-space-deduction.cpp @@ -1,5 +1,5 @@ // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py -// RUN: %clang_cc1 -triple spir64 -fsycl-is-device -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple spir64 -fsycl-is-device -fgpu-rdc -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s // CHECK-LABEL: @_Z4testv( // CHECK-NEXT: entry: diff --git a/clang/test/CodeGenSYCL/address-space-mangling.cpp b/clang/test/CodeGenSYCL/address-space-mangling.cpp index 23eeb2e10ae8e..5eb60b94b9e48 100644 --- a/clang/test/CodeGenSYCL/address-space-mangling.cpp +++ b/clang/test/CodeGenSYCL/address-space-mangling.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple spir64 -fsycl-is-device -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s --check-prefix=SPIR +// RUN: %clang_cc1 -triple spir64 -fsycl-is-device -fgpu-rdc -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s --check-prefix=SPIR // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsycl-is-host -emit-llvm %s -o - | FileCheck %s --check-prefix=ITANIUM // RUN: %clang_cc1 -triple x86_64-windows-msvc -fsycl-is-host -emit-llvm %s -o - | FileCheck %s --check-prefix=MS diff --git a/clang/test/CodeGenSYCL/amd-address-space-conversions.cpp b/clang/test/CodeGenSYCL/amd-address-space-conversions.cpp index c14df426df656..aa52afe9a5708 100644 --- a/clang/test/CodeGenSYCL/amd-address-space-conversions.cpp +++ b/clang/test/CodeGenSYCL/amd-address-space-conversions.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple amdgpu-amd-amdhsa -fsycl-is-device -disable-llvm-passes -emit-llvm %s -o - -Wno-deprecated-attributes | FileCheck %s +// RUN: %clang_cc1 -triple amdgpu-amd-amdhsa -fsycl-is-device -fgpu-rdc -disable-llvm-passes -emit-llvm %s -o - -Wno-deprecated-attributes | FileCheck %s void bar(int &Data) {} // CHECK-DAG: define {{.*}} void @[[RAW_REF:[a-zA-Z0-9_]+]](ptr noundef nonnull align 4 dereferenceable(4) % void bar2(int &Data) {} diff --git a/clang/test/CodeGenSYCL/cuda-address-space-conversions.cpp b/clang/test/CodeGenSYCL/cuda-address-space-conversions.cpp index 94ba76f9489cc..9f0cc274a97fa 100644 --- a/clang/test/CodeGenSYCL/cuda-address-space-conversions.cpp +++ b/clang/test/CodeGenSYCL/cuda-address-space-conversions.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fsycl-is-device -disable-llvm-passes -emit-llvm %s -o - -Wno-deprecated-attributes | FileCheck %s +// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fsycl-is-device -fgpu-rdc -disable-llvm-passes -emit-llvm %s -o - -Wno-deprecated-attributes | FileCheck %s void bar(int &Data) {} // CHECK-DAG: define {{.*}} void @[[RAW_REF:[a-zA-Z0-9_]+]](ptr noundef nonnull align 4 dereferenceable(4) % void bar2(int &Data) {} diff --git a/clang/test/CodeGenSYCL/debug-info-kernel-variables.cpp b/clang/test/CodeGenSYCL/debug-info-kernel-variables.cpp index 551c4e7e2b8b4..b6bb390d04ee6 100644 --- a/clang/test/CodeGenSYCL/debug-info-kernel-variables.cpp +++ b/clang/test/CodeGenSYCL/debug-info-kernel-variables.cpp @@ -1,7 +1,7 @@ // RUN: %clang_cc1 %s -o - -O0 -emit-llvm \ // RUN: -triple spir64-unknown-unknown \ // RUN: -aux-triple x86_64-unknown-linux-gnu \ -// RUN: -fsycl-is-device \ +// RUN: -fsycl-is-device -fgpu-rdc \ // RUN: -finclude-default-header \ // RUN: -debug-info-kind=limited -gno-column-info \ // RUN: | FileCheck %s diff --git a/clang/test/CodeGenSYCL/field-annotate-addr-space.cpp b/clang/test/CodeGenSYCL/field-annotate-addr-space.cpp index fe7a160900a54..263118d9505a9 100644 --- a/clang/test/CodeGenSYCL/field-annotate-addr-space.cpp +++ b/clang/test/CodeGenSYCL/field-annotate-addr-space.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple spir64 -fsycl-is-device -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple spir64 -fsycl-is-device -fgpu-rdc -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s // CHECK: [[ANNOT:.+]] = private unnamed_addr addrspace(1) constant {{.*}}c"my_annotation\00" diff --git a/clang/test/CodeGenSYCL/functionptr-addrspace.cpp b/clang/test/CodeGenSYCL/functionptr-addrspace.cpp index 060104a29b60a..70f3b3864212d 100644 --- a/clang/test/CodeGenSYCL/functionptr-addrspace.cpp +++ b/clang/test/CodeGenSYCL/functionptr-addrspace.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsycl-is-device -triple spir64 -verify -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -fsycl-is-device -fgpu-rdc -triple spir64 -verify -emit-llvm %s -o - | FileCheck %s // expected-no-diagnostics diff --git a/clang/test/CodeGenSYCL/sycl-external-attr.cpp b/clang/test/CodeGenSYCL/sycl-external-attr.cpp index 2c22e65874713..e93c45959e2d7 100644 --- a/clang/test/CodeGenSYCL/sycl-external-attr.cpp +++ b/clang/test/CodeGenSYCL/sycl-external-attr.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -fsycl-is-device -fgpu-rdc -triple spir64-unknown-unknown -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s // This test code generation when sycl_external attribute is used diff --git a/clang/test/CodeGenSYCL/sycl-module-id.cpp b/clang/test/CodeGenSYCL/sycl-module-id.cpp index d9beded116a65..6d86db7662d23 100644 --- a/clang/test/CodeGenSYCL/sycl-module-id.cpp +++ b/clang/test/CodeGenSYCL/sycl-module-id.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown \ +// RUN: %clang_cc1 -fsycl-is-device -fgpu-rdc -triple spir64-unknown-unknown \ // RUN: -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s // Verify that the "sycl-module-id" function attribute is emitted for: diff --git a/clang/test/Headers/gpuintrin_lang.c b/clang/test/Headers/gpuintrin_lang.c index 0dc9c22a8629e..66d5596cb9303 100644 --- a/clang/test/Headers/gpuintrin_lang.c +++ b/clang/test/Headers/gpuintrin_lang.c @@ -23,7 +23,7 @@ // RUN: | FileCheck %s --check-prefix=OPENMP // // RUN: %clang_cc1 -internal-isystem %S/Inputs/include -DSYCL \ -// RUN: -internal-isystem %S/../../lib/Headers/ -fsycl-is-device \ +// RUN: -internal-isystem %S/../../lib/Headers/ -fsycl-is-device -fgpu-rdc \ // RUN: -x c++ -triple spirv64 -emit-llvm %s -o - \ // RUN: | FileCheck %s --check-prefix=SYCL // diff --git a/clang/test/Headers/spirv_functions.cpp b/clang/test/Headers/spirv_functions.cpp index fa9e2cea51079..7273ae2a3690b 100644 --- a/clang/test/Headers/spirv_functions.cpp +++ b/clang/test/Headers/spirv_functions.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -Wno-unused-value -O0 -internal-isystem %S/../../lib/Headers -include __clang_spirv_builtins.h -triple spirv64 -emit-llvm %s -fsycl-is-device -o - | FileCheck %s -check-prefixes=SPV -// RUN: %clang_cc1 -Wno-unused-value -O0 -internal-isystem %S/../../lib/Headers -include __clang_spirv_builtins.h -triple nvptx64 -emit-llvm %s -fsycl-is-device -o - | FileCheck %s -check-prefixes=NV +// RUN: %clang_cc1 -Wno-unused-value -O0 -internal-isystem %S/../../lib/Headers -include __clang_spirv_builtins.h -triple spirv64 -emit-llvm %s -fsycl-is-device -fgpu-rdc -o - | FileCheck %s -check-prefixes=SPV +// RUN: %clang_cc1 -Wno-unused-value -O0 -internal-isystem %S/../../lib/Headers -include __clang_spirv_builtins.h -triple nvptx64 -emit-llvm %s -fsycl-is-device -fgpu-rdc -o - | FileCheck %s -check-prefixes=NV // SPV: void @_Z9test_castPi diff --git a/clang/test/Headers/spirv_ids.cpp b/clang/test/Headers/spirv_ids.cpp index a1c953eff7771..5e7570c20af3b 100644 --- a/clang/test/Headers/spirv_ids.cpp +++ b/clang/test/Headers/spirv_ids.cpp @@ -1,8 +1,8 @@ -// RUN: %clang_cc1 -Wno-unused-value -O0 -internal-isystem %S/../../lib/Headers -include __clang_spirv_builtins.h -triple spirv64 -emit-llvm %s -fsycl-is-device -o - | FileCheck %s -check-prefixes=CHECK64 +// RUN: %clang_cc1 -Wno-unused-value -O0 -internal-isystem %S/../../lib/Headers -include __clang_spirv_builtins.h -triple spirv64 -emit-llvm %s -fsycl-is-device -fgpu-rdc -o - | FileCheck %s -check-prefixes=CHECK64 // RUN: %clang_cc1 -Wno-unused-value -O0 -internal-isystem %S/../../lib/Headers -include __clang_spirv_builtins.h -triple spirv64 -emit-llvm %s -x cl -o - | FileCheck %s -check-prefixes=CHECK64 -// RUN: %clang_cc1 -Wno-unused-value -O0 -internal-isystem %S/../../lib/Headers -include __clang_spirv_builtins.h -triple spirv32 -emit-llvm %s -fsycl-is-device -o - | FileCheck %s -check-prefixes=CHECK32 +// RUN: %clang_cc1 -Wno-unused-value -O0 -internal-isystem %S/../../lib/Headers -include __clang_spirv_builtins.h -triple spirv32 -emit-llvm %s -fsycl-is-device -fgpu-rdc -o - | FileCheck %s -check-prefixes=CHECK32 // RUN: %clang_cc1 -Wno-unused-value -O0 -internal-isystem %S/../../lib/Headers -include __clang_spirv_builtins.h -triple spirv32 -emit-llvm %s -x cl -o - | FileCheck %s -check-prefixes=CHECK32 -// RUN: %clang_cc1 -Wno-unused-value -O0 -internal-isystem %S/../../lib/Headers -include __clang_spirv_builtins.h -triple nvptx64 -emit-llvm %s -fsycl-is-device -o - | FileCheck %s -check-prefixes=NV +// RUN: %clang_cc1 -Wno-unused-value -O0 -internal-isystem %S/../../lib/Headers -include __clang_spirv_builtins.h -triple nvptx64 -emit-llvm %s -fsycl-is-device -fgpu-rdc -o - | FileCheck %s -check-prefixes=NV // CHECK64: call i64 @llvm.spv.num.workgroups.i64(i32 0) diff --git a/clang/test/SemaSYCL/sycl-cconv.cpp b/clang/test/SemaSYCL/sycl-cconv.cpp index 1b250676cf478..db1036f015c39 100644 --- a/clang/test/SemaSYCL/sycl-cconv.cpp +++ b/clang/test/SemaSYCL/sycl-cconv.cpp @@ -6,7 +6,7 @@ __inline __cdecl int printf(char const* const _Format, ...) { return 0; } -// FIXME: that should be diagnosed. +// expected-error@+1 {{'clang::sycl_external' attribute is ignored when GPU relocatable device code (-fgpu-rdc) is disabled}} [[clang::sycl_external]] int foo(int, ...) { return 0; } __inline __cdecl int moo() { return 0; } diff --git a/clang/test/SemaSYCL/sycl-external-attr-grammar.cpp b/clang/test/SemaSYCL/sycl-external-attr-grammar.cpp index a0169851cdaf0..3401e431e11d0 100644 --- a/clang/test/SemaSYCL/sycl-external-attr-grammar.cpp +++ b/clang/test/SemaSYCL/sycl-external-attr-grammar.cpp @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -fsycl-is-host -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsycl-is-device -fgpu-rdc -fsyntax-only -verify %s // FIXME-expected-error@+1{{'clang::sycl_external' attribute takes no arguments}} [[clang::sycl_external()]] void bad1(); diff --git a/clang/test/SemaSYCL/sycl-external-attr-no-gpu-rdc.cpp b/clang/test/SemaSYCL/sycl-external-attr-no-gpu-rdc.cpp new file mode 100644 index 0000000000000..810393bafe74f --- /dev/null +++ b/clang/test/SemaSYCL/sycl-external-attr-no-gpu-rdc.cpp @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -fsycl-is-host -std=c++17 -fsyntax-only -verify=rdc %s +// RUN: %clang_cc1 -fsycl-is-host -std=c++17 -fgpu-rdc -fsyntax-only -verify=rdc %s +// RUN: %clang_cc1 -fsycl-is-device -std=c++17 -fsyntax-only -verify=nordc %s +// RUN: %clang_cc1 -fsycl-is-device -std=c++17 -fgpu-rdc -fsyntax-only -verify=rdc %s +// RUN: %clang_cc1 -fsycl-is-device -std=c++17 -Wno-sycl-external-ignored -fsyntax-only -verify=rdc %s + +// Tests that the sycl_external attribute is diagnosed as ignored during device +// compilation without -fgpu-rdc; Host compilation does not diagnose this to +// avoid rediagnosing an issue twice. + +// nordc-error@+1{{'clang::sycl_external' attribute is ignored when GPU relocatable device code (-fgpu-rdc) is disabled}} +[[clang::sycl_external]] void foo() {} + +// Redeclarations should not result in the diagnostic triggering again: +// nordc-error@+1{{'clang::sycl_external' attribute is ignored when GPU reloc... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/232934 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
