mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-21 18:29:46 +00:00
Enhance InsertPHITranslatedPointer to be able to return a list of newly
inserted instructions. No functionality change until someone starts using it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90039 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ab9530ee5d
commit
dd696052f0
@ -261,11 +261,12 @@ namespace llvm {
|
||||
|
||||
/// InsertPHITranslatedPointer - Insert a computation of the PHI translated
|
||||
/// version of 'V' for the edge PredBB->CurBB into the end of the PredBB
|
||||
/// block.
|
||||
/// block. All newly created instructions are added to the NewInsts list.
|
||||
Value *InsertPHITranslatedPointer(Value *V,
|
||||
BasicBlock *CurBB, BasicBlock *PredBB,
|
||||
const TargetData *TD,
|
||||
const DominatorTree &DT) const;
|
||||
const DominatorTree &DT,
|
||||
SmallVectorImpl<Instruction*> &NewInsts) const;
|
||||
|
||||
/// removeInstruction - Remove an instruction from the dependence analysis,
|
||||
/// updating the dependence of instructions that previously depended on it.
|
||||
|
@ -879,14 +879,13 @@ GetAvailablePHITranslatedValue(Value *V,
|
||||
|
||||
/// InsertPHITranslatedPointer - Insert a computation of the PHI translated
|
||||
/// version of 'V' for the edge PredBB->CurBB into the end of the PredBB
|
||||
/// block.
|
||||
/// block. All newly created instructions are added to the NewInsts list.
|
||||
///
|
||||
/// This is only called when PHITranslatePointer returns a value that doesn't
|
||||
/// dominate the block, so we don't need to handle the trivial cases here.
|
||||
Value *MemoryDependenceAnalysis::
|
||||
InsertPHITranslatedPointer(Value *InVal, BasicBlock *CurBB,
|
||||
BasicBlock *PredBB, const TargetData *TD,
|
||||
const DominatorTree &DT) const {
|
||||
const DominatorTree &DT,
|
||||
SmallVectorImpl<Instruction*> &NewInsts) const {
|
||||
// See if we have a version of this value already available and dominating
|
||||
// PredBB. If so, there is no need to insert a new copy.
|
||||
if (Value *Res = GetAvailablePHITranslatedValue(InVal, CurBB, PredBB, TD, DT))
|
||||
@ -899,13 +898,15 @@ InsertPHITranslatedPointer(Value *InVal, BasicBlock *CurBB,
|
||||
// Handle bitcast of PHI translatable value.
|
||||
if (BitCastInst *BC = dyn_cast<BitCastInst>(Inst)) {
|
||||
Value *OpVal = InsertPHITranslatedPointer(BC->getOperand(0),
|
||||
CurBB, PredBB, TD, DT);
|
||||
CurBB, PredBB, TD, DT, NewInsts);
|
||||
if (OpVal == 0) return 0;
|
||||
|
||||
// Otherwise insert a bitcast at the end of PredBB.
|
||||
return new BitCastInst(OpVal, InVal->getType(),
|
||||
InVal->getName()+".phi.trans.insert",
|
||||
PredBB->getTerminator());
|
||||
BitCastInst *New = new BitCastInst(OpVal, InVal->getType(),
|
||||
InVal->getName()+".phi.trans.insert",
|
||||
PredBB->getTerminator());
|
||||
NewInsts.push_back(New);
|
||||
return New;
|
||||
}
|
||||
|
||||
// Handle getelementptr with at least one PHI operand.
|
||||
@ -914,7 +915,7 @@ InsertPHITranslatedPointer(Value *InVal, BasicBlock *CurBB,
|
||||
BasicBlock *CurBB = GEP->getParent();
|
||||
for (unsigned i = 0, e = GEP->getNumOperands(); i != e; ++i) {
|
||||
Value *OpVal = InsertPHITranslatedPointer(GEP->getOperand(i),
|
||||
CurBB, PredBB, TD, DT);
|
||||
CurBB, PredBB, TD, DT, NewInsts);
|
||||
if (OpVal == 0) return 0;
|
||||
GEPOps.push_back(OpVal);
|
||||
}
|
||||
@ -924,6 +925,7 @@ InsertPHITranslatedPointer(Value *InVal, BasicBlock *CurBB,
|
||||
InVal->getName()+".phi.trans.insert",
|
||||
PredBB->getTerminator());
|
||||
Result->setIsInBounds(GEP->isInBounds());
|
||||
NewInsts.push_back(Result);
|
||||
return Result;
|
||||
}
|
||||
|
||||
@ -937,7 +939,7 @@ InsertPHITranslatedPointer(Value *InVal, BasicBlock *CurBB,
|
||||
isa<ConstantInt>(Inst->getOperand(1))) {
|
||||
// PHI translate the LHS.
|
||||
Value *OpVal = InsertPHITranslatedPointer(Inst->getOperand(0),
|
||||
CurBB, PredBB, TD, DT);
|
||||
CurBB, PredBB, TD, DT, NewInsts);
|
||||
if (OpVal == 0) return 0;
|
||||
|
||||
BinaryOperator *Res = BinaryOperator::CreateAdd(OpVal, Inst->getOperand(1),
|
||||
@ -945,6 +947,7 @@ InsertPHITranslatedPointer(Value *InVal, BasicBlock *CurBB,
|
||||
PredBB->getTerminator());
|
||||
Res->setHasNoSignedWrap(cast<BinaryOperator>(Inst)->hasNoSignedWrap());
|
||||
Res->setHasNoUnsignedWrap(cast<BinaryOperator>(Inst)->hasNoUnsignedWrap());
|
||||
NewInsts.push_back(Res);
|
||||
return Res;
|
||||
}
|
||||
#endif
|
||||
|
@ -1437,10 +1437,11 @@ bool GVN::processNonLocalLoad(LoadInst *LI,
|
||||
//
|
||||
// FIXME: This may insert a computation, but we don't tell scalar GVN
|
||||
// optimization stuff about it. How do we do this?
|
||||
SmallVector<Instruction*, 8> NewInsts;
|
||||
#if 0
|
||||
Value *LoadPtr =
|
||||
MD->InsertPHITranslatedPointer(LI->getOperand(0), LoadBB,
|
||||
UnavailablePred, TD, *DT);
|
||||
UnavailablePred, TD, *DT, NewInsts);
|
||||
#else
|
||||
Value *LoadPtr =
|
||||
MD->GetAvailablePHITranslatedValue(LI->getOperand(0), LoadBB,
|
||||
@ -1465,6 +1466,7 @@ bool GVN::processNonLocalLoad(LoadInst *LI,
|
||||
// we do not have this case. Otherwise, check that the load is safe to
|
||||
// put anywhere; this can be improved, but should be conservatively safe.
|
||||
if (!allSingleSucc &&
|
||||
// FIXME: REEVALUTE THIS.
|
||||
!isSafeToLoadUnconditionally(LoadPtr, UnavailablePred->getTerminator()))
|
||||
return false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user