Rename SILCloner doPostProcess and foldValue to recordClonedInstruction and recordFoldedValue.

This commit is contained in:
Andrew Trick
2018-10-10 18:01:12 -07:00
parent c781d78782
commit 9e440d13a6
5 changed files with 690 additions and 734 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -135,7 +135,8 @@ public:
using SILClonerWithScopes<ImplClass>::getTypeInClonedContext; using SILClonerWithScopes<ImplClass>::getTypeInClonedContext;
using SILClonerWithScopes<ImplClass>::getOpType; using SILClonerWithScopes<ImplClass>::getOpType;
using SILClonerWithScopes<ImplClass>::getOpBasicBlock; using SILClonerWithScopes<ImplClass>::getOpBasicBlock;
using SILClonerWithScopes<ImplClass>::doPostProcess; using SILClonerWithScopes<ImplClass>::recordClonedInstruction;
using SILClonerWithScopes<ImplClass>::recordFoldedValue;
using SILClonerWithScopes<ImplClass>::addBlockWithUnreachable; using SILClonerWithScopes<ImplClass>::addBlockWithUnreachable;
using SILClonerWithScopes<ImplClass>::OpenedArchetypesTracker; using SILClonerWithScopes<ImplClass>::OpenedArchetypesTracker;
@@ -192,7 +193,7 @@ protected:
Helper.getArguments(), Inst->isNonThrowing(), Helper.getArguments(), Inst->isNonThrowing(),
GenericSpecializationInformation::create( GenericSpecializationInformation::create(
Inst, getBuilder())); Inst, getBuilder()));
doPostProcess(Inst, N); recordClonedInstruction(Inst, N);
} }
void visitTryApplyInst(TryApplyInst *Inst) { void visitTryApplyInst(TryApplyInst *Inst) {
@@ -204,7 +205,7 @@ protected:
getOpBasicBlock(Inst->getErrorBB()), getOpBasicBlock(Inst->getErrorBB()),
GenericSpecializationInformation::create( GenericSpecializationInformation::create(
Inst, getBuilder())); Inst, getBuilder()));
doPostProcess(Inst, N); recordClonedInstruction(Inst, N);
} }
void visitPartialApplyInst(PartialApplyInst *Inst) { void visitPartialApplyInst(PartialApplyInst *Inst) {
@@ -216,7 +217,7 @@ protected:
Helper.getSubstitutions(), Helper.getArguments(), ParamConvention, Helper.getSubstitutions(), Helper.getArguments(), ParamConvention,
GenericSpecializationInformation::create( GenericSpecializationInformation::create(
Inst, getBuilder())); Inst, getBuilder()));
doPostProcess(Inst, N); recordClonedInstruction(Inst, N);
} }
/// Attempt to simplify a conditional checked cast. /// Attempt to simplify a conditional checked cast.
@@ -257,7 +258,7 @@ protected:
// there is no need for an upcast and we can just use the operand. // there is no need for an upcast and we can just use the operand.
if (getOpType(Upcast->getType()) == if (getOpType(Upcast->getType()) ==
getOpValue(Upcast->getOperand())->getType()) { getOpValue(Upcast->getOperand())->getType()) {
super::foldValue(SILValue(Upcast), getOpValue(Upcast->getOperand())); recordFoldedValue(SILValue(Upcast), getOpValue(Upcast->getOperand()));
return; return;
} }
super::visitUpcastInst(Upcast); super::visitUpcastInst(Upcast);
@@ -267,7 +268,7 @@ protected:
// If the substituted type is trivial, ignore the copy. // If the substituted type is trivial, ignore the copy.
SILType copyTy = getOpType(Copy->getType()); SILType copyTy = getOpType(Copy->getType());
if (copyTy.isTrivial(Copy->getModule())) { if (copyTy.isTrivial(Copy->getModule())) {
super::foldValue(SILValue(Copy), getOpValue(Copy->getOperand())); recordFoldedValue(SILValue(Copy), getOpValue(Copy->getOperand()));
return; return;
} }
super::visitCopyValueInst(Copy); super::visitCopyValueInst(Copy);

View File

