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

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-analysis

Author: Paschalis Mpeis (paschalis-mpeis)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/78989.diff


1 Files Affected:

- (modified) llvm/unittests/Analysis/ReplaceWithVecLibTest.cpp (+2) 


``````````diff
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());
   }
 };

``````````

</details>


https://github.com/llvm/llvm-project/pull/78989


More information about the llvm-commits mailing list