[llvm] Workaround -Wglobal-constructor warning. (PR #94699)

Eric Schweitz via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 10 10:39:04 PDT 2024


https://github.com/schweitzpgi updated https://github.com/llvm/llvm-project/pull/94699

>From 352477cf1a4ade7bb100e322697dc5e9be20e67d Mon Sep 17 00:00:00 2001
From: Eric Schweitz <eschweitz at nvidia.com>
Date: Thu, 6 Jun 2024 16:33:07 -0700
Subject: [PATCH] Workaround -Wglobal-constructor warning.

This line was tripping the -Wglobal-constructor warning which was
causing a build failure when -Werror was turned on.

code review comment
---
 llvm/lib/Support/CodeGenCoverage.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/lib/Support/CodeGenCoverage.cpp b/llvm/lib/Support/CodeGenCoverage.cpp
index 4d41c42e527e2..2e35019e12c16 100644
--- a/llvm/lib/Support/CodeGenCoverage.cpp
+++ b/llvm/lib/Support/CodeGenCoverage.cpp
@@ -21,8 +21,6 @@
 
 using namespace llvm;
 
-static sys::SmartMutex<true> OutputMutex;
-
 CodeGenCoverage::CodeGenCoverage() = default;
 
 void CodeGenCoverage::setCovered(uint64_t RuleID) {
@@ -79,6 +77,7 @@ bool CodeGenCoverage::parse(MemoryBuffer &Buffer, StringRef BackendName) {
 bool CodeGenCoverage::emit(StringRef CoveragePrefix,
                            StringRef BackendName) const {
   if (!CoveragePrefix.empty() && !RuleCoverage.empty()) {
+    static sys::SmartMutex<true> OutputMutex;
     sys::SmartScopedLock<true> Lock(OutputMutex);
 
     // We can handle locking within a process easily enough but we don't want to



More information about the llvm-commits mailing list