@@ -1237,50 +1237,43 @@ struct LocalTransferredReason {
1237
1237
// to be informative, so distance is used as a heuristic to choose which
1238
1238
// access sites to display in diagnostics given a racy consumption.
1239
1239
class TransferredReason {
1240
- std::map <unsigned , std::vector< PartitionOp> > transferOps;
1240
+ std::multimap <unsigned , PartitionOp> transferOps;
1241
1241
1242
1242
friend class TransferRequireAccumulator ;
1243
1243
1244
1244
bool containsOp (const PartitionOp& op) {
1245
- for (auto [_, vec] : transferOps)
1246
- for (auto vecOp : vec)
1247
- if (op == vecOp)
1248
- return true ;
1249
- return false ;
1245
+ return llvm::any_of (transferOps,
1246
+ [&](const std::pair<unsigned , PartitionOp> &pair) {
1247
+ return pair.second == op;
1248
+ });
1250
1249
}
1251
1250
1252
1251
public:
1253
- // a TransferredReason is valid if it contains at least one transfer
1254
- // instruction
1255
- bool isValid () {
1256
- for (auto [_, vec] : transferOps)
1257
- if (!vec.empty ())
1258
- return true ;
1259
- return false ;
1260
- }
1252
+ // A TransferredReason is valid if it contains at least one transfer
1253
+ // instruction.
1254
+ bool isValid () { return transferOps.size (); }
1261
1255
1262
1256
TransferredReason () {}
1263
1257
1264
1258
TransferredReason (LocalTransferredReason localReason) {
1265
1259
assert (localReason.kind == LocalTransferredReasonKind::LocalTransferInst);
1266
- transferOps[ 0 ] = { localReason.localInst .value ()} ;
1260
+ transferOps. emplace ( 0 , localReason.localInst .value ()) ;
1267
1261
}
1268
1262
1269
1263
void addTransferOp (PartitionOp transferOp, unsigned distance) {
1270
1264
assert (transferOp.getKind () == PartitionOpKind::Transfer);
1271
1265
// duplicates should not arise
1272
1266
if (!containsOp (transferOp))
1273
- transferOps[distance]. push_back ( transferOp);
1267
+ transferOps. emplace (distance, transferOp);
1274
1268
}
1275
1269
1276
1270
// merge in another transferredReason, adding the specified distane to all its
1277
1271
// ops
1278
1272
void addOtherReasonAtDistance (const TransferredReason &otherReason,
1279
1273
unsigned distance) {
1280
- for (auto &[otherDistance, otherTransferOpsAtDistance ] :
1274
+ for (auto &[otherDistance, otherTransferOpAtDistance ] :
1281
1275
otherReason.transferOps )
1282
- for (auto otherTransferOp : otherTransferOpsAtDistance)
1283
- addTransferOp (otherTransferOp, distance + otherDistance);
1276
+ addTransferOp (otherTransferOpAtDistance, distance + otherDistance);
1284
1277
}
1285
1278
};
1286
1279
@@ -1319,9 +1312,8 @@ class TransferRequireAccumulator {
1319
1312
1320
1313
void accumulateTransferredReason (PartitionOp requireOp,
1321
1314
const TransferredReason &transferredReason) {
1322
- for (auto [distance, transferOps] : transferredReason.transferOps )
1323
- for (auto transferOp : transferOps)
1324
- requirementsForTransfers[transferOp].insert ({requireOp, distance});
1315
+ for (auto [distance, transferOp] : transferredReason.transferOps )
1316
+ requirementsForTransfers[transferOp].insert ({requireOp, distance});
1325
1317
}
1326
1318
1327
1319
void emitErrorsForTransferRequire (
0 commit comments