@@ -376,10 +376,10 @@ public:
auto *BlockArg = DestBB->createPhiArgument( auto *BlockArg = DestBB->createPhiArgument(
DestPHIArg->getType(), DestPHIArg->getOwnershipKind()); DestPHIArg->getType(), DestPHIArg->getOwnershipKind());
// Since we don't call any CFG cloning entry point, we can call // Since we don't call any CFG cloning entry point, we can call
// `foldValue` immediately as if cloning has already started. This simply // `recordFoldedValue` immediately as if cloning has already started. This
// avoids handling AvailVals during `remap` or defining a custom // simply avoids handling AvailVals during `remap` or defining a custom
// visitSILPhiArgument(). // visitSILPhiArgument().
foldValue(DestPHIArg, BlockArg); recordFoldedValue(DestPHIArg, BlockArg);
AvailVals.push_back(std::make_pair(DestPHIArg, BlockArg)); AvailVals.push_back(std::make_pair(DestPHIArg, BlockArg));
} }
@@ -426,10 +426,10 @@ class BasicBlockCloner : public BaseThreadingCloner {
// replaced with the BBArgs of the DestBB. // replaced with the BBArgs of the DestBB.
for (unsigned i = 0, e = FromBB->args_size(); i != e; ++i) { for (unsigned i = 0, e = FromBB->args_size(); i != e; ++i) {
// Since we don't call any CFG cloning entry point, we can call // Since we don't call any CFG cloning entry point, we can call
// `foldValue` immediately as if cloning has already started. This // `recordFoldedValue` immediately as if cloning has already
// simply avoids handling AvailVals during `remap` or defining a custom // started. This simply avoids handling AvailVals during `remap` or
// visitSILPhiArgument(). // defining a custom visitSILPhiArgument().
foldValue(FromBB->getArgument(i), DestBB->getArgument(i)); recordFoldedValue(FromBB->getArgument(i), DestBB->getArgument(i));
AvailVals.push_back( AvailVals.push_back(
std::make_pair(FromBB->getArgument(i), DestBB->getArgument(i))); std::make_pair(FromBB->getArgument(i), DestBB->getArgument(i)));
} }

View File

@@ -643,7 +643,7 @@ void ClosureCloner::visitLoadBorrowInst(LoadBorrowInst *LI) {
// We assume that the value is already guaranteed. // We assume that the value is already guaranteed.
assert(Val.getOwnershipKind().isTrivialOr(ValueOwnershipKind::Guaranteed) && assert(Val.getOwnershipKind().isTrivialOr(ValueOwnershipKind::Guaranteed) &&
"Expected argument value to be guaranteed"); "Expected argument value to be guaranteed");
foldValue(LI, Val); recordFoldedValue(LI, Val);
return; return;
} }
@@ -668,7 +668,7 @@ void ClosureCloner::visitLoadInst(LoadInst *LI) {
&& LI->getOwnershipQualifier() == LoadOwnershipQualifier::Copy) { && LI->getOwnershipQualifier() == LoadOwnershipQualifier::Copy) {
Val = getBuilder().createCopyValue(LI->getLoc(), Val); Val = getBuilder().createCopyValue(LI->getLoc(), Val);
} }
foldValue(LI, Val); recordFoldedValue(LI, Val);
return; return;
} }
@@ -694,7 +694,7 @@ void ClosureCloner::visitLoadInst(LoadInst *LI) {
&& LI->getOwnershipQualifier() == LoadOwnershipQualifier::Copy) { && LI->getOwnershipQualifier() == LoadOwnershipQualifier::Copy) {
Val = getBuilder().createCopyValue(LI->getLoc(), Val); Val = getBuilder().createCopyValue(LI->getLoc(), Val);
} }
foldValue(LI, Val); recordFoldedValue(LI, Val);
return; return;
} }
SILCloner<ClosureCloner>::visitLoadInst(LI); SILCloner<ClosureCloner>::visitLoadInst(LI);

View File

@@ -726,7 +726,7 @@ void PromotedParamCloner::visitProjectBoxInst(ProjectBoxInst *Inst) {
// Its uses will be replaced by the promoted address. // Its uses will be replaced by the promoted address.
if (OrigPromotedParameters.count(Inst->getOperand())) { if (OrigPromotedParameters.count(Inst->getOperand())) {
auto *origArg = cast<SILFunctionArgument>(Inst->getOperand()); auto *origArg = cast<SILFunctionArgument>(Inst->getOperand());
foldValue(Inst, NewPromotedArgs[origArg->getIndex()]); recordFoldedValue(Inst, NewPromotedArgs[origArg->getIndex()]);
return; return;
} }