From: Chris Lattner Date: Tue, 8 Dec 2009 06:06:26 +0000 (+0000) Subject: fix a typo (and -> add) and fix GetAvailablePHITranslatedSubExpr to not X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=34f849098bfb8850fa34fbd115ba9b2e55c85a32;p=oota-llvm.git fix a typo (and -> add) and fix GetAvailablePHITranslatedSubExpr to not side-effect the current object. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90837 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Analysis/PHITransAddr.h b/include/llvm/Analysis/PHITransAddr.h index 678d40561e8..1f4f3416da8 100644 --- a/include/llvm/Analysis/PHITransAddr.h +++ b/include/llvm/Analysis/PHITransAddr.h @@ -88,7 +88,7 @@ private: /// PHITranslateSubExpr if it dominates PredBB, otherwise return null. Value *GetAvailablePHITranslatedSubExpr(Value *V, BasicBlock *CurBB, BasicBlock *PredBB, - const DominatorTree &DT); + const DominatorTree &DT) const; /// InsertPHITranslatedSubExpr - Insert a computation of the PHI translated /// version of 'V' for the edge PredBB->CurBB into the end of the PredBB diff --git a/lib/Analysis/PHITransAddr.cpp b/lib/Analysis/PHITransAddr.cpp index bb95926c526..98cea9bb4bd 100644 --- a/lib/Analysis/PHITransAddr.cpp +++ b/lib/Analysis/PHITransAddr.cpp @@ -22,7 +22,7 @@ static bool CanPHITrans(Instruction *Inst) { isa(Inst)) return true; - if (Inst->getOpcode() == Instruction::And && + if (Inst->getOpcode() == Instruction::Add && isa(Inst->getOperand(1))) return true; @@ -205,9 +205,12 @@ bool PHITransAddr::PHITranslateValue(BasicBlock *CurBB, BasicBlock *PredBB) { /// PHITranslateSubExpr if it dominates PredBB, otherwise return null. Value *PHITransAddr:: GetAvailablePHITranslatedSubExpr(Value *V, BasicBlock *CurBB,BasicBlock *PredBB, - const DominatorTree &DT) { + const DominatorTree &DT) const { + PHITransAddr Tmp(V, TD); + Tmp.PHITranslateValue(CurBB, PredBB); + // See if PHI translation succeeds. - V = PHITranslateSubExpr(V, CurBB, PredBB); + V = Tmp.getAddr(); // Make sure the value is live in the predecessor. if (Instruction *Inst = dyn_cast_or_null(V))