[llvm] Workaround -Wglobal-constructor warning. (PR #94699)
Eric Schweitz via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 6 16:37:45 PDT 2024
https://github.com/schweitzpgi created https://github.com/llvm/llvm-project/pull/94699
This line was tripping the -Wglobal-constructor warning which was causing a build failure when -Werror was turned on.
>From 452df19bf7fb5103a93b3bed418e48eac2979a25 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.
---
llvm/lib/Support/CodeGenCoverage.cpp | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Support/CodeGenCoverage.cpp b/llvm/lib/Support/CodeGenCoverage.cpp
index 4d41c42e527e2..f87cbf18ef1a5 100644
--- a/llvm/lib/Support/CodeGenCoverage.cpp
+++ b/llvm/lib/Support/CodeGenCoverage.cpp
@@ -21,7 +21,10 @@
using namespace llvm;
-static sys::SmartMutex<true> OutputMutex;
+static sys::SmartMutex<true> &OutputMutex() {
+ static sys::SmartMutex<true> mutex;
+ return mutex;
+}
CodeGenCoverage::CodeGenCoverage() = default;
@@ -79,7 +82,7 @@ bool CodeGenCoverage::parse(MemoryBuffer &Buffer, StringRef BackendName) {
bool CodeGenCoverage::emit(StringRef CoveragePrefix,
StringRef BackendName) const {
if (!CoveragePrefix.empty() && !RuleCoverage.empty()) {
- sys::SmartScopedLock<true> Lock(OutputMutex);
+ sys::SmartScopedLock<true> Lock(OutputMutex());
// We can handle locking within a process easily enough but we don't want to
// manage it between multiple processes. Use the process ID to ensure no
More information about the llvm-commits
mailing list