[PATCH] D137318: [llvm-diff] Fix false-positive diffs on forward-referencing phi nodes

Jannik Silvanus via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 3 01:45:25 PDT 2022


jsilvanus created this revision.
Herald added a project: All.
jsilvanus requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

When a phi node references a variable defined in a basic block dominated
by the the basic block containing the phi node, llvm-diff currently cannot determine
whether the variable is equivalent, and thus treats the phi node as different
and reports a difference. This leads to false positive differences as demonstrated
by the loop.ll diff, for which llvm-diff reports a diff when comparing the file
with itself.

Fix that issue by adding the concept of *equivalence assumptions*.
When encountering a pair of values which can neither be proven to be equivalent
nor to be non-equivalent, instead optimistically assume equivalence, and store
somewhere that the equivalence of the currently compared basic blocks depends
on this assumption.

Later, once all BBs have been processed, check all made assumptions and report
blocks as different whose equivalence was depending on an incorrect assumption,
or an assumption we could not prove to be correct.

In order to preserve the original diff report order, also schedule diffs
of blocks already known to be different using the same mechanism, so all block
diffs are now generated at the very end of function diffing.

In case an incorrect assumption was made, all further shown equivalences between
old and new values implictly depend on the incorrect assumption. Some of these
may in fact be not equivalent, but these are neither reverted nor reported,
because they are considered indirect diffs caused by an earlier direct diff.

See inline comments for an argument why we do not run into issues caused by circular
proof dependencies.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137318

Files:
  llvm/test/tools/llvm-diff/assumption-report-order.ll
  llvm/test/tools/llvm-diff/loop.ll
  llvm/tools/llvm-diff/lib/DifferenceEngine.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137318.472872.patch
Type: text/x-patch
Size: 22153 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221103/4aacf4f8/attachment.bin>


More information about the llvm-commits mailing list