From 4869a22d1d0bff59e3f2699739554d459905a76d Mon Sep 17 00:00:00 2001 From: Joseph Huber Date: Mon, 17 Jan 2022 17:03:33 -0500 Subject: [PATCH] [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 --- openmp/libomptarget/DeviceRTL/src/Utils.cpp | 2 +- openmp/libomptarget/deviceRTLs/common/src/support.cu | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openmp/libomptarget/DeviceRTL/src/Utils.cpp b/openmp/libomptarget/DeviceRTL/src/Utils.cpp index b04653f..0816f07 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 28df6bc..e6241a4 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(); -- 2.7.4