13
13
#include " llvm/ADT/DenseMap.h"
14
14
#include " llvm/Support/Debug.h"
15
15
16
+ #define DEBUG_TYPE " send-non-sendable"
17
+
16
18
using namespace swift ;
17
19
18
20
namespace {
19
21
20
- static const bool DEBUG = false ;
21
22
static const char *SEP_STR = " ╾──────────────────────────────╼\n " ;
22
23
23
24
// SILApplyCrossesIsolation determines if a SIL instruction is an isolation
@@ -429,16 +430,16 @@ class PartitionOpTranslator {
429
430
// transformations to the non-Sendable partition that it induces.
430
431
// it accomplished this by sequentially calling translateSILInstruction
431
432
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
+ );
442
443
443
444
// translate each SIL instruction to a PartitionOp, if necessary
444
445
std::vector<PartitionOp> partitionOps;
@@ -447,11 +448,11 @@ class PartitionOpTranslator {
447
448
for (PartitionOp &op : ops) {
448
449
partitionOps.push_back (op);
449
450
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
+ );
455
456
}
456
457
}
457
458
@@ -527,33 +528,35 @@ class BlockPartitionState {
527
528
528
529
public:
529
530
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
+ );
557
560
}
558
561
};
559
562
@@ -712,10 +715,10 @@ class PartitionAnalysis {
712
715
static void performForFunction (SILFunction *function) {
713
716
auto analysis = PartitionAnalysis (function);
714
717
analysis.solve ();
715
- if (DEBUG) {
716
- llvm::dbgs () << " SOLVED: " ;
717
- analysis.dump ();
718
- }
718
+ LLVM_DEBUG (
719
+ llvm::dbgs () << " SOLVED: " ;
720
+ analysis.dump ();
721
+ );
719
722
analysis.diagnose ();
720
723
}
721
724
};
0 commit comments