[PATCH] D114211: [llvm-diff] Implement diff of PHI nodes
Bill Wendling via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 18 17:03:48 PST 2021
void created this revision.
void added reviewers: rjmccall, dblaikie, craig.topper.
void requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Implement diff of PHI nodes
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D114211
Files:
llvm/test/tools/llvm-diff/phinode.ll
llvm/tools/llvm-diff/lib/DifferenceEngine.cpp
Index: llvm/tools/llvm-diff/lib/DifferenceEngine.cpp
===================================================================
--- llvm/tools/llvm-diff/lib/DifferenceEngine.cpp
+++ llvm/tools/llvm-diff/lib/DifferenceEngine.cpp
@@ -269,15 +269,35 @@
} else if (isa<CallInst>(L)) {
return diffCallSites(cast<CallInst>(*L), cast<CallInst>(*R), Complain);
} else if (isa<PHINode>(L)) {
- // FIXME: implement.
+ const PHINode &LI = cast<PHINode>(*L);
+ const PHINode &RI = cast<PHINode>(*R);
// This is really weird; type uniquing is broken?
- if (L->getType() != R->getType()) {
- if (!L->getType()->isPointerTy() || !R->getType()->isPointerTy()) {
+ if (LI.getType() != RI.getType()) {
+ if (!LI.getType()->isPointerTy() || !RI.getType()->isPointerTy()) {
if (Complain) Engine.log("different phi types");
return true;
}
}
+
+ if (LI.getNumIncomingValues() != RI.getNumIncomingValues()) {
+ if (Complain)
+ Engine.log("PHI node # of incoming values differ");
+ return true;
+ }
+
+ for (unsigned I = 0; I < LI.getNumIncomingValues(); ++I) {
+ if (TryUnify)
+ tryUnify(LI.getIncomingBlock(I), RI.getIncomingBlock(I));
+
+ if (!equivalentAsOperands(LI.getIncomingValue(I),
+ RI.getIncomingValue(I))) {
+ if (Complain)
+ Engine.log("PHI node incoming values differ");
+ return true;
+ }
+ }
+
return false;
// Terminators.
Index: llvm/test/tools/llvm-diff/phinode.ll
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-diff/phinode.ll
@@ -0,0 +1,20 @@
+; RUN: llvm-diff %s %s
+
+define i32 @foo(i32 %0) #0 {
+ callbr void asm sideeffect "", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@foo, %6))
+ to label %2 [label %6]
+
+2:
+ %3 = icmp eq i32 %0, 0
+ br i1 %3, label %6, label %4
+
+4:
+ br label %5
+
+5:
+ br label %5
+
+6:
+ %7 = phi i32 [ 0, %2 ], [ -1, %1 ]
+ ret i32 %7
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114211.388357.patch
Type: text/x-patch
Size: 2098 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211119/1315b959/attachment.bin>
More information about the llvm-commits
mailing list