[llvm] c1ae72d - [IR] Revert r119493

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Tue May 19 05:17:24 PDT 2020


Author: Jay Foad
Date: 2020-05-19T13:17:11+01:00
New Revision: c1ae72d03f71bb0a4cf7c39ce5ffe3dbc8b96514

URL: https://github.com/llvm/llvm-project/commit/c1ae72d03f71bb0a4cf7c39ce5ffe3dbc8b96514
DIFF: https://github.com/llvm/llvm-project/commit/c1ae72d03f71bb0a4cf7c39ce5ffe3dbc8b96514.diff

LOG: [IR] Revert r119493

r119493 protected against PHINode::hasConstantValue returning the PHI
node itself, but a later fix in r159687 means that can never happen, so
the workarounds are no longer required.

Added: 
    

Modified: 
    llvm/lib/Analysis/Lint.cpp
    llvm/lib/IR/BasicBlock.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/Lint.cpp b/llvm/lib/Analysis/Lint.cpp
index 30a0846d2af8..1c34fc43dade 100644
--- a/llvm/lib/Analysis/Lint.cpp
+++ b/llvm/lib/Analysis/Lint.cpp
@@ -691,8 +691,7 @@ Value *Lint::findValueImpl(Value *V, bool OffsetOk,
     }
   } else if (PHINode *PN = dyn_cast<PHINode>(V)) {
     if (Value *W = PN->hasConstantValue())
-      if (W != V)
-        return findValueImpl(W, OffsetOk, Visited);
+      return findValueImpl(W, OffsetOk, Visited);
   } else if (CastInst *CI = dyn_cast<CastInst>(V)) {
     if (CI->isNoopCast(*DL))
       return findValueImpl(CI->getOperand(0), OffsetOk, Visited);

diff  --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index 4baf36839c6e..a9fa7cae92d8 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -368,11 +368,10 @@ void BasicBlock::removePredecessor(BasicBlock *Pred,
       // If all incoming values to the Phi are the same, we can replace the Phi
       // with that value.
       Value* PNV = nullptr;
-      if (!KeepOneInputPHIs && (PNV = PN->hasConstantValue()))
-        if (PNV != PN) {
-          PN->replaceAllUsesWith(PNV);
-          PN->eraseFromParent();
-        }
+      if (!KeepOneInputPHIs && (PNV = PN->hasConstantValue())) {
+        PN->replaceAllUsesWith(PNV);
+        PN->eraseFromParent();
+      }
     }
   }
 }


        


More information about the llvm-commits mailing list