jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992, JonChesterfield, ronlieb, 
ABataev.
Herald added subscribers: mattd, asavonic, guansong, yaxunl.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

We use protected visibility for almost everything with offloading. This
is because it provides us with the ability to read things from the host
without the expectation that it will be preempted by a shared library
load, bugs related to this have happened when offloading to the host.
This patch just makes the `exec_mode` global generated for each plugin
have protected visibility.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135285

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_target_simd_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_simd_codegen.cpp


Index: clang/test/OpenMP/nvptx_target_teams_distribute_simd_codegen.cpp
===================================================================
--- clang/test/OpenMP/nvptx_target_teams_distribute_simd_codegen.cpp
+++ clang/test/OpenMP/nvptx_target_teams_distribute_simd_codegen.cpp
@@ -16,10 +16,10 @@
 #define HEADER
 
 // Check that the execution mode of all 2 target regions on the gpu is set to 
NonSPMD Mode.
-// CHECK-DAG: {{@__omp_offloading_.+l37}}_exec_mode = weak constant i8 2
-// CHECK-DAG: {{@__omp_offloading_.+l43}}_exec_mode = weak constant i8 2
-// CHECK-DAG: {{@__omp_offloading_.+l48}}_exec_mode = weak constant i8 2
-// CHECK-DAG: {{@__omp_offloading_.+l53}}_exec_mode = weak constant i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l37}}_exec_mode = weak protected constant 
i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l43}}_exec_mode = weak protected constant 
i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l48}}_exec_mode = weak protected constant 
i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l53}}_exec_mode = weak protected constant 
i8 2
 
 #define N 1000
 #define M 10
Index: clang/test/OpenMP/nvptx_target_simd_codegen.cpp
===================================================================
--- clang/test/OpenMP/nvptx_target_simd_codegen.cpp
+++ clang/test/OpenMP/nvptx_target_simd_codegen.cpp
@@ -16,10 +16,10 @@
 #define HEADER
 
 // Check that the execution mode of all 2 target regions on the gpu is set to 
NonSPMD Mode.
-// CHECK-DAG: {{@__omp_offloading_.+l32}}_exec_mode = weak constant i8 2
-// CHECK-DAG: {{@__omp_offloading_.+l37}}_exec_mode = weak constant i8 2
-// CHECK-DAG: {{@__omp_offloading_.+l42}}_exec_mode = weak constant i8 2
-// CHECK-DAG: {{@__omp_offloading_.+l47}}_exec_mode = weak constant i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l32}}_exec_mode = weak protected constant 
i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l37}}_exec_mode = weak protected constant 
i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l42}}_exec_mode = weak protected constant 
i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l47}}_exec_mode = weak protected constant 
i8 2
 
 #define N 1000
 
Index: clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
===================================================================
--- clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
+++ clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
@@ -12,9 +12,9 @@
 // CHECK-DAG: [[TRANSFER_STORAGE:@.+]] = weak 
addrspace([[SHARED_ADDRSPACE:[0-9]+]]) global [32 x i32]
 
 // Check that the execution mode of all 3 target regions is set to Spmd Mode.
-// CHECK-DAG: {{@__omp_offloading_.+l27}}_exec_mode = weak constant i8 2
-// CHECK-DAG: {{@__omp_offloading_.+l32}}_exec_mode = weak constant i8 2
-// CHECK-DAG: {{@__omp_offloading_.+l38}}_exec_mode = weak constant i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l27}}_exec_mode = weak protected constant 
i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l32}}_exec_mode = weak protected constant 
i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l38}}_exec_mode = weak protected constant 
i8 2
 
 template<typename tx>
 tx ftemplate(int n) {
Index: clang/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp
===================================================================
--- clang/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp
+++ clang/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp
@@ -16,9 +16,9 @@
 #define HEADER
 
 // Check that the execution mode of all 3 target regions on the gpu is set to 
SPMD Mode.
-// CHECK-DAG: {{@__omp_offloading_.+l29}}_exec_mode = weak constant i8 2
-// CHECK-DAG: {{@__omp_offloading_.+l33}}_exec_mode = weak constant i8 2
-// CHECK-DAG: {{@__omp_offloading_.+l38}}_exec_mode = weak constant i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l29}}_exec_mode = weak protected constant 
i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l33}}_exec_mode = weak protected constant 
i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l38}}_exec_mode = weak protected constant 
i8 2
 
 template<typename tx>
 tx ftemplate(int n) {
Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
===================================================================
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -836,6 +836,7 @@
       llvm::ConstantInt::get(CGM.Int8Ty, Mode ? OMP_TGT_EXEC_MODE_SPMD
                                               : OMP_TGT_EXEC_MODE_GENERIC),
       Twine(Name, "_exec_mode"));
