@@ -904,8 +904,8 @@ class PartitionOpTranslator {
904
904
break ;
905
905
}
906
906
907
- LLVM_DEBUG (llvm::errs () << " warning: " ;
908
- llvm::errs () << " unhandled instruction kind "
907
+ LLVM_DEBUG (llvm::dbgs () << " warning: " ;
908
+ llvm::dbgs () << " unhandled instruction kind "
909
909
<< getSILInstructionName (inst->getKind ()) << " \n " ;);
910
910
911
911
return {};
@@ -915,16 +915,11 @@ class PartitionOpTranslator {
915
915
// transformations to the non-Sendable partition that it induces.
916
916
// it accomplished this by sequentially calling translateSILInstruction
917
917
std::vector<PartitionOp> translateSILBasicBlock (SILBasicBlock *basicBlock) {
918
- LLVM_DEBUG (
919
- llvm::dbgs () << SEP_STR
920
- << " Compiling basic block for function "
921
- << basicBlock->getFunction ()->getName ()
922
- << " : " ;
923
- basicBlock->dumpID ();
924
- llvm::dbgs () << SEP_STR;
925
- basicBlock->dump ();
926
- llvm::dbgs () << SEP_STR << " Results:\n " ;
927
- );
918
+ LLVM_DEBUG (llvm::dbgs () << SEP_STR << " Compiling basic block for function "
919
+ << basicBlock->getFunction ()->getName () << " : " ;
920
+ basicBlock->dumpID (); llvm::dbgs () << SEP_STR;
921
+ basicBlock->print (llvm::dbgs ());
922
+ llvm::dbgs () << SEP_STR << " Results:\n " ;);
928
923
929
924
// translate each SIL instruction to a PartitionOp, if necessary
930
925
std::vector<PartitionOp> partitionOps;
@@ -937,18 +932,14 @@ class PartitionOpTranslator {
937
932
LLVM_DEBUG (
938
933
if (translationIndex != lastTranslationIndex) {
939
934
llvm::dbgs () << " ┌─┬─╼" ;
940
- instruction.dump ( );
935
+ instruction.print ( llvm::dbgs () );
941
936
llvm::dbgs () << " │ └─╼ " ;
942
937
instruction.getLoc ().getSourceLoc ().printLineAndColumn (
943
938
llvm::dbgs (), function->getASTContext ().SourceMgr );
944
939
llvm::dbgs () << " │ translation #" << translationIndex;
945
940
llvm::dbgs () << " \n └─────╼ " ;
946
- } else {
947
- llvm::dbgs () << " └╼ " ;
948
- }
949
- op.dump ();
950
- lastTranslationIndex = translationIndex;
951
- );
941
+ } else { llvm::dbgs () << " └╼ " ; } op.print (llvm::dbgs ());
942
+ lastTranslationIndex = translationIndex;);
952
943
}
953
944
}
954
945
@@ -1038,36 +1029,32 @@ class BlockPartitionState {
1038
1029
return exitPartition;
1039
1030
}
1040
1031
1041
- void dump () LLVM_ATTRIBUTE_USED {
1032
+ SWIFT_DEBUG_DUMP { print (llvm::dbgs ()); }
1033
+
1034
+ void print (llvm::raw_ostream &os) const {
1042
1035
LLVM_DEBUG (
1043
- llvm::dbgs () << SEP_STR
1044
- << " BlockPartitionState[reached="
1045
- << reached
1046
- << " , needsUpdate="
1047
- << needsUpdate
1048
- << " ]\n id: " ;
1049
- basicBlock->dumpID ();
1050
- llvm::dbgs () << " entry partition: " ;
1051
- entryPartition.dump ();
1052
- llvm::dbgs () << " exit partition: " ;
1053
- exitPartition.dump ();
1054
- llvm::dbgs () << " instructions:\n ┌──────────╼\n " ;
1055
- for (PartitionOp op : blockPartitionOps) {
1056
- llvm::dbgs () << " │ " ;
1057
- op.dump ();
1058
- }
1059
- llvm::dbgs () << " └──────────╼\n Succs:\n " ;
1060
- for (auto succ : basicBlock->getSuccessorBlocks ()) {
1061
- llvm::dbgs () << " →" ;
1062
- succ->dumpID ();
1063
- }
1064
- llvm::dbgs () << " Preds:\n " ;
1065
- for (auto pred : basicBlock->getPredecessorBlocks ()) {
1066
- llvm::dbgs () << " ←" ;
1067
- pred->dumpID ();
1068
- }
1069
- llvm::dbgs ()<< SEP_STR;
1070
- );
1036
+ os << SEP_STR << " BlockPartitionState[reached=" << reached
1037
+ << " , needsUpdate=" << needsUpdate << " ]\n id: " ;
1038
+ basicBlock->printID (os); os << " entry partition: " ;
1039
+ entryPartition.print (os); os << " exit partition: " ;
1040
+ exitPartition.print (os);
1041
+ os << " instructions:\n ┌──────────╼\n " ; for (PartitionOp op
1042
+ : blockPartitionOps) {
1043
+ os << " │ " ;
1044
+ op.print (os);
1045
+ } os << " └──────────╼\n Succs:\n " ;
1046
+ for (auto succ
1047
+ : basicBlock->getSuccessorBlocks ()) {
1048
+ os << " →" ;
1049
+ succ->printID (os);
1050
+ } os
1051
+ << " Preds:\n " ;
1052
+ for (auto pred
1053
+ : basicBlock->getPredecessorBlocks ()) {
1054
+ os << " ←" ;
1055
+ pred->printID (os);
1056
+ } os
1057
+ << SEP_STR;);
1071
1058
}
1072
1059
};
1073
1060
@@ -1223,17 +1210,19 @@ class ConsumeRequireAccumulator {
1223
1210
}
1224
1211
}
1225
1212
1226
- void dump () const {
1213
+ SWIFT_DEBUG_DUMP { print (llvm::dbgs ()); }
1214
+
1215
+ void print (llvm::raw_ostream &os) const {
1227
1216
forEachConsumeRequire (
1228
- [](const PartitionOp& consumeOp, unsigned numProcessed, unsigned numSkipped) {
1229
- llvm::dbgs () << " ┌──╼ CONSUME: " ;
1230
- consumeOp.dump ();
1217
+ [&](const PartitionOp &consumeOp, unsigned numProcessed,
1218
+ unsigned numSkipped) {
1219
+ os << " ┌──╼ CONSUME: " ;
1220
+ consumeOp.print (os);
1231
1221
},
1232
- [](const PartitionOp& requireOp) {
1233
- llvm::dbgs () << " ├╼ REQUIRE: " ;
1234
- requireOp.dump ();
1235
- }
1236
- );
1222
+ [&](const PartitionOp &requireOp) {
1223
+ os << " ├╼ REQUIRE: " ;
1224
+ requireOp.print (os);
1225
+ });
1237
1226
}
1238
1227
};
1239
1228
@@ -1429,25 +1418,22 @@ class RaceTracer {
1429
1418
}
1430
1419
1431
1420
bool dumpBlockSearch (SILBasicBlock * SILBlock, TrackableValueID consumedVal) {
1432
- LLVM_DEBUG (
1433
- unsigned i = 0 ;
1434
- const BlockPartitionState &block = blockStates[SILBlock];
1435
- Partition working = block.getEntryPartition ();
1436
- llvm::dbgs () << " ┌──────────╼\n │ " ;
1437
- working.dump ();
1438
- block.forEachPartitionOp ([&](const PartitionOp &op) {
1439
- llvm::dbgs () << " ├[" << i++ << " ] " ;
1440
- op.dump ();
1441
- working.apply (op);
1442
- llvm::dbgs () << " │ " ;
1443
- if (working.isConsumed (consumedVal)) {
1444
- llvm::errs () << " (" << consumedVal << " CONSUMED) " ;
1445
- }
1446
- working.dump ();
1447
- return true ;
1448
- });
1449
- llvm::dbgs () << " └──────────╼\n " ;
1450
- );
1421
+ LLVM_DEBUG (unsigned i = 0 ;
1422
+ const BlockPartitionState &block = blockStates[SILBlock];
1423
+ Partition working = block.getEntryPartition ();
1424
+ llvm::dbgs () << " ┌──────────╼\n │ " ; working.print (llvm::dbgs ());
1425
+ block.forEachPartitionOp ([&](const PartitionOp &op) {
1426
+ llvm::dbgs () << " ├[" << i++ << " ] " ;
1427
+ op.print (llvm::dbgs ());
1428
+ working.apply (op);
1429
+ llvm::dbgs () << " │ " ;
1430
+ if (working.isConsumed (consumedVal)) {
1431
+ llvm::dbgs () << " (" << consumedVal << " CONSUMED) " ;
1432
+ }
1433
+ working.print (llvm::dbgs ());
1434
+ return true ;
1435
+ });
1436
+ llvm::dbgs () << " └──────────╼\n " ;);
1451
1437
return false ;
1452
1438
}
1453
1439
@@ -1624,10 +1610,8 @@ class PartitionAnalysis {
1624
1610
});
1625
1611
}
1626
1612
1627
- LLVM_DEBUG (
1628
- llvm::dbgs () << " Accumulator Complete:\n " ;
1629
- raceTracer.getAccumulator ().dump ();
1630
- );
1613
+ LLVM_DEBUG (llvm::dbgs () << " Accumulator Complete:\n " ;
1614
+ raceTracer.getAccumulator ().print (llvm::dbgs ()););
1631
1615
1632
1616
// ask the raceTracer to report diagnostics at the consumption sites
1633
1617
// for all the racy requirement sites entered into it above
@@ -1692,22 +1676,20 @@ class PartitionAnalysis {
1692
1676
}
1693
1677
1694
1678
public:
1679
+ SWIFT_DEBUG_DUMP { print (llvm::dbgs ()); }
1695
1680
1696
- void dump () LLVM_ATTRIBUTE_USED {
1697
- llvm::dbgs () << " \n PartitionAnalysis[fname=" << function->getName () << " ]\n " ;
1681
+ void print (llvm::raw_ostream &os) const {
1682
+ os << " \n PartitionAnalysis[fname=" << function->getName () << " ]\n " ;
1698
1683
1699
1684
for (auto [_, blockState] : blockStates) {
1700
- blockState.dump ( );
1685
+ blockState.print (os );
1701
1686
}
1702
1687
}
1703
1688
1704
1689
static void performForFunction (SILFunction *function) {
1705
1690
auto analysis = PartitionAnalysis (function);
1706
1691
analysis.solve ();
1707
- LLVM_DEBUG (
1708
- llvm::dbgs () << " SOLVED: " ;
1709
- analysis.dump ();
1710
- );
1692
+ LLVM_DEBUG (llvm::dbgs () << " SOLVED: " ; analysis.print (llvm::dbgs ()););
1711
1693
analysis.diagnose ();
1712
1694
}
1713
1695
};
0 commit comments