When propagating equalities, eg replacing A with B in every basic block
authorDuncan Sands <baldrick@free.fr>
Fri, 23 Mar 2012 08:45:52 +0000 (08:45 +0000)
committerDuncan Sands <baldrick@free.fr>
Fri, 23 Mar 2012 08:45:52 +0000 (08:45 +0000)
dominated by Root, check that B is available throughout the scope.  This
is obviously true (famous last words?) given the current logic, but the
check may be helpful if more complicated reasoning is added one day.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153323 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/GVN.cpp

index ac80c489f9627edc851e0b2535d35d9dfd582a9a..8b79d27b952161b10d1c5f13ba80892ffa069dca 100644 (file)
@@ -2001,6 +2001,9 @@ bool GVN::propagateEquality(Value *LHS, Value *RHS, BasicBlock *Root) {
       LVN = RVN;
     }
   }
+  assert((!isa<Instruction>(RHS) ||
+          DT->properlyDominates(cast<Instruction>(RHS)->getParent(), Root)) &&
+         "Instruction doesn't dominate scope!");
 
   // If value numbering later deduces that an instruction in the scope is equal
   // to 'LHS' then ensure it will be turned into 'RHS'.