From cf56b08d15b6fe4c8b87569529e1d220baf44aea Mon Sep 17 00:00:00 2001 From: Andrew Litteken Date: Mon, 30 Aug 2021 08:34:25 -0700 Subject: [PATCH] [IRSim] Adding missing comments canonical relation commit Adding missing comments to IRSimilarityIdentifier.cpp since they were not properly added in commit 063af63b9664151b3a9206feefa9a6a36a471e80. --- llvm/lib/Analysis/IRSimilarityIdentifier.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp index 99785a3ec53e..033aa2184b81 100644 --- a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp +++ b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp @@ -759,14 +759,19 @@ void IRSimilarityCandidate::createCanonicalRelationFrom( assert(NumberToCanonNum.size() == 0 && "Canonical Relationship is non-empty"); DenseSet UsedGVNs; - // Iterate over the mappings provided from this candidate to A. + // Iterate over the mappings provided from this candidate to SourceCand. We + // are then able to map the GVN in this candidate to the same canonical number + // given to the corresponding GVN in SourceCand. for (std::pair> &GVNMapping : ToSourceMapping) { unsigned SourceGVN = GVNMapping.first; assert(GVNMapping.second.size() != 0 && "Possible GVNs is 0!"); unsigned ResultGVN; - // We need special handling if we have more than one potential value. + // We need special handling if we have more than one potential value. This + // means that there are at least two GVNs that could correspond to this GVN. + // This could lead to potential swapping later on, so we make a decision + // here to ensure a one-to-one mapping. if (GVNMapping.second.size() > 1) { bool Found = false; for (unsigned Val : GVNMapping.second) {