+  GVMode->setVisibility(llvm::GlobalVariable::ProtectedVisibility);
   CGM.addCompilerUsedGlobal(GVMode);
 }
 


Index: clang/test/OpenMP/nvptx_target_teams_distribute_simd_codegen.cpp
===================================================================
--- clang/test/OpenMP/nvptx_target_teams_distribute_simd_codegen.cpp
+++ clang/test/OpenMP/nvptx_target_teams_distribute_simd_codegen.cpp
@@ -16,10 +16,10 @@
 #define HEADER
 
 // Check that the execution mode of all 2 target regions on the gpu is set to NonSPMD Mode.
-// CHECK-DAG: {{@__omp_offloading_.+l37}}_exec_mode = weak constant i8 2
-// CHECK-DAG: {{@__omp_offloading_.+l43}}_exec_mode = weak constant i8 2
-// CHECK-DAG: {{@__omp_offloading_.+l48}}_exec_mode = weak constant i8 2
-// CHECK-DAG: {{@__omp_offloading_.+l53}}_exec_mode = weak constant i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l37}}_exec_mode = weak protected constant i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l43}}_exec_mode = weak protected constant i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l48}}_exec_mode = weak protected constant i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l53}}_exec_mode = weak protected constant i8 2
 
 #define N 1000
 #define M 10
Index: clang/test/OpenMP/nvptx_target_simd_codegen.cpp
===================================================================
--- clang/test/OpenMP/nvptx_target_simd_codegen.cpp
+++ clang/test/OpenMP/nvptx_target_simd_codegen.cpp
@@ -16,10 +16,10 @@
 #define HEADER
 
 // Check that the execution mode of all 2 target regions on the gpu is set to NonSPMD Mode.
-// CHECK-DAG: {{@__omp_offloading_.+l32}}_exec_mode = weak constant i8 2
-// CHECK-DAG: {{@__omp_offloading_.+l37}}_exec_mode = weak constant i8 2
-// CHECK-DAG: {{@__omp_offloading_.+l42}}_exec_mode = weak constant i8 2
-// CHECK-DAG: {{@__omp_offloading_.+l47}}_exec_mode = weak constant i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l32}}_exec_mode = weak protected constant i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l37}}_exec_mode = weak protected constant i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l42}}_exec_mode = weak protected constant i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l47}}_exec_mode = weak protected constant i8 2
 
 #define N 1000
 
Index: clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
===================================================================
--- clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
+++ clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
@@ -12,9 +12,9 @@
 // CHECK-DAG: [[TRANSFER_STORAGE:@.+]] = weak addrspace([[SHARED_ADDRSPACE:[0-9]+]]) global [32 x i32]
 
 // Check that the execution mode of all 3 target regions is set to Spmd Mode.
-// CHECK-DAG: {{@__omp_offloading_.+l27}}_exec_mode = weak constant i8 2
-// CHECK-DAG: {{@__omp_offloading_.+l32}}_exec_mode = weak constant i8 2
-// CHECK-DAG: {{@__omp_offloading_.+l38}}_exec_mode = weak constant i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l27}}_exec_mode = weak protected constant i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l32}}_exec_mode = weak protected constant i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l38}}_exec_mode = weak protected constant i8 2
 
 template<typename tx>
 tx ftemplate(int n) {
Index: clang/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp
===================================================================
--- clang/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp
+++ clang/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp
@@ -16,9 +16,9 @@
 #define HEADER
 
 // Check that the execution mode of all 3 target regions on the gpu is set to SPMD Mode.
-// CHECK-DAG: {{@__omp_offloading_.+l29}}_exec_mode = weak constant i8 2
-// CHECK-DAG: {{@__omp_offloading_.+l33}}_exec_mode = weak constant i8 2
-// CHECK-DAG: {{@__omp_offloading_.+l38}}_exec_mode = weak constant i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l29}}_exec_mode = weak protected constant i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l33}}_exec_mode = weak protected constant i8 2
+// CHECK-DAG: {{@__omp_offloading_.+l38}}_exec_mode = weak protected constant i8 2
 
 template<typename tx>
 tx ftemplate(int n) {
Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
===================================================================
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -836,6 +836,7 @@
       llvm::ConstantInt::get(CGM.Int8Ty, Mode ? OMP_TGT_EXEC_MODE_SPMD
                                               : OMP_TGT_EXEC_MODE_GENERIC),
       Twine(Name, "_exec_mode"));
+  GVMode->setVisibility(llvm::GlobalVariable::ProtectedVisibility);
   CGM.addCompilerUsedGlobal(GVMode);
 }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D135285: [OpenMP] Mak... Joseph Huber via Phabricator via cfe-commits

Reply via email to