[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 13 17:22:30 PDT 2025
================
@@ -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_external]] int square(int x) { return x*x; }
+// CHECK: define dso_local spir_func noundef i32 @_Z6squarei
+
+// Function defined and used - symbols emitted
+[[clang::sycl_external]] int squareUsed(int x) { return x*x; }
+// CHECK: define dso_local spir_func noundef i32 @_Z10squareUsedi
+
+// Constexpr function defined and not used - symbols emitted
----------------
schittir wrote:
I was under the opposite impression per one of the older review comments but I can't find it at the moment. No related wording in the spec either.
https://github.com/llvm/llvm-project/pull/140282
More information about the cfe-commits
mailing list