[llvm] [NFC][NewGVN] Remove the initialization of the PredicateInfo from the constructor. (PR #83937)

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 4 17:33:06 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Konstantina Mitropoulou (kmitropoulou)

<details>
<summary>Changes</summary>

The initialization of the PredicateInfo in the constructor might create problems during testing. For example, we might need to disable some functions by adding early returns in runGVN(). In this case, we will see a crash. This is due to the fact that the predicated code has already been emitted and it is not removed.

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


1 Files Affected:

- (modified) llvm/lib/Transforms/Scalar/NewGVN.cpp (+1-1) 


``````````diff
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index 19ac9526b5f88b..d57eb094151ad4 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -658,7 +658,6 @@ class NewGVN {
          TargetLibraryInfo *TLI, AliasAnalysis *AA, MemorySSA *MSSA,
          const DataLayout &DL)
       : F(F), DT(DT), TLI(TLI), AA(AA), MSSA(MSSA), AC(AC), DL(DL),
-        PredInfo(std::make_unique<PredicateInfo>(F, *DT, *AC)),
         SQ(DL, TLI, DT, AC, /*CtxI=*/nullptr, /*UseInstrInfo=*/false,
            /*CanUseUndef=*/false) {}
 
@@ -3426,6 +3425,7 @@ bool NewGVN::runGVN() {
     StartingVNCounter = DebugCounter::getCounterValue(VNCounter);
   bool Changed = false;
   NumFuncArgs = F.arg_size();
+  PredInfo = std::make_unique<PredicateInfo>(F, *DT, *AC);
   MSSAWalker = MSSA->getWalker();
   SingletonDeadExpression = new (ExpressionAllocator) DeadExpression();
 

``````````

</details>


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


More information about the llvm-commits mailing list