summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-diff/DifferenceEngine.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-08-24 09:16:51 +0000
committerJohn McCall <rjmccall@apple.com>2010-08-24 09:16:51 +0000
commit5ee026c51237d9c96051523a0daad264dd328cfa (patch)
treeac71563a4eff95afa50e613f33b954a467c9f851 /llvm/tools/llvm-diff/DifferenceEngine.cpp
parentc5990644b05c573772a730ff1a34cb6108a58c60 (diff)
downloadbcm5719-llvm-5ee026c51237d9c96051523a0daad264dd328cfa.tar.gz
bcm5719-llvm-5ee026c51237d9c96051523a0daad264dd328cfa.zip
Check in a couple of changes that I apparently never committed:
- teach DifferenceEngine to unify successors of calls and invokes in certain circumstances - basic blocks actually don't have their own numbering; did that change? - add llvm-diff to the Makefile and CMake build systems llvm-svn: 111909
Diffstat (limited to 'llvm/tools/llvm-diff/DifferenceEngine.cpp')
-rw-r--r--llvm/tools/llvm-diff/DifferenceEngine.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/llvm/tools/llvm-diff/DifferenceEngine.cpp b/llvm/tools/llvm-diff/DifferenceEngine.cpp
index 7436d1ed4e3..b0a24d0737e 100644
--- a/llvm/tools/llvm-diff/DifferenceEngine.cpp
+++ b/llvm/tools/llvm-diff/DifferenceEngine.cpp
@@ -590,6 +590,39 @@ void FunctionDifferenceEngine::runBlockDiff(BasicBlock::iterator LStart,
unify(&*LI, &*RI);
++LI, ++RI;
}
+
+ // If the terminators have different kinds, but one is an invoke and the
+ // other is an unconditional branch immediately following a call, unify
+ // the results and the destinations.
+ TerminatorInst *LTerm = LStart->getParent()->getTerminator();
+ TerminatorInst *RTerm = RStart->getParent()->getTerminator();
+ if (isa<BranchInst>(LTerm) && isa<InvokeInst>(RTerm)) {
+ if (cast<BranchInst>(LTerm)->isConditional()) return;
+ BasicBlock::iterator I = LTerm;
+ if (I == LStart->getParent()->begin()) return;
+ --I;
+ if (!isa<CallInst>(*I)) return;
+ CallInst *LCall = cast<CallInst>(&*I);
+ InvokeInst *RInvoke = cast<InvokeInst>(RTerm);
+ if (!equivalentAsOperands(LCall->getCalledValue(), RInvoke->getCalledValue()))
+ return;
+ if (!LCall->use_empty())
+ Values[LCall] = RInvoke;
+ tryUnify(LTerm->getSuccessor(0), RInvoke->getNormalDest());
+ } else if (isa<InvokeInst>(LTerm) && isa<BranchInst>(RTerm)) {
+ if (cast<BranchInst>(RTerm)->isConditional()) return;
+ BasicBlock::iterator I = RTerm;
+ if (I == RStart->getParent()->begin()) return;
+ --I;
+ if (!isa<CallInst>(*I)) return;
+ CallInst *RCall = cast<CallInst>(I);
+ InvokeInst *LInvoke = cast<InvokeInst>(LTerm);
+ if (!equivalentAsOperands(LInvoke->getCalledValue(), RCall->getCalledValue()))
+ return;
+ if (!LInvoke->use_empty())
+ Values[LInvoke] = RCall;
+ tryUnify(LInvoke->getNormalDest(), RTerm->getSuccessor(0));
+ }
}
}
OpenPOWER on IntegriCloud