[Openmp-commits] [openmp] 4395608 - [openmp] Mark used variables as retain as well

Jon Chesterfield via Openmp-commits openmp-commits at lists.llvm.org
Thu Jan 13 05:57:41 PST 2022


Author: Jon Chesterfield
Date: 2022-01-13T13:57:32Z
New Revision: 439560893941aaff0c9634bdc5eda8337ba0375e

URL: https://github.com/llvm/llvm-project/commit/439560893941aaff0c9634bdc5eda8337ba0375e
DIFF: https://github.com/llvm/llvm-project/commit/439560893941aaff0c9634bdc5eda8337ba0375e.diff

LOG: [openmp] Mark used variables as retain as well

D97446 changed the behaviour of 'used'. Compensate.

Reviewed By: ronlieb

Differential Revision: https://reviews.llvm.org/D117211

Added: 
    

Modified: 
    openmp/libomptarget/DeviceRTL/src/Configuration.cpp
    openmp/libomptarget/DeviceRTL/src/Utils.cpp
    openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
    openmp/libomptarget/deviceRTLs/common/src/support.cu

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/DeviceRTL/src/Configuration.cpp b/openmp/libomptarget/DeviceRTL/src/Configuration.cpp
index f7c61dc013cf1..ae819a9bb93d0 100644
--- a/openmp/libomptarget/DeviceRTL/src/Configuration.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/Configuration.cpp
@@ -24,7 +24,7 @@ extern uint32_t __omp_rtl_debug_kind; // defined by CGOpenMPRuntimeGPU
 
 // TODO: We want to change the name as soon as the old runtime is gone.
 DeviceEnvironmentTy CONSTANT(omptarget_device_environment)
-    __attribute__((used));
+    __attribute__((used, retain));
 
 uint32_t config::getDebugKind() {
   return __omp_rtl_debug_kind & omptarget_device_environment.DebugKind;

diff  --git a/openmp/libomptarget/DeviceRTL/src/Utils.cpp b/openmp/libomptarget/DeviceRTL/src/Utils.cpp
index 8cd633bd53a9f..b04653f51560f 100644
--- a/openmp/libomptarget/DeviceRTL/src/Utils.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/Utils.cpp
@@ -21,7 +21,7 @@ using namespace _OMP;
 
 namespace _OMP {
 /// Helper to keep code alive without introducing a performance penalty.
-__attribute__((used, weak, optnone)) void keepAlive() {
+__attribute__((used, retain, weak, optnone)) void keepAlive() {
   __kmpc_get_hardware_thread_id_in_block();
   __kmpc_get_hardware_num_threads_in_block();
   __kmpc_get_warp_size();

diff  --git a/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h b/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
index f4755996c86aa..2fe1ebd54673d 100644
--- a/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
+++ b/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
@@ -31,7 +31,8 @@ typedef uint64_t __kmpc_impl_lanemask_t;
 #define NOINLINE __attribute__((noinline))
 #define ALIGN(N) __attribute__((aligned(N)))
 #define PLUGIN_ACCESSIBLE                                                      \
-  __attribute__((used)) /* Don't discard values the plugin reads */            \
+  __attribute__((used))   /* Don't discard values the plugin reads */          \
+  __attribute__((retain)) /* Also needed to keep values alive */               \
   __attribute__((visibility("default"))) /* Access via SHT_HASH */             \
   __attribute__((section(".data")))      /* Not .bss, can write before load */
 

diff  --git a/openmp/libomptarget/deviceRTLs/common/src/support.cu b/openmp/libomptarget/deviceRTLs/common/src/support.cu
index 47969a31bb109..28df6bc0cf22c 100644
--- a/openmp/libomptarget/deviceRTLs/common/src/support.cu
+++ b/openmp/libomptarget/deviceRTLs/common/src/support.cu
@@ -228,7 +228,7 @@ void __kmp_invoke_microtask(kmp_int32 global_tid, kmp_int32 bound_tid, void *fn,
 
 namespace _OMP {
 /// Helper to keep code alive without introducing a performance penalty.
-__attribute__((used, weak, optnone)) void keepAlive() {
+__attribute__((used, retain, weak, optnone)) void keepAlive() {
   __kmpc_get_hardware_thread_id_in_block();
   __kmpc_get_hardware_num_threads_in_block();
   __kmpc_get_warp_size();


        


More information about the Openmp-commits mailing list