[PATCH] D141156: Merge lines in print-changed by showing simple changes in place in the line

Jamie Schmeiser via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 11 07:51:16 PST 2023


jamieschmeiser added a comment.

This will show some of the differences:
int f() {

  unsigned total = 0;
  for (unsigned i = 0; i < 5; ++i)
    total += i;
  return total;

}

int main() {

  return f();

}
-

clang -mllvm -print-changed=cdiff-quiet -emit-llvm -O2 test.C -c
----------------------------------------------------------------

Look for lines that have a * at the front.  It shows better in colour.  I originally had it limited to cdiff and dot-cfg, but then added the * to make it easier to spot in diff and cdiff (also helps if using grep -e "^\*" -e "^+"-e "^-")

- IR Dump After SimplifyCFGPass on _Z1fv ***

...
*for.cond:                                         ; preds = -%for.inc+%for.body, %entry
...
 for.body:                                         ; preds = %for.cond

- -%1+%2 = load i32, ptr %i, align 4, !tbaa !5
- -%2+%3 = load i32, ptr %total, align 4, !tbaa !5
- %add = add i32 -%2+%3, -%1+%2

Normally, for.body would have 3 red (delete) lines, followed by 3 green (add) lines and the first thing I would do is compare all of the text in the lines, trying to identify that everything other the unnamed variables was unchanged.
The example shows that when an unnamed variable is added or deleted, it has a ripple effect and such changes are easier to spot.  Also, changes to just the attributes will also be displayed in a similar manner (eg: -!6+!7).  I find it means I don't have to compare lines token by token to recognize simple changes.  It also makes it a little more compact.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141156/new/

https://reviews.llvm.org/D141156



More information about the llvm-commits mailing list