X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=tools%2Fllvm-diff%2FDifferenceEngine.cpp;h=768b94b6907134926b2c806d51e2c30da2054249;hb=5be77762a3aa434ee877b0a03b98b5c3a7571918;hp=ba2cec2992554bbd942207b283658bb115fc9394;hpb=7a2bdde0a0eebcd2125055e0eacaca040f0b766c;p=oota-llvm.git diff --git a/tools/llvm-diff/DifferenceEngine.cpp b/tools/llvm-diff/DifferenceEngine.cpp index ba2cec29925..768b94b6907 100644 --- a/tools/llvm-diff/DifferenceEngine.cpp +++ b/tools/llvm-diff/DifferenceEngine.cpp @@ -13,22 +13,20 @@ //===----------------------------------------------------------------------===// #include "DifferenceEngine.h" - -#include "llvm/Constants.h" -#include "llvm/Function.h" -#include "llvm/Instructions.h" -#include "llvm/Module.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSet.h" -#include "llvm/Support/CallSite.h" +#include "llvm/IR/Constants.h" +#include "llvm/IR/Function.h" +#include "llvm/IR/Instructions.h" +#include "llvm/IR/Module.h" #include "llvm/Support/CFG.h" +#include "llvm/Support/CallSite.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/type_traits.h" - #include using namespace llvm; @@ -195,12 +193,10 @@ class FunctionDifferenceEngine { DifferenceEngine::Context C(Engine, L, R); BasicBlock::iterator LI = L->begin(), LE = L->end(); - BasicBlock::iterator RI = R->begin(), RE = R->end(); - - llvm::SmallVector, 20> TentativePairs; + BasicBlock::iterator RI = R->begin(); do { - assert(LI != LE && RI != RE); + assert(LI != LE && RI != R->end()); Instruction *LeftI = &*LI, *RightI = &*RI; // If the instructions differ, start the more sophisticated diff @@ -319,15 +315,19 @@ class FunctionDifferenceEngine { bool Difference = false; DenseMap LCases; - for (unsigned I = 1, E = LI->getNumCases(); I != E; ++I) - LCases[LI->getCaseValue(I)] = LI->getSuccessor(I); - for (unsigned I = 1, E = RI->getNumCases(); I != E; ++I) { - ConstantInt *CaseValue = RI->getCaseValue(I); + + for (SwitchInst::CaseIt I = LI->case_begin(), E = LI->case_end(); + I != E; ++I) + LCases[I.getCaseValue()] = I.getCaseSuccessor(); + + for (SwitchInst::CaseIt I = RI->case_begin(), E = RI->case_end(); + I != E; ++I) { + ConstantInt *CaseValue = I.getCaseValue(); BasicBlock *LCase = LCases[CaseValue]; if (LCase) { - if (TryUnify) tryUnify(LCase, RI->getSuccessor(I)); + if (TryUnify) tryUnify(LCase, I.getCaseSuccessor()); LCases.erase(CaseValue); - } else if (!Difference) { + } else if (Complain || !Difference) { if (Complain) Engine.logf("right switch has extra case %r") << CaseValue; Difference = true; @@ -628,6 +628,8 @@ void FunctionDifferenceEngine::runBlockDiff(BasicBlock::iterator LStart, } +void DifferenceEngine::Oracle::anchor() { } + void DifferenceEngine::diff(Function *L, Function *R) { Context C(*this, L, R);