[Openmp-commits] [openmp] 4869a22 - [Libomptarget] Add `cold` to KeepAlive attributes

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Mon Jan 17 14:29:39 PST 2022


Author: Joseph Huber
Date: 2022-01-17T17:29:26-05:00
New Revision: 4869a22d1d0bff59e3f2699739554d459905a76d

URL: https://github.com/llvm/llvm-project/commit/4869a22d1d0bff59e3f2699739554d459905a76d
DIFF: https://github.com/llvm/llvm-project/commit/4869a22d1d0bff59e3f2699739554d459905a76d.diff

LOG: [Libomptarget] Add `cold` to KeepAlive attributes

This patch adds the `cold` attribute to the keepAlive functions in the
RTL. This dummy function exists to keep certain RTL calls alive without
them being optimized out, but it is never called and can be declared
cold. This also helps some erroneous remarks being given on this
function because it has weak linkage and cannot be made internal.

Reviewed By: tianshilei1992

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

Added: 
    

Modified: 
    openmp/libomptarget/DeviceRTL/src/Utils.cpp
    openmp/libomptarget/deviceRTLs/common/src/support.cu

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/DeviceRTL/src/Utils.cpp b/openmp/libomptarget/DeviceRTL/src/Utils.cpp
index b04653f51560f..0816f078e2ab4 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, retain, weak, optnone)) void keepAlive() {
+__attribute__((used, retain, weak, optnone, cold)) 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/common/src/support.cu b/openmp/libomptarget/deviceRTLs/common/src/support.cu
index 28df6bc0cf22c..e6241a424a911 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, retain, weak, optnone)) void keepAlive() {
+__attribute__((used, retain, weak, optnone, cold)) 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