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

Konstantina Mitropoulou via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 4 17:32:38 PST 2024


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

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.

>From cc8b9bfc4fd7380532c7cabf62ff0ac8c2debd6b Mon Sep 17 00:00:00 2001
From: Konstantina Mitropoulou <KonstantinaMitropoulou at amd.com>
Date: Mon, 4 Mar 2024 15:02:25 -0800
Subject: [PATCH] [NFC][NewGVN] Remove the initialization of the PredicateInfo
 from the constructor.

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.
---
 llvm/lib/Transforms/Scalar/NewGVN.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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();
 



More information about the llvm-commits mailing list