mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #12634 from gottesmm/pr-b3f1b87a0325e44b2300443db5fdaa81b8e38e8e
This commit is contained in:
@@ -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,9 +513,8 @@ 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());
|
||||||
@@ -560,7 +559,7 @@ AggregateAvailableValues(SILInstruction *Inst, SILType LoadTy,
|
|||||||
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;
|
||||||
}
|
}
|
||||||
@@ -583,7 +582,7 @@ AggregateAvailableValues(SILInstruction *Inst, SILType LoadTy,
|
|||||||
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,7 +691,7 @@ 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;
|
||||||
@@ -757,7 +756,7 @@ 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;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user