Skip to content

Commit 38d3864

Browse files
authored
Merge pull request #63868 from meg-gupta/cseassert
Ensure isEqual and getHashValue() are in sync with an invariant in CSE
2 parents ce24ad3 + a0d1b08 commit 38d3864

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/SILOptimizer/Transforms/CSE.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,20 @@ bool llvm::DenseMapInfo<SimpleValue>::isEqual(SimpleValue LHS,
564564
return true;
565565
return false;
566566
};
567-
return LHSI->getKind() == RHSI->getKind() && LHSI->isIdenticalTo(RHSI, opCmp);
567+
bool isEqual =
568+
LHSI->getKind() == RHSI->getKind() && LHSI->isIdenticalTo(RHSI, opCmp);
569+
#ifdef NDEBUG
570+
if (isEqual && getHashValue(LHS) != getHashValue(RHS)) {
571+
llvm::dbgs() << "LHS: ";
572+
LHSI->dump();
573+
llvm::dbgs() << "RHS: ";
574+
RHSI->dump();
575+
llvm::dbgs() << "In function:\n";
576+
LHSI->getFunction()->dump();
577+
llvm_unreachable("Mismatched isEqual and getHashValue() function in CSE\n");
578+
}
579+
#endif
580+
return isEqual;
568581
}
569582

570583
namespace {

0 commit comments

Comments
 (0)