[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
Fri Apr 23 09:22:08 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcbe8b57a6755: [Clang] Allow the combination of loader_uninitialized and address spaces (authored by jdoerfert).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100929/new/

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
  clang/test/Sema/attr-loader-uninitialized.cpp


Index: clang/test/Sema/attr-loader-uninitialized.cpp
===================================================================
--- clang/test/Sema/attr-loader-uninitialized.cpp
+++ clang/test/Sema/attr-loader-uninitialized.cpp
@@ -5,7 +5,6 @@
 int hidden_ok __attribute__((visibility("hidden"))) __attribute__((loader_uninitialized));
 
 const int still_cant_be_const __attribute__((loader_uninitialized));
-// expected-error at -1 {{default initialization of an object of const type}}
 extern int external_rejected __attribute__((loader_uninitialized));
 // expected-error at -1 {{variable 'external_rejected' cannot be declared both 'extern' and with the 'loader_uninitialized' attribute}}
 
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
@@ -12640,6 +12640,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.340073.patch
Type: text/x-patch
Size: 3213 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210423/232d79e1/attachment.bin>


More information about the cfe-commits mailing list