[llvm] [VecLib] Fix: Restore llvm::DebugFlag state after test. (PR #78989)

Paschalis Mpeis via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 22 06:58:13 PST 2024


https://github.com/paschalis-mpeis created https://github.com/llvm/llvm-project/pull/78989

It appears that Google Tests run multiple modules from the same invocation.
As a result setting `llvm::DebugFlag` in this pass kept it on in subsequent passes, which is not the expected behavior.

>From f96271ce83d7574e44d7a38f2ea05ab840d0d166 Mon Sep 17 00:00:00 2001
From: Paschalis Mpeis <Paschalis.Mpeis at arm.com>
Date: Mon, 22 Jan 2024 14:35:34 +0000
Subject: [PATCH] [VecLib] Fix: Restore llvm::DebugFlag state after test.

It appears that Google Tests run multiple modules from the same
invocation. As a result setting `llvm::DebugFlag` in this pass kept it
on in subsequent passes, which is not the expected behavior.
---
 llvm/unittests/Analysis/ReplaceWithVecLibTest.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/unittests/Analysis/ReplaceWithVecLibTest.cpp b/llvm/unittests/Analysis/ReplaceWithVecLibTest.cpp
index a1f0a4a894c8d1..95f17f93bf4c0b 100644
--- a/llvm/unittests/Analysis/ReplaceWithVecLibTest.cpp
+++ b/llvm/unittests/Analysis/ReplaceWithVecLibTest.cpp
@@ -72,9 +72,11 @@ class ReplaceWithVecLibTest : public ::testing::Test {
     PB.registerFunctionAnalyses(FAM);
 
     // Enable debugging and capture std error
+    bool DebugFlagPrev = llvm::DebugFlag;
     llvm::DebugFlag = true;
     testing::internal::CaptureStderr();
     FPM.run(*M->getFunction("foo"), FAM);
+    llvm::DebugFlag = DebugFlagPrev;
     return getLastLine(testing::internal::GetCapturedStderr());
   }
 };



More information about the llvm-commits mailing list