From 0203ff19602d9d90e03653062dbb19cc13afa956 Mon Sep 17 00:00:00 2001 From: Joseph Huber Date: Mon, 17 Jan 2022 19:55:03 -0500 Subject: [PATCH] [Libomptarget] Fix external visibility for internal variables After the changes in D117362 made variables declared inside of a target declare directive visible outside the plugin, some variables inside the runtime were given visiblity that conflicted with their address space type. This caused problems when shared or local memory was made externally visible. This patch fixes this issue by making these varialbes static within the module, therefore limiting their visibility to being internal. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D117526 --- openmp/libomptarget/DeviceRTL/include/Types.h | 3 ++- openmp/libomptarget/DeviceRTL/src/Workshare.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/openmp/libomptarget/DeviceRTL/include/Types.h b/openmp/libomptarget/DeviceRTL/include/Types.h index 0ff0cee66b3f..8d9b48a0f135 100644 --- a/openmp/libomptarget/DeviceRTL/include/Types.h +++ b/openmp/libomptarget/DeviceRTL/include/Types.h @@ -193,7 +193,8 @@ enum OMPTgtExecModeFlags : int8_t { // TODO: clang should use address space 5 for omp_thread_mem_alloc, but right // now that's not the case. #define THREAD_LOCAL(NAME) \ - NAME [[clang::loader_uninitialized, clang::address_space(5)]] + NAME [[clang::loader_uninitialized, clang::address_space(5), \ + gnu::visibility("hidden")]] // TODO: clang should use address space 4 for omp_const_mem_alloc, maybe it // does? diff --git a/openmp/libomptarget/DeviceRTL/src/Workshare.cpp b/openmp/libomptarget/DeviceRTL/src/Workshare.cpp index 24f3fee2aa5b..0bdbf30c23d3 100644 --- a/openmp/libomptarget/DeviceRTL/src/Workshare.cpp +++ b/openmp/libomptarget/DeviceRTL/src/Workshare.cpp @@ -46,7 +46,7 @@ struct DynamicScheduleTracker { #pragma omp declare target // TODO: This variable is a hack inherited from the old runtime. -uint64_t SHARED(Cnt); +static uint64_t SHARED(Cnt); template struct omptarget_nvptx_LoopSupport { //////////////////////////////////////////////////////////////////////////////// @@ -443,7 +443,7 @@ template struct omptarget_nvptx_LoopSupport { // TODO: This is a stopgap. We probably want to expand the dispatch API to take // an DST pointer which can then be allocated properly without malloc. -DynamicScheduleTracker *THREAD_LOCAL(ThreadDSTPtr); +static DynamicScheduleTracker *THREAD_LOCAL(ThreadDSTPtr); // Create a new DST, link the current one, and define the new as current. static DynamicScheduleTracker *pushDST() {