Merge pull request #12634 from gottesmm/pr-b3f1b87a0325e44b2300443db5fdaa81b8e38e8e

This commit is contained in:
swift-ci
2017-10-26 12:04:13 -07:00
committed by GitHub

View File

@@ -147,7 +147,7 @@ static unsigned computeSubelement(SILValue Pointer,
/// Given an aggregate value and an access path, extract the value indicated by /// Given an aggregate value and an access path, extract the value indicated by
/// the path. /// the path.
static SILValue ExtractSubElement(SILValue Val, unsigned SubElementNumber, static SILValue extractSubElement(SILValue Val, unsigned SubElementNumber,
SILBuilder &B, SILLocation Loc) { SILBuilder &B, SILLocation Loc) {
SILType ValTy = Val->getType(); SILType ValTy = Val->getType();
@@ -159,7 +159,7 @@ static SILValue ExtractSubElement(SILValue Val, unsigned SubElementNumber,
unsigned NumSubElt = getNumSubElements(EltTy, B.getModule()); unsigned NumSubElt = getNumSubElements(EltTy, B.getModule());
if (SubElementNumber < NumSubElt) { if (SubElementNumber < NumSubElt) {
Val = B.emitTupleExtract(Loc, Val, EltNo, EltTy); Val = B.emitTupleExtract(Loc, Val, EltNo, EltTy);
return ExtractSubElement(Val, SubElementNumber, B, Loc); return extractSubElement(Val, SubElementNumber, B, Loc);
} }
SubElementNumber -= NumSubElt; SubElementNumber -= NumSubElt;
@@ -176,7 +176,7 @@ static SILValue ExtractSubElement(SILValue Val, unsigned SubElementNumber,
if (SubElementNumber < NumSubElt) { if (SubElementNumber < NumSubElt) {
Val = B.emitStructExtract(Loc, Val, D); Val = B.emitStructExtract(Loc, Val, D);
return ExtractSubElement(Val, SubElementNumber, B, Loc); return extractSubElement(Val, SubElementNumber, B, Loc);
} }
SubElementNumber -= NumSubElt; SubElementNumber -= NumSubElt;
@@ -513,11 +513,10 @@ static bool anyMissing(unsigned StartSubElt, unsigned NumSubElts,
/// AggregateAvailableValues - Given a bunch of primitive subelement values, /// AggregateAvailableValues - Given a bunch of primitive subelement values,
/// build out the right aggregate type (LoadTy) by emitting tuple and struct /// build out the right aggregate type (LoadTy) by emitting tuple and struct
/// instructions as necessary. /// instructions as necessary.
static SILValue static SILValue aggregateAvailableValues(
AggregateAvailableValues(SILInstruction *Inst, SILType LoadTy, SILInstruction *Inst, SILType LoadTy, SILValue Address,
SILValue Address, ArrayRef<std::pair<SILValue, unsigned>> AvailableValues,
ArrayRef<std::pair<SILValue, unsigned>> AvailableValues, unsigned FirstElt) {
unsigned FirstElt) {
assert(LoadTy.isObject()); assert(LoadTy.isObject());
SILModule &M = Inst->getModule(); SILModule &M = Inst->getModule();
@@ -559,8 +558,8 @@ AggregateAvailableValues(SILInstruction *Inst, SILType LoadTy,
if (anyMissing(FirstElt, NumSubElt, AvailableValues)) if (anyMissing(FirstElt, NumSubElt, AvailableValues))
EltAddr = B.createTupleElementAddr(Inst->getLoc(), Address, EltNo, EltAddr = B.createTupleElementAddr(Inst->getLoc(), Address, EltNo,
EltTy.getAddressType()); EltTy.getAddressType());
ResultElts.push_back(AggregateAvailableValues(Inst, EltTy, EltAddr, ResultElts.push_back(aggregateAvailableValues(Inst, EltTy, EltAddr,
AvailableValues, FirstElt)); AvailableValues, FirstElt));
FirstElt += NumSubElt; FirstElt += NumSubElt;
} }
@@ -582,8 +581,8 @@ AggregateAvailableValues(SILInstruction *Inst, SILType LoadTy,
if (anyMissing(FirstElt, NumSubElt, AvailableValues)) if (anyMissing(FirstElt, NumSubElt, AvailableValues))
EltAddr = B.createStructElementAddr(Inst->getLoc(), Address, FD, EltAddr = B.createStructElementAddr(Inst->getLoc(), Address, FD,
EltTy.getAddressType()); EltTy.getAddressType());
ResultElts.push_back(AggregateAvailableValues(Inst, EltTy, EltAddr, ResultElts.push_back(aggregateAvailableValues(Inst, EltTy, EltAddr,
AvailableValues, FirstElt)); AvailableValues, FirstElt));
FirstElt += NumSubElt; FirstElt += NumSubElt;
} }
@@ -597,7 +596,7 @@ AggregateAvailableValues(SILInstruction *Inst, SILType LoadTy,
return B.createLoad(Inst->getLoc(), Address, return B.createLoad(Inst->getLoc(), Address,
LoadOwnershipQualifier::Unqualified); LoadOwnershipQualifier::Unqualified);
SILValue EltVal = ExtractSubElement(Val.first, Val.second, B, Inst->getLoc()); SILValue EltVal = extractSubElement(Val.first, Val.second, B, Inst->getLoc());
// It must be the same type as LoadTy if available. // It must be the same type as LoadTy if available.
assert(EltVal->getType() == LoadTy && assert(EltVal->getType() == LoadTy &&
"Subelement types mismatch"); "Subelement types mismatch");
@@ -692,9 +691,9 @@ bool AllocOptimize::promoteLoad(SILInstruction *Inst) {
// type as the load did, and emit smaller) loads for any subelements that were // type as the load did, and emit smaller) loads for any subelements that were
// not available. // not available.
auto Load = cast<LoadInst>(Inst); auto Load = cast<LoadInst>(Inst);
auto NewVal = AggregateAvailableValues(Load, LoadTy, Load->getOperand(), auto NewVal = aggregateAvailableValues(Load, LoadTy, Load->getOperand(),
AvailableValues, FirstElt); AvailableValues, FirstElt);
++NumLoadPromoted; ++NumLoadPromoted;
// Simply replace the load. // Simply replace the load.
@@ -757,8 +756,8 @@ bool AllocOptimize::promoteDestroyAddr(DestroyAddrInst *DAI) {
// type as the load did, and emit smaller) loads for any subelements that were // type as the load did, and emit smaller) loads for any subelements that were
// not available. // not available.
auto NewVal = auto NewVal =
AggregateAvailableValues(DAI, LoadTy, Address, AvailableValues, FirstElt); aggregateAvailableValues(DAI, LoadTy, Address, AvailableValues, FirstElt);
++NumDestroyAddrPromoted; ++NumDestroyAddrPromoted;
DEBUG(llvm::dbgs() << " *** Promoting destroy_addr: " << *DAI << "\n"); DEBUG(llvm::dbgs() << " *** Promoting destroy_addr: " << *DAI << "\n");