Skip to content

Commit 9fa0dfd

Browse files
committed
[region-isolation] Eliminate unnecessary using TrackableValueID = Element.
Having two artificial typedefs for the same wrapped value is just confusing. Better to just have one and make the code simpler to understand.
1 parent d70933b commit 9fa0dfd

File tree

3 files changed

+22
-26
lines changed

3 files changed

+22
-26
lines changed

include/swift/SILOptimizer/Analysis/RegionAnalysis.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class RegionAnalysisFunctionInfo;
2828
namespace regionanalysisimpl {
2929

3030
using TransferringOperandSetFactory = Partition::TransferringOperandSetFactory;
31-
using TrackableValueID = PartitionPrimitives::Element;
31+
using Element = PartitionPrimitives::Element;
3232
using Region = PartitionPrimitives::Region;
3333

3434
/// Check if the passed in type is NonSendable.
@@ -172,7 +172,7 @@ class regionanalysisimpl::TrackableValueState {
172172

173173
SILIsolationInfo getIsolationRegionInfo() const { return regionInfo; }
174174

175-
TrackableValueID getID() const { return TrackableValueID(id); }
175+
Element getID() const { return Element(id); }
176176

177177
void addFlag(TrackableValueFlag flag) { flagSet |= flag; }
178178

@@ -273,9 +273,7 @@ class regionanalysisimpl::TrackableValue {
273273
return valueState.getIsolationRegionInfo();
274274
}
275275

276-
TrackableValueID getID() const {
277-
return TrackableValueID(valueState.getID());
278-
}
276+
Element getID() const { return Element(valueState.getID()); }
279277

280278
/// Return the representative value of this equivalence class of values.
281279
RepresentativeValue getRepresentative() const { return representativeValue; }
@@ -317,7 +315,6 @@ class RegionAnalysisValueMap {
317315
using Region = PartitionPrimitives::Region;
318316
using TrackableValue = regionanalysisimpl::TrackableValue;
319317
using TrackableValueState = regionanalysisimpl::TrackableValueState;
320-
using TrackableValueID = Element;
321318
using RepresentativeValue = regionanalysisimpl::RepresentativeValue;
322319

323320
private:
@@ -371,14 +368,14 @@ class RegionAnalysisValueMap {
371368
SILInstruction *introducingInst) const;
372369

373370
private:
374-
std::optional<TrackableValue> getValueForId(TrackableValueID id) const;
371+
std::optional<TrackableValue> getValueForId(Element id) const;
375372
std::optional<TrackableValue> tryToTrackValue(SILValue value) const;
376373
TrackableValue
377374
getActorIntroducingRepresentative(SILInstruction *introducingInst,
378375
SILIsolationInfo isolation) const;
379376
bool mergeIsolationRegionInfo(SILValue value, SILIsolationInfo isolation);
380377
bool valueHasID(SILValue value, bool dumpIfHasNoID = false);
381-
TrackableValueID lookupValueID(SILValue value);
378+
Element lookupValueID(SILValue value);
382379
};
383380

384381
class RegionAnalysisFunctionInfo {

lib/SILOptimizer/Analysis/RegionAnalysis.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,11 +1145,10 @@ struct PartitionOpBuilder {
11451145
currentInstPartitionOps.clear();
11461146
}
11471147

1148-
TrackableValueID lookupValueID(SILValue value);
1148+
Element lookupValueID(SILValue value);
11491149
bool valueHasID(SILValue value, bool dumpIfHasNoID = false);
11501150

1151-
TrackableValueID
1152-
getActorIntroducingRepresentative(SILIsolationInfo actorIsolation);
1151+
Element getActorIntroducingRepresentative(SILIsolationInfo actorIsolation);
11531152

11541153
void addAssignFresh(SILValue value) {
11551154
currentInstPartitionOps.emplace_back(
@@ -1160,7 +1159,7 @@ struct PartitionOpBuilder {
11601159
assert(valueHasID(src, /*dumpIfHasNoID=*/true) &&
11611160
"source value of assignment should already have been encountered");
11621161

1163-
TrackableValueID srcID = lookupValueID(src);
1162+
Element srcID = lookupValueID(src);
11641163
if (lookupValueID(tgt) == srcID) {
11651164
LLVM_DEBUG(llvm::dbgs() << " Skipping assign since tgt and src have "
11661165
"the same representative.\n");
@@ -1501,7 +1500,7 @@ class PartitionOpTranslator {
15011500
return partialApplyReachabilityDataflow.isReachable(value, inst);
15021501
}
15031502

1504-
std::optional<TrackableValue> getValueForId(TrackableValueID id) const {
1503+
std::optional<TrackableValue> getValueForId(Element id) const {
15051504
return valueMap.getValueForId(id);
15061505
}
15071506

@@ -1542,7 +1541,7 @@ class PartitionOpTranslator {
15421541
return valueMap.valueHasID(value, dumpIfHasNoID);
15431542
}
15441543

1545-
TrackableValueID lookupValueID(SILValue value) {
1544+
Element lookupValueID(SILValue value) {
15461545
return valueMap.lookupValueID(value);
15471546
}
15481547

@@ -2288,11 +2287,11 @@ class PartitionOpTranslator {
22882287
} // namespace regionanalysisimpl
22892288
} // namespace swift
22902289

2291-
TrackableValueID PartitionOpBuilder::lookupValueID(SILValue value) {
2290+
Element PartitionOpBuilder::lookupValueID(SILValue value) {
22922291
return translator->lookupValueID(value);
22932292
}
22942293

2295-
TrackableValueID PartitionOpBuilder::getActorIntroducingRepresentative(
2294+
Element PartitionOpBuilder::getActorIntroducingRepresentative(
22962295
SILIsolationInfo actorIsolation) {
22972296
return translator
22982297
->getActorIntroducingRepresentative(currentInst, actorIsolation)
@@ -2332,17 +2331,17 @@ void PartitionOpBuilder::print(llvm::raw_ostream &os) const {
23322331

23332332
// Now print out a translation from region to equivalence class value.
23342333
llvm::dbgs() << " └─────╼ Used Values\n";
2335-
llvm::SmallVector<TrackableValueID, 8> opsToPrint;
2334+
llvm::SmallVector<Element, 8> opsToPrint;
23362335
SWIFT_DEFER { opsToPrint.clear(); };
23372336
for (const PartitionOp &op : ops) {
23382337
// Now dump our the root value we map.
23392338
for (unsigned opArg : op.getOpArgs()) {
23402339
// If we didn't insert, skip this. We only emit this once.
2341-
opsToPrint.push_back(TrackableValueID(opArg));
2340+
opsToPrint.push_back(Element(opArg));
23422341
}
23432342
}
23442343
sortUnique(opsToPrint);
2345-
for (TrackableValueID opArg : opsToPrint) {
2344+
for (Element opArg : opsToPrint) {
23462345
llvm::dbgs() << " └╼ ";
23472346
auto trackableValue = translator->getValueForId(opArg);
23482347
assert(trackableValue);
@@ -3193,7 +3192,7 @@ SILInstruction *RegionAnalysisValueMap::maybeGetActorIntroducingInst(
31933192
}
31943193

31953194
std::optional<TrackableValue>
3196-
RegionAnalysisValueMap::getValueForId(TrackableValueID id) const {
3195+
RegionAnalysisValueMap::getValueForId(Element id) const {
31973196
auto iter = stateIndexToEquivalenceClass.find(id);
31983197
if (iter == stateIndexToEquivalenceClass.end())
31993198
return {};
@@ -3570,7 +3569,7 @@ bool RegionAnalysisValueMap::valueHasID(SILValue value, bool dumpIfHasNoID) {
35703569
return hasID;
35713570
}
35723571

3573-
TrackableValueID RegionAnalysisValueMap::lookupValueID(SILValue value) {
3572+
Element RegionAnalysisValueMap::lookupValueID(SILValue value) {
35743573
auto state = getTrackableValue(value);
35753574
assert(state.isNonSendable() &&
35763575
"only non-Sendable values should be entered in the map");

lib/SILOptimizer/Mandatory/TransferNonSendable.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ using namespace swift::regionanalysisimpl;
4646
namespace {
4747

4848
using TransferringOperandSetFactory = Partition::TransferringOperandSetFactory;
49-
using TrackableValueID = PartitionPrimitives::Element;
49+
using Element = PartitionPrimitives::Element;
5050
using Region = PartitionPrimitives::Region;
5151

5252
} // namespace
@@ -1354,7 +1354,7 @@ struct DiagnosticEvaluator final
13541354
transferredNonTransferrable(transferredNonTransferrable) {}
13551355

13561356
void handleLocalUseAfterTransfer(const PartitionOp &partitionOp,
1357-
TrackableValueID transferredVal,
1357+
Element transferredVal,
13581358
TransferringOperand *transferringOp) const {
13591359
// Ignore this if we have a gep like instruction that is returning a
13601360
// sendable type and transferringOp was not set with closure
@@ -1387,7 +1387,7 @@ struct DiagnosticEvaluator final
13871387

13881388
void
13891389
handleTransferNonTransferrable(const PartitionOp &partitionOp,
1390-
TrackableValueID transferredVal,
1390+
Element transferredVal,
13911391
SILIsolationInfo isolationRegionInfo) const {
13921392
LLVM_DEBUG(llvm::dbgs()
13931393
<< " Emitting TransferNonTransferrable Error!\n"
@@ -1407,8 +1407,8 @@ struct DiagnosticEvaluator final
14071407

14081408
void
14091409
handleTransferNonTransferrable(const PartitionOp &partitionOp,
1410-
TrackableValueID transferredVal,
1411-
TrackableValueID actualNonTransferrableValue,
1410+
Element transferredVal,
1411+
Element actualNonTransferrableValue,
14121412
SILIsolationInfo isolationRegionInfo) const {
14131413
LLVM_DEBUG(llvm::dbgs()
14141414
<< " Emitting TransferNonTransferrable Error!\n"

0 commit comments

Comments
 (0)