[llvm] 0b12839 - [llvm-diff] Respect AllowAssumptions in diffCallSites (#203597)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 12 12:22:11 PDT 2026
Author: lijinpei-amd
Date: 2026-06-12T21:22:06+02:00
New Revision: 0b128394b9c796ebe4efd9e0dde38976fb291798
URL: https://github.com/llvm/llvm-project/commit/0b128394b9c796ebe4efd9e0dde38976fb291798
DIFF: https://github.com/llvm/llvm-project/commit/0b128394b9c796ebe4efd9e0dde38976fb291798.diff
LOG: [llvm-diff] Respect AllowAssumptions in diffCallSites (#203597)
diffCallSites always built an AssumptionContext, so call sites made
optimistic equivalence assumptions even when the caller disabled them.
This made matchForBlockDiff over-match, and the re-check in unify() then
hit the "structural differences second time around?" assertion.
Thread the caller's AssumptionContext into diffCallSites so call sites
honor the no-assumptions request like every other instruction kind.
Fixes #184133
Added:
llvm/test/tools/llvm-diff/callsite-assumption-passing.ll
Modified:
llvm/tools/llvm-diff/lib/DifferenceEngine.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-
diff /callsite-assumption-passing.ll b/llvm/test/tools/llvm-
diff /callsite-assumption-passing.ll
new file mode 100644
index 0000000000000..b7531877e5f93
--- /dev/null
+++ b/llvm/test/tools/llvm-
diff /callsite-assumption-passing.ll
@@ -0,0 +1,33 @@
+; RUN: split-file %s %t
+; RUN: not llvm-
diff %t/a.ll %t/b.ll 2>&1 | FileCheck %s
+
+; Regression test for https://github.com/llvm/llvm-project/issues/184133
+
+; CHECK: in function func:
+; CHECK-NEXT: in block %0 / %0:
+; CHECK-NEXT: > %c = call double @h()
+; CHECK-NEXT: > %b = call double @g(double %c)
+; CHECK-NEXT: > ret double %b
+; CHECK-NEXT: < %b = call double @g(double %a)
+; CHECK-NEXT: < ret double %b
+; CHECK-NOT: second time around
+
+;--- a.ll
+define double @func() {
+ %a = call double @f()
+ %b = call double @g(double %a)
+ ret double %b
+}
+declare double @f()
+declare double @g(double)
+
+;--- b.ll
+define double @func() {
+ %a = call double @f()
+ %c = call double @h()
+ %b = call double @g(double %c)
+ ret double %b
+}
+declare double @f()
+declare double @h()
+declare double @g(double)
diff --git a/llvm/tools/llvm-
diff /lib/DifferenceEngine.cpp b/llvm/tools/llvm-
diff /lib/DifferenceEngine.cpp
index 7226eb4d159e3..8b123049fcdb3 100644
--- a/llvm/tools/llvm-
diff /lib/DifferenceEngine.cpp
+++ b/llvm/tools/llvm-
diff /lib/DifferenceEngine.cpp
@@ -339,11 +339,10 @@ class FunctionDifferenceEngine {
void runBlockDiff(BasicBlock::const_iterator LI,
BasicBlock::const_iterator RI);
- bool
diff CallSites(const CallBase &L, const CallBase &R, bool Complain) {
+ bool
diff CallSites(const CallBase &L, const CallBase &R, bool Complain,
+ const AssumptionContext *AC) {
// FIXME: call attributes
- AssumptionContext AC = {L.getParent(), R.getParent()};
- if (!equivalentAsOperands(L.getCalledOperand(), R.getCalledOperand(),
- &AC)) {
+ if (!equivalentAsOperands(L.getCalledOperand(), R.getCalledOperand(), AC)) {
if (Complain) Engine.log("called functions
diff er");
return true;
}
@@ -352,7 +351,7 @@ class FunctionDifferenceEngine {
return true;
}
for (unsigned I = 0, E = L.arg_size(); I != E; ++I)
- if (!equivalentAsOperands(L.getArgOperand(I), R.getArgOperand(I), &AC)) {
+ if (!equivalentAsOperands(L.getArgOperand(I), R.getArgOperand(I), AC)) {
if (Complain)
Engine.logf("arguments %l and %r
diff er")
<< L.getArgOperand(I) << R.getArgOperand(I);
@@ -384,7 +383,8 @@ class FunctionDifferenceEngine {
return true;
}
} else if (isa<CallInst>(L)) {
- return
diff CallSites(cast<CallInst>(*L), cast<CallInst>(*R), Complain);
+ return
diff CallSites(cast<CallInst>(*L), cast<CallInst>(*R), Complain,
+ AC);
} else if (isa<PHINode>(L)) {
const PHINode &LI = cast<PHINode>(*L);
const PHINode &RI = cast<PHINode>(*R);
@@ -421,7 +421,7 @@ class FunctionDifferenceEngine {
} else if (isa<InvokeInst>(L)) {
const InvokeInst &LI = cast<InvokeInst>(*L);
const InvokeInst &RI = cast<InvokeInst>(*R);
- if (
diff CallSites(LI, RI, Complain))
+ if (
diff CallSites(LI, RI, Complain, AC))
return true;
if (TryUnify) {
@@ -444,7 +444,7 @@ class FunctionDifferenceEngine {
for (unsigned I = 0; I < LI.getNumIndirectDests(); I++)
tryUnify(LI.getIndirectDest(I), RI.getIndirectDest(I));
- if (
diff CallSites(LI, RI, Complain))
+ if (
diff CallSites(LI, RI, Complain, AC))
return true;
if (TryUnify)
More information about the llvm-commits
mailing list