1313#include " llvm/ADT/DenseMap.h"
1414#include " llvm/Support/Debug.h"
1515
16+ #define DEBUG_TYPE " send-non-sendable"
17+
1618using namespace swift ;
1719
1820namespace {
1921
20- static const bool DEBUG = false ;
2122static const char *SEP_STR = " ╾──────────────────────────────╼\n " ;
2223
2324// SILApplyCrossesIsolation determines if a SIL instruction is an isolation
@@ -429,16 +430,16 @@ class PartitionOpTranslator {
429430 // transformations to the non-Sendable partition that it induces.
430431 // it accomplished this by sequentially calling translateSILInstruction
431432 std::vector<PartitionOp> translateSILBasicBlock (SILBasicBlock *basicBlock) {
432- if (DEBUG) {
433- llvm::dbgs () << SEP_STR
434- << " Compiling basic block for function "
435- << basicBlock->getFunction ()->getName ()
436- << " : " ;
437- basicBlock->dumpID ();
438- llvm::dbgs () << SEP_STR;
439- basicBlock->dump ();
440- llvm::dbgs () << SEP_STR << " Results:\n " ;
441- }
433+ LLVM_DEBUG (
434+ llvm::dbgs () << SEP_STR
435+ << " Compiling basic block for function "
436+ << basicBlock->getFunction ()->getName ()
437+ << " : " ;
438+ basicBlock->dumpID ();
439+ llvm::dbgs () << SEP_STR;
440+ basicBlock->dump ();
441+ llvm::dbgs () << SEP_STR << " Results:\n " ;
442+ );
442443
443444 // translate each SIL instruction to a PartitionOp, if necessary
444445 std::vector<PartitionOp> partitionOps;
@@ -447,11 +448,11 @@ class PartitionOpTranslator {
447448 for (PartitionOp &op : ops) {
448449 partitionOps.push_back (op);
449450
450- if (DEBUG) {
451- instruction.dump ();
452- llvm::dbgs () << " └───╼ " ;
453- op.dump ();
454- }
451+ LLVM_DEBUG (
452+ instruction.dump ();
453+ llvm::dbgs () << " └───╼ " ;
454+ op.dump ();
455+ );
455456 }
456457 }
457458
@@ -527,33 +528,35 @@ class BlockPartitionState {
527528
528529public:
529530 void dump () LLVM_ATTRIBUTE_USED {
530- llvm::dbgs () << SEP_STR
531- << " BlockPartitionState[reached="
532- << reached
533- << " , needsUpdate="
534- << needsUpdate
535- << " ]\n id: " ;
536- basicBlock->dumpID ();
537- llvm::dbgs () << " entry partition: " ;
538- entryPartition.dump ();
539- llvm::dbgs () << " exit partition: " ;
540- exitPartition.dump ();
541- llvm::dbgs () << " instructions:\n ┌──────────╼\n " ;
542- for (PartitionOp op : blockPartitionOps) {
543- llvm::dbgs () << " │ " ;
544- op.dump ();
545- }
546- llvm::dbgs () << " └──────────╼\n Succs:\n " ;
547- for (auto succ : basicBlock->getSuccessorBlocks ()) {
548- llvm::dbgs () << " →" ;
549- succ->dumpID ();
550- }
551- llvm::dbgs () << " Preds:\n " ;
552- for (auto pred : basicBlock->getPredecessorBlocks ()) {
553- llvm::dbgs () << " ←" ;
554- pred->dumpID ();
555- }
556- llvm::dbgs ()<< SEP_STR;
531+ LLVM_DEBUG (
532+ llvm::dbgs () << SEP_STR
533+ << " BlockPartitionState[reached="
534+ << reached
535+ << " , needsUpdate="
536+ << needsUpdate
537+ << " ]\n id: " ;
538+ basicBlock->dumpID ();
539+ llvm::dbgs () << " entry partition: " ;
540+ entryPartition.dump ();
541+ llvm::dbgs () << " exit partition: " ;
542+ exitPartition.dump ();
543+ llvm::dbgs () << " instructions:\n ┌──────────╼\n " ;
544+ for (PartitionOp op : blockPartitionOps) {
545+ llvm::dbgs () << " │ " ;
546+ op.dump ();
547+ }
548+ llvm::dbgs () << " └──────────╼\n Succs:\n " ;
549+ for (auto succ : basicBlock->getSuccessorBlocks ()) {
550+ llvm::dbgs () << " →" ;
551+ succ->dumpID ();
552+ }
553+ llvm::dbgs () << " Preds:\n " ;
554+ for (auto pred : basicBlock->getPredecessorBlocks ()) {
555+ llvm::dbgs () << " ←" ;
556+ pred->dumpID ();
557+ }
558+ llvm::dbgs ()<< SEP_STR;
559+ );
557560 }
558561};
559562
@@ -712,10 +715,10 @@ class PartitionAnalysis {
712715 static void performForFunction (SILFunction *function) {
713716 auto analysis = PartitionAnalysis (function);
714717 analysis.solve ();
715- if (DEBUG) {
716- llvm::dbgs () << " SOLVED: " ;
717- analysis.dump ();
718- }
718+ LLVM_DEBUG (
719+ llvm::dbgs () << " SOLVED: " ;
720+ analysis.dump ();
721+ );
719722 analysis.diagnose ();
720723 }
721724};
0 commit comments