Skip to content

Commit 72817df

Browse files
committed
[SIL-opaque] rename materialization functions.
1 parent 7f88908 commit 72817df

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

lib/SILOptimizer/Mandatory/AddressLowering.cpp

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,7 @@ class AddressMaterialization {
12311231
return storage.storageAddress;
12321232

12331233
if (storage.isUseProjection) {
1234-
materializeUseProjectionStorage(storage, /*intoPhiOperand*/ false);
1234+
recursivelyMaterializeStorage(storage, /*intoPhiOperand*/ false);
12351235
} else {
12361236
assert(storage.isDefProjection);
12371237
storage.storageAddress = materializeDefProjection(origValue);
@@ -1241,8 +1241,8 @@ class AddressMaterialization {
12411241

12421242
void initializeOperand(Operand *operand);
12431243

1244-
SILValue materializeUseProjectionStorage(ValueStorage &storage,
1245-
bool intoPhiOperand);
1244+
SILValue recursivelyMaterializeStorage(ValueStorage &storage,
1245+
bool intoPhiOperand);
12461246

12471247
SILValue materializeDefProjection(SILValue origValue);
12481248

@@ -1257,8 +1257,8 @@ class AddressMaterialization {
12571257

12581258
SILValue materializeComposingUser(SingleValueInstruction *user,
12591259
bool intoPhiOperand) {
1260-
return materializeUseProjectionStorage(
1261-
pass.valueStorageMap.getStorage(user), intoPhiOperand);
1260+
return recursivelyMaterializeStorage(pass.valueStorageMap.getStorage(user),
1261+
intoPhiOperand);
12621262
}
12631263
};
12641264
} // anonymous namespace
@@ -1290,19 +1290,26 @@ void AddressMaterialization::initializeOperand(Operand *operand) {
12901290
StoreOwnershipQualifier::Init);
12911291
}
12921292

1293-
// Recursively materialize the address for storage at the point that a use
1294-
// projects into it via either a composing-use (struct, tuple, enum) or phi
1295-
// projection. This only materializes the address that the operands project
1296-
// into. It does not materialize the storage for the result. e.g. it
1297-
// materializes init_enum_data_addr, not inject_enum_addr.
1293+
// Recursively materialize the address for storage at the point that an operand
1294+
// may project into it via either a composing-use (struct, tuple, enum) or phi
1295+
// projection.
1296+
//
1297+
// Precondition: \p storage is not a def-projection.
12981298
//
12991299
// If \p intoPhiOperand is true, this materializes the address in the path that
1300-
// reaches a phi operand, not the phi block itself.
1300+
// reaches a phi operand, not the phi block itself. Do not map the storage onto
1301+
// the materialized address.
13011302
//
13021303
// If \p intoPhiOperand is false, then the materialized address is guaranteed to
13031304
// domaninate the composing user. Map the user onto this address to avoid
13041305
// rematerialization.
1305-
SILValue AddressMaterialization::materializeUseProjectionStorage(
1306+
//
1307+
// Note: This only materializes the address for the purpose of projection an
1308+
// operand into the storage. It does not materialize the final address of
1309+
// storage after materializing the result. In particular, it materializes
1310+
// init_enum_data_addr, but not inject_enum_addr.
1311+
//
1312+
SILValue AddressMaterialization::recursivelyMaterializeStorage(
13061313
ValueStorage &storage, bool intoPhiOperand = false) {
13071314
// If this storage is already materialized, then simply return its
13081315
// address. This not only avoids redundant projections, but is necessary for
@@ -1331,7 +1338,7 @@ SILValue AddressMaterialization::materializeUseProjectionStorage(
13311338
return recordAddress(useStorage.storage.storageAddress);
13321339
}
13331340
if (storage.isPhiProjection()) {
1334-
return recordAddress(materializeUseProjectionStorage(
1341+
return recordAddress(recursivelyMaterializeStorage(
13351342
pass.valueStorageMap.getProjectedStorage(storage).storage,
13361343
/*intoPhiOperand*/ true));
13371344
}
@@ -1566,8 +1573,8 @@ void PhiRewriter::materializeOperand(PhiOperand phiOper) {
15661573

15671574
auto &phiStorage = pass.valueStorageMap.getStorage(phiOper.getValue());
15681575
SILValue phiAddress =
1569-
addrMat.materializeUseProjectionStorage(phiStorage,
1570-
/*intoPhiOperand*/ true);
1576+
addrMat.recursivelyMaterializeStorage(phiStorage,
1577+
/*intoPhiOperand*/ true);
15711578

15721579
if (!movePos.foundAntiDependenceCycle) {
15731580
createPhiMove(builder, phiOperAddress, phiAddress);

0 commit comments

Comments
 (0)