[Openmp-commits] [openmp] 1af81ab - [libarcher] Place classes in anonymous namespace

Nikita Popov via Openmp-commits openmp-commits at lists.llvm.org
Mon Oct 31 01:17:29 PDT 2022


Author: Nikita Popov
Date: 2022-10-31T09:16:38+01:00
New Revision: 1af81ab4846f0d07d3ac3079f95d66779a4d9430

URL: https://github.com/llvm/llvm-project/commit/1af81ab4846f0d07d3ac3079f95d66779a4d9430
DIFF: https://github.com/llvm/llvm-project/commit/1af81ab4846f0d07d3ac3079f95d66779a4d9430.diff

LOG: [libarcher] Place classes in anonymous namespace

Place various classes/structs into anonymous namespaces and mark
variables as static. As far as I understand, these are all
implementation details and not intended to be exported -- only a
small number of tsan hooks are supposed to be.

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

Added: 
    

Modified: 
    openmp/tools/archer/ompt-tsan.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/tools/archer/ompt-tsan.cpp b/openmp/tools/archer/ompt-tsan.cpp
index a3cc0a2ec30d4..a6fdb17ca9bf4 100644
--- a/openmp/tools/archer/ompt-tsan.cpp
+++ b/openmp/tools/archer/ompt-tsan.cpp
@@ -56,6 +56,7 @@
 static int runOnTsan;
 static int hasReductionCallback;
 
+namespace {
 class ArcherFlags {
 public:
 #if (LLVM_VERSION) >= 40
@@ -132,6 +133,7 @@ class TsanFlags {
     }
   }
 };
+} // namespace
 
 #if (LLVM_VERSION) >= 40
 extern "C" {
@@ -139,7 +141,7 @@ int __attribute__((weak)) __archer_get_omp_status();
 void __attribute__((weak)) __tsan_flush_memory() {}
 }
 #endif
-ArcherFlags *archer_flags;
+static ArcherFlags *archer_flags;
 
 #ifndef TsanHappensBefore
 // Thread Sanitizer is a tool that finds races in code.
@@ -232,6 +234,7 @@ static int pagesize{0};
 
 // Data structure to provide a threadsafe pool of reusable objects.
 // DataPool<Type of objects>
+namespace {
 template <typename T> struct DataPool final {
   static __thread DataPool<T> *ThreadDataPool;
   std::mutex DPMutex{};
@@ -598,14 +601,15 @@ struct TaskData final : DataPoolEntry<TaskData> {
 
   TaskData(DataPool<TaskData> *dp) : DataPoolEntry<TaskData>(dp) {}
 };
+} // namespace
 
 static inline TaskData *ToTaskData(ompt_data_t *task_data) {
   return reinterpret_cast<TaskData *>(task_data->ptr);
 }
 
 /// Store a mutex for each wait_id to resolve race condition with callbacks.
-std::unordered_map<ompt_wait_id_t, std::mutex> Locks;
-std::mutex LocksMutex;
+static std::unordered_map<ompt_wait_id_t, std::mutex> Locks;
+static std::mutex LocksMutex;
 
 static void ompt_tsan_thread_begin(ompt_thread_t thread_type,
                                    ompt_data_t *thread_data) {


        


More information about the Openmp-commits mailing list