Migrate to use new projection for SILmem2reg. This should be a NFC.

This is part of rdar://24520269
This commit is contained in:
Xin Tong
2016-02-05 23:05:01 -08:00
parent e05cf6e018
commit 338a2d0af5

View File

@@ -319,19 +319,18 @@ static void collectLoads(SILInstruction *I, SmallVectorImpl<LoadInst *> &Loads)
static void replaceLoad(LoadInst *LI, SILValue val, AllocStackInst *ASI) {
ProjectionPath projections;
NewProjectionPath projections(val->getType());
SILValue op = LI->getOperand();
while (op != ASI) {
assert(isa<StructElementAddrInst>(op) || isa<TupleElementAddrInst>(op));
SILInstruction *Inst = cast<SILInstruction>(op);
auto projection = Projection::addressProjectionForInstruction(Inst);
projections.push_back(projection.getValue());
projections.push_back(NewProjection(Inst));
op = Inst->getOperand(0);
}
SILBuilder builder(LI);
for (auto iter = projections.rbegin(); iter != projections.rend(); ++iter) {
const Projection &projection = *iter;
val = projection.createValueProjection(builder, LI->getLoc(), val).get();
const NewProjection &projection = *iter;
val = projection.createObjectProjection(builder, LI->getLoc(), val).get();
}
op = LI->getOperand();
LI->replaceAllUsesWith(val);