[PATCH] D100929: [Clang] Allow the combination of loader_uninitialized and address spaces
Johannes Doerfert via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 21 00:33:27 PDT 2021
jdoerfert created this revision.
jdoerfert added reviewers: JonChesterfield, aaron.ballman.
Herald added a reviewer: bollu.
jdoerfert requested review of this revision.
Herald added a project: clang.
When an object is allocated in a non-default address space we do not
need to check for a constructor if it is not initialized and has a
trivial constructor (which we won't call then).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D100929
Files:
clang/lib/Sema/SemaDecl.cpp
clang/test/CodeGen/attr-loader-uninitialized.c
clang/test/OpenMP/declare_target_codegen.cpp
Index: clang/test/OpenMP/declare_target_codegen.cpp
===================================================================
--- clang/test/OpenMP/declare_target_codegen.cpp
+++ clang/test/OpenMP/declare_target_codegen.cpp
@@ -37,6 +37,7 @@
// CHECK-DAG: @fff_decl_tgt_ref_ptr = weak global i32* null
// CHECK-DAG: @eee_decl_tgt_ref_ptr = weak global i32* null
// CHECK-DAG: @{{.*}}maini1{{.*}}aaa = internal global i64 23,
+// CHECK-DAG: @pair = {{.*}}addrspace(3) global %struct.PAIR undef
// CHECK-DAG: @b ={{ hidden | }}global i32 15,
// CHECK-DAG: @d ={{ hidden | }}global i32 0,
// CHECK-DAG: @c = external global i32,
@@ -264,6 +265,15 @@
// DEV5-NOT: define {{.*}}void {{.*}}host_fun{{.*}}
#endif // OMP5
+struct PAIR {
+ int a;
+ int b;
+};
+
+#pragma omp declare target
+PAIR pair __attribute__((address_space(3), loader_uninitialized));
+#pragma omp end declare target
+
#endif // HEADER
#ifdef LOAD
Index: clang/test/CodeGen/attr-loader-uninitialized.c
===================================================================
--- clang/test/CodeGen/attr-loader-uninitialized.c
+++ clang/test/CodeGen/attr-loader-uninitialized.c
@@ -18,7 +18,19 @@
} s;
// CHECK: @i ={{.*}} global %struct.s undef
+// CHECK: @j1 ={{.*}}addrspace(1) global %struct.s undef
+// CHECK: @j2 ={{.*}}addrspace(2) global %struct.s undef
+// CHECK: @j3 ={{.*}}addrspace(3) global %struct.s undef
+// CHECK: @j4 ={{.*}}addrspace(4) global %struct.s undef
+// CHECK: @j5 ={{.*}}addrspace(5) global %struct.s undef
+// CHECK: @j99 ={{.*}}addrspace(99) global %struct.s undef
s i __attribute__((loader_uninitialized));
+s j1 __attribute__((loader_uninitialized, address_space(1)));
+s j2 __attribute__((loader_uninitialized, address_space(2)));
+s j3 __attribute__((loader_uninitialized, address_space(3)));
+s j4 __attribute__((loader_uninitialized, address_space(4)));
+s j5 __attribute__((loader_uninitialized, address_space(5)));
+s j99 __attribute__((loader_uninitialized, address_space(99)));
// CHECK: @private_extern_ok = hidden global i32 undef
__private_extern__ int private_extern_ok __attribute__((loader_uninitialized));
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -12623,6 +12623,8 @@
return;
}
}
+ // The declaration is unitialized, no need for further checks.
+ return;
}
VarDecl::DefinitionKind DefKind = Var->isThisDeclarationADefinition();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100929.339126.patch
Type: text/x-patch
Size: 2531 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210421/d3350b78/attachment.bin>
More information about the cfe-commits
mailing list