File tree Expand file tree Collapse file tree 2 files changed +41
-4
lines changed Expand file tree Collapse file tree 2 files changed +41
-4
lines changed Original file line number Diff line number Diff line change @@ -10446,14 +10446,14 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) {
10446
10446
if (D->hasAttr <WeakRefAttr>())
10447
10447
return false ;
10448
10448
10449
- // Aliases and used decls are required.
10450
- if (D->hasAttr <AliasAttr>() || D->hasAttr <UsedAttr>())
10451
- return true ;
10452
-
10453
10449
if (LangOpts.SYCLIsDevice && !D->hasAttr <OpenCLKernelAttr>() &&
10454
10450
!D->hasAttr <SYCLDeviceAttr>())
10455
10451
return false ;
10456
10452
10453
+ // Aliases and used decls are required.
10454
+ if (D->hasAttr <AliasAttr>() || D->hasAttr <UsedAttr>())
10455
+ return true ;
10456
+
10457
10457
if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
10458
10458
// Forward declarations aren't required.
10459
10459
if (!FD->doesThisDeclarationHaveABody ())
Original file line number Diff line number Diff line change
1
+ // RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s
2
+ // Test that the 'used' attribute does not force the emission of globals on sycl device
3
+
4
+ // CHECK-NOT: @_ZN1hI1aE1iE
5
+ // CHECK-NOT: @_ZGVN1hI1aE1iE
6
+ // CHECK-NOT: @__dso_handle
7
+ // CHECK-NOT: @llvm.global_ctors
8
+ // CHECK-NOT: @llvm.used
9
+
10
+ // CHECK-NOT: {{.*}} void @_ZN1fI1aEC2Ev(%struct._ZTS1fI1aE.f* %this)
11
+
12
+ // CHECK-NOT: {{.*}} void @__cxx_global_var_init()
13
+ // CHECK-NOT: {{.*}} void @_ZN1gD1Ev(%class._ZTS1g.g*) unnamed_addr #2
14
+ // CHECK-NOT: {{.*}} i32 @__cxa_atexit(void (i8*)*, i8*, i8*)
15
+ // CHECK-NOT: {{.*}} void @_ZN1fI1aEC1Ev(%struct._ZTS1fI1aE.f* %this)
16
+
17
+ struct a ;
18
+ class g {
19
+ public:
20
+ int c;
21
+ ~g ();
22
+ };
23
+ template <class >
24
+ class h {
25
+ public:
26
+ static const void k ();
27
+ static g i;
28
+ };
29
+ template <class j >
30
+ const void h<j>::k() { i.c = 0 ; }
31
+ template <class j >
32
+ g h<j>::i;
33
+ template <class >
34
+ struct f { f() __attribute__((used)); };
35
+ template <class j >
36
+ f<j>::f() { h<j>::k (); }
37
+ template struct f <a>;
You can’t perform that action at this time.
0 commit comments