[Openmp-commits] [openmp] [OpenMP][libomptarget] Fixes possible no-return warning (PR #70808)

Jan Patrick Lehr via Openmp-commits openmp-commits at lists.llvm.org
Tue Oct 31 07:05:17 PDT 2023


https://github.com/jplehr created https://github.com/llvm/llvm-project/pull/70808

The UNREACHABLE macro resolves to message + trap, which may still give you no-return warnings. This silences these warnings.

>From c80f81c0c455d4b91d11d5265ab0af0561e5435b Mon Sep 17 00:00:00 2001
From: JP Lehr <JanPatrick.Lehr at amd.com>
Date: Tue, 31 Oct 2023 09:55:44 -0400
Subject: [PATCH] [OpenMP][libomptarget] Fixes possible no-return warning

The UNREACHABLE macro resolves to message + trap, which may still give
you no-return warnings. This silences these warnings.
---
 openmp/libomptarget/DeviceRTL/src/Mapping.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/openmp/libomptarget/DeviceRTL/src/Mapping.cpp b/openmp/libomptarget/DeviceRTL/src/Mapping.cpp
index 822b8dc2dd5e671..c64856c237f04e0 100644
--- a/openmp/libomptarget/DeviceRTL/src/Mapping.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/Mapping.cpp
@@ -57,6 +57,7 @@ uint32_t getNumberOfThreadsInBlock(int32_t Dim) {
     return __builtin_amdgcn_workgroup_size_z();
   };
   UNREACHABLE("Dim outside range!");
+  return 0;
 }
 
 LaneMaskTy activemask() { return __builtin_amdgcn_read_exec(); }
@@ -91,6 +92,7 @@ uint32_t getThreadIdInBlock(int32_t Dim) {
     return __builtin_amdgcn_workitem_id_z();
   };
   UNREACHABLE("Dim outside range!");
+  return 0;
 }
 
 uint32_t getNumberOfThreadsInKernel() {
@@ -108,6 +110,7 @@ uint32_t getBlockIdInKernel(int32_t Dim) {
     return __builtin_amdgcn_workgroup_id_z();
   };
   UNREACHABLE("Dim outside range!");
+  return 0;
 }
 
 uint32_t getNumberOfBlocksInKernel(int32_t Dim) {
@@ -120,6 +123,7 @@ uint32_t getNumberOfBlocksInKernel(int32_t Dim) {
     return __builtin_amdgcn_grid_size_z() / __builtin_amdgcn_workgroup_size_z();
   };
   UNREACHABLE("Dim outside range!");
+  return 0;
 }
 
 uint32_t getWarpIdInBlock() {
@@ -150,6 +154,7 @@ uint32_t getNumberOfThreadsInBlock(int32_t Dim) {
     return __nvvm_read_ptx_sreg_ntid_z();
   };
   UNREACHABLE("Dim outside range!");
+  return 0;
 }
 
 const llvm::omp::GV &getGridValue() { return llvm::omp::NVPTXGridValues; }
@@ -182,6 +187,7 @@ uint32_t getThreadIdInBlock(int32_t Dim) {
     return __nvvm_read_ptx_sreg_tid_z();
   };
   UNREACHABLE("Dim outside range!");
+  return 0;
 }
 
 uint32_t getThreadIdInWarp() {
@@ -199,6 +205,7 @@ uint32_t getBlockIdInKernel(int32_t Dim) {
     return __nvvm_read_ptx_sreg_ctaid_z();
   };
   UNREACHABLE("Dim outside range!");
+  return 0;
 }
 
 uint32_t getNumberOfBlocksInKernel(int32_t Dim) {
@@ -211,6 +218,7 @@ uint32_t getNumberOfBlocksInKernel(int32_t Dim) {
     return __nvvm_read_ptx_sreg_nctaid_z();
   };
   UNREACHABLE("Dim outside range!");
+  return 0;
 }
 
 uint32_t getNumberOfThreadsInKernel() {



More information about the Openmp-commits mailing list