From b82b4339d1dded9c7e36afac80aac2ca73918e51 Mon Sep 17 00:00:00 2001 From: John McCall Date: Tue, 24 Aug 2010 09:16:51 +0000 Subject: 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111909 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-diff/DifferenceEngine.cpp | 33 +++++++++++++++++++++++++++++++++ tools/llvm-diff/llvm-diff.cpp | 4 +--- 2 files changed, 34 insertions(+), 3 deletions(-) (limited to 'tools/llvm-diff') diff --git a/tools/llvm-diff/DifferenceEngine.cpp b/tools/llvm-diff/DifferenceEngine.cpp index 7436d1ed4e..b0a24d0737 100644 --- a/tools/llvm-diff/DifferenceEngine.cpp +++ b/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(LTerm) && isa(RTerm)) { + if (cast(LTerm)->isConditional()) return; + BasicBlock::iterator I = LTerm; + if (I == LStart->getParent()->begin()) return; + --I; + if (!isa(*I)) return; + CallInst *LCall = cast(&*I); + InvokeInst *RInvoke = cast(RTerm); + if (!equivalentAsOperands(LCall->getCalledValue(), RInvoke->getCalledValue())) + return; + if (!LCall->use_empty()) + Values[LCall] = RInvoke; + tryUnify(LTerm->getSuccessor(0), RInvoke->getNormalDest()); + } else if (isa(LTerm) && isa(RTerm)) { + if (cast(RTerm)->isConditional()) return; + BasicBlock::iterator I = RTerm; + if (I == RStart->getParent()->begin()) return; + --I; + if (!isa(*I)) return; + CallInst *RCall = cast(I); + InvokeInst *LInvoke = cast(LTerm); + if (!equivalentAsOperands(LInvoke->getCalledValue(), RCall->getCalledValue())) + return; + if (!LInvoke->use_empty()) + Values[LInvoke] = RCall; + tryUnify(LInvoke->getNormalDest(), RTerm->getSuccessor(0)); + } } } diff --git a/tools/llvm-diff/llvm-diff.cpp b/tools/llvm-diff/llvm-diff.cpp index cc5d233db3..16a990fb28 100644 --- a/tools/llvm-diff/llvm-diff.cpp +++ b/tools/llvm-diff/llvm-diff.cpp @@ -75,7 +75,6 @@ struct DiffContext { }; void ComputeNumbering(Function *F, DenseMap &Numbering) { - unsigned BBN = 0; unsigned IN = 0; // Arguments get the first numbers. @@ -86,9 +85,8 @@ void ComputeNumbering(Function *F, DenseMap &Numbering) { // Walk the basic blocks in order. for (Function::iterator FI = F->begin(), FE = F->end(); FI != FE; ++FI) { - // Basic blocks have their own 'namespace'. if (!FI->hasName()) - Numbering[&*FI] = BBN++; + Numbering[&*FI] = IN++; // Walk the instructions in order. for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); BI != BE; ++BI) -- cgit v1.2.3