[Openmp-commits] [PATCH] D117513: [Libomptarget] Add `cold` to KeepAlive attributes

Joseph Huber via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Mon Jan 17 14:04:37 PST 2022


jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992.
jhuber6 requested review of this revision.
Herald added a project: OpenMP.
Herald added a subscriber: openmp-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117513

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


Index: openmp/libomptarget/deviceRTLs/common/src/support.cu
===================================================================
--- openmp/libomptarget/deviceRTLs/common/src/support.cu
+++ openmp/libomptarget/deviceRTLs/common/src/support.cu
@@ -228,7 +228,7 @@
 
 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();
Index: openmp/libomptarget/DeviceRTL/src/Utils.cpp
===================================================================
--- openmp/libomptarget/DeviceRTL/src/Utils.cpp
+++ openmp/libomptarget/DeviceRTL/src/Utils.cpp
@@ -21,7 +21,7 @@
 
 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();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117513.400641.patch
Type: text/x-patch
Size: 1193 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220117/c8ccfa3d/attachment.bin>


More information about the Openmp-commits mailing list