X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=tools%2Fllvm-diff%2FDifferenceEngine.cpp;h=456560b093aba55fdaeadbceb7f0ceb42ad2e1c1;hb=543e02b4381244c28463696f159170004c787628;hp=3cf178e7f169cb9fe6cbf2a30329d60656abdb54;hpb=7d4fc4fb345ee8a1de15c718a854b5f38c1e6e46;p=oota-llvm.git diff --git a/tools/llvm-diff/DifferenceEngine.cpp b/tools/llvm-diff/DifferenceEngine.cpp index 3cf178e7f16..456560b093a 100644 --- a/tools/llvm-diff/DifferenceEngine.cpp +++ b/tools/llvm-diff/DifferenceEngine.cpp @@ -13,21 +13,20 @@ //===----------------------------------------------------------------------===// #include "DifferenceEngine.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/Support/CFG.h" +#include "llvm/IR/CFG.h" +#include "llvm/IR/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/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/type_traits.h" - #include using namespace llvm; @@ -194,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 @@ -266,7 +263,7 @@ class FunctionDifferenceEngine { } else if (isa(L)) { // FIXME: implement. - // This is really wierd; type uniquing is broken? + // This is really weird; type uniquing is broken? if (L->getType() != R->getType()) { if (!L->getType()->isPointerTy() || !R->getType()->isPointerTy()) { if (Complain) Engine.log("different phi types"); @@ -318,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; @@ -598,7 +599,7 @@ void FunctionDifferenceEngine::runBlockDiff(BasicBlock::iterator LStart, TerminatorInst *RTerm = RStart->getParent()->getTerminator(); if (isa(LTerm) && isa(RTerm)) { if (cast(LTerm)->isConditional()) return; - BasicBlock::iterator I = LTerm; + BasicBlock::iterator I = LTerm->getIterator(); if (I == LStart->getParent()->begin()) return; --I; if (!isa(*I)) return; @@ -611,7 +612,7 @@ void FunctionDifferenceEngine::runBlockDiff(BasicBlock::iterator LStart, tryUnify(LTerm->getSuccessor(0), RInvoke->getNormalDest()); } else if (isa(LTerm) && isa(RTerm)) { if (cast(RTerm)->isConditional()) return; - BasicBlock::iterator I = RTerm; + BasicBlock::iterator I = RTerm->getIterator(); if (I == RStart->getParent()->begin()) return; --I; if (!isa(*I)) return; @@ -627,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);