@@ -48,8 +48,6 @@ using namespace swift::PartitionPrimitives;
48
48
using namespace swift ::PatternMatch;
49
49
using namespace swift ::regionanalysisimpl;
50
50
51
- #ifndef NDEBUG
52
-
53
51
bool swift::regionanalysisimpl::AbortOnUnknownPatternMatchError = false ;
54
52
55
53
static llvm::cl::opt<bool , true > AbortOnUnknownPatternMatchErrorCmdLine (
@@ -60,8 +58,6 @@ static llvm::cl::opt<bool, true> AbortOnUnknownPatternMatchErrorCmdLine(
60
58
llvm::cl::location(
61
59
swift::regionanalysisimpl::AbortOnUnknownPatternMatchError));
62
60
63
- #endif
64
-
65
61
// ===----------------------------------------------------------------------===//
66
62
// MARK: Utilities
67
63
// ===----------------------------------------------------------------------===//
@@ -778,8 +774,9 @@ void PartialApplyReachabilityDataflow::add(Operand *op) {
778
774
assert (!propagatedReachability &&
779
775
" Cannot add more operands once reachability is computed" );
780
776
SILValue underlyingValue = getRootValue (op->get ());
781
- LLVM_DEBUG (llvm::dbgs () << " PartialApplyReachability::add.\n Value: "
782
- << underlyingValue << " User: " << *op->getUser ());
777
+ REGIONBASEDISOLATION_LOG (llvm::dbgs ()
778
+ << " PartialApplyReachability::add.\n Value: "
779
+ << underlyingValue << " User: " << *op->getUser ());
783
780
784
781
unsigned bit = getBitForValue (underlyingValue);
785
782
auto &state = blockData[op->getParentBlock ()];
@@ -899,8 +896,8 @@ void PartialApplyReachabilityDataflow::propagateReachability() {
899
896
}
900
897
}
901
898
902
- LLVM_DEBUG (llvm::dbgs () << " Propagating Captures Result!\n " ;
903
- print (llvm::dbgs ()));
899
+ REGIONBASEDISOLATION_LOG (llvm::dbgs () << " Propagating Captures Result!\n " ;
900
+ print (llvm::dbgs ()));
904
901
}
905
902
906
903
void PartialApplyReachabilityDataflow::print (llvm::raw_ostream &os) const {
@@ -1177,9 +1174,11 @@ struct PartitionOpBuilder {
1177
1174
1178
1175
Element srcID = lookupValueID (srcOperand->get ());
1179
1176
if (lookupValueID (destValue) == srcID) {
1180
- LLVM_DEBUG (llvm::dbgs () << " Skipping assign since tgt and src have "
1181
- " the same representative.\n " );
1182
- LLVM_DEBUG (llvm::dbgs () << " Rep ID: %%" << srcID.num << " .\n " );
1177
+ REGIONBASEDISOLATION_LOG (llvm::dbgs ()
1178
+ << " Skipping assign since tgt and src have "
1179
+ " the same representative.\n " );
1180
+ REGIONBASEDISOLATION_LOG (llvm::dbgs ()
1181
+ << " Rep ID: %%" << srcID.num << " .\n " );
1183
1182
return ;
1184
1183
}
1185
1184
@@ -1434,9 +1433,10 @@ class PartitionOpTranslator {
1434
1433
RegionAnalysisValueMap &valueMap;
1435
1434
1436
1435
void gatherFlowInsensitiveInformationBeforeDataflow () {
1437
- LLVM_DEBUG (llvm::dbgs () << " >>> Performing pre-dataflow scan to gather "
1438
- " flow insensitive information "
1439
- << function->getName () << " :\n " );
1436
+ REGIONBASEDISOLATION_LOG (llvm::dbgs ()
1437
+ << " >>> Performing pre-dataflow scan to gather "
1438
+ " flow insensitive information "
1439
+ << function->getName () << " :\n " );
1440
1440
1441
1441
for (auto &block : *function) {
1442
1442
for (auto &inst : block) {
@@ -1462,7 +1462,7 @@ class PartitionOpTranslator {
1462
1462
isNonSendableType (val->getType ())) {
1463
1463
auto trackVal = getTrackableValue (val, true );
1464
1464
(void )trackVal;
1465
- LLVM_DEBUG (trackVal.print (llvm::dbgs ()));
1465
+ REGIONBASEDISOLATION_LOG (trackVal.print (llvm::dbgs ()));
1466
1466
continue ;
1467
1467
}
1468
1468
if (auto *pbi = dyn_cast<ProjectBoxInst>(val)) {
@@ -1490,10 +1490,10 @@ class PartitionOpTranslator {
1490
1490
builder.translator = this ;
1491
1491
gatherFlowInsensitiveInformationBeforeDataflow ();
1492
1492
1493
- LLVM_DEBUG (llvm::dbgs () << " Initializing Function Args:\n " );
1493
+ REGIONBASEDISOLATION_LOG (llvm::dbgs () << " Initializing Function Args:\n " );
1494
1494
auto functionArguments = function->getArguments ();
1495
1495
if (functionArguments.empty ()) {
1496
- LLVM_DEBUG (llvm::dbgs () << " None.\n " );
1496
+ REGIONBASEDISOLATION_LOG (llvm::dbgs () << " None.\n " );
1497
1497
functionArgPartition = Partition::singleRegion (SILLocation::invalid (), {},
1498
1498
historyFactory.get ());
1499
1499
return ;
@@ -1510,19 +1510,20 @@ class PartitionOpTranslator {
1510
1510
// NOTE: We do not support today the ability to have multiple parameters
1511
1511
// transfer together as part of the same region.
1512
1512
if (isTransferrableFunctionArgument (cast<SILFunctionArgument>(arg))) {
1513
- LLVM_DEBUG (llvm::dbgs () << " %%" << state->getID ()
1514
- << " (transferring): " << *arg);
1513
+ REGIONBASEDISOLATION_LOG (llvm::dbgs () << " %%" << state->getID ()
1514
+ << " (transferring): " << *arg);
1515
1515
nonSendableSeparateIndices.push_back (state->getID ());
1516
1516
continue ;
1517
1517
}
1518
1518
1519
1519
// Otherwise, it is one of our merged parameters. Add it to the never
1520
1520
// transfer list and to the region join list.
1521
- LLVM_DEBUG (llvm::dbgs () << " %%" << state->getID () << " : " ;
1522
- state->print (llvm::dbgs ()); llvm::dbgs () << *arg);
1521
+ REGIONBASEDISOLATION_LOG (
1522
+ llvm::dbgs () << " %%" << state->getID () << " : " ;
1523
+ state->print (llvm::dbgs ()); llvm::dbgs () << *arg);
1523
1524
nonSendableJoinedIndices.push_back (state->getID ());
1524
1525
} else {
1525
- LLVM_DEBUG (llvm::dbgs () << " Sendable: " << *arg);
1526
+ REGIONBASEDISOLATION_LOG (llvm::dbgs () << " Sendable: " << *arg);
1526
1527
}
1527
1528
}
1528
1529
@@ -1665,7 +1666,7 @@ class PartitionOpTranslator {
1665
1666
// of our arguments (consider isolated to different actors) or with the
1666
1667
// isolationInfo we specified. Emit an unknown patten error.
1667
1668
if (!mergedInfo) {
1668
- LLVM_DEBUG (
1669
+ REGIONBASEDISOLATION_LOG (
1669
1670
llvm::dbgs () << " Merge Failure!\n "
1670
1671
<< " Original Info: " ;
1671
1672
if (originalMergedInfo)
@@ -1829,7 +1830,8 @@ class PartitionOpTranslator {
1829
1830
}
1830
1831
1831
1832
void translateSILPartialApplyAsyncLetBegin (PartialApplyInst *pai) {
1832
- LLVM_DEBUG (llvm::dbgs () << " Translating Async Let Begin Partial Apply!\n " );
1833
+ REGIONBASEDISOLATION_LOG (llvm::dbgs ()
1834
+ << " Translating Async Let Begin Partial Apply!\n " );
1833
1835
// Grab our partial apply and transfer all of its non-sendable
1834
1836
// parameters. We do not merge the parameters since each individual capture
1835
1837
// of the async let at the program level is viewed as still being in
@@ -1858,7 +1860,8 @@ class PartitionOpTranslator {
1858
1860
void translateIsolatedPartialApply (PartialApplyInst *pai,
1859
1861
SILIsolationInfo actorIsolation) {
1860
1862
ApplySite applySite (pai);
1861
- LLVM_DEBUG (llvm::dbgs () << " Translating Isolated Partial Apply!\n " );
1863
+ REGIONBASEDISOLATION_LOG (llvm::dbgs ()
1864
+ << " Translating Isolated Partial Apply!\n " );
1862
1865
1863
1866
// For each argument operand.
1864
1867
for (auto &op : applySite.getArgumentOperands ()) {
@@ -2346,15 +2349,16 @@ class PartitionOpTranslator {
2346
2349
// / that define the block's dataflow.
2347
2350
void translateSILBasicBlock (SILBasicBlock *basicBlock,
2348
2351
std::vector<PartitionOp> &foundPartitionOps) {
2349
- LLVM_DEBUG (llvm::dbgs () << SEP_STR << " Compiling basic block for function "
2350
- << basicBlock->getFunction ()->getName () << " : " ;
2351
- basicBlock->dumpID (); llvm::dbgs () << SEP_STR;
2352
- basicBlock->print (llvm::dbgs ());
2353
- llvm::dbgs () << SEP_STR << " Results:\n " ;);
2352
+ REGIONBASEDISOLATION_LOG (
2353
+ llvm::dbgs () << SEP_STR << " Compiling basic block for function "
2354
+ << basicBlock->getFunction ()->getName () << " : " ;
2355
+ basicBlock->dumpID (); llvm::dbgs () << SEP_STR;
2356
+ basicBlock->print (llvm::dbgs ());
2357
+ llvm::dbgs () << SEP_STR << " Results:\n " ;);
2354
2358
// Translate each SIL instruction to the PartitionOps that it represents if
2355
2359
// any.
2356
2360
for (auto &instruction : *basicBlock) {
2357
- LLVM_DEBUG (llvm::dbgs () << " Visiting: " << instruction);
2361
+ REGIONBASEDISOLATION_LOG (llvm::dbgs () << " Visiting: " << instruction);
2358
2362
translateSILInstruction (&instruction);
2359
2363
copy (builder.currentInstPartitionOps ,
2360
2364
std::back_inserter (foundPartitionOps));
@@ -2383,7 +2387,7 @@ class PartitionOpTranslator {
2383
2387
// / Top level switch that translates SIL instructions.
2384
2388
void translateSILInstruction (SILInstruction *inst) {
2385
2389
builder.reset (inst);
2386
- SWIFT_DEFER { LLVM_DEBUG (builder.print (llvm::dbgs ())); };
2390
+ SWIFT_DEFER { REGIONBASEDISOLATION_LOG (builder.print (llvm::dbgs ())); };
2387
2391
2388
2392
auto computeOpKind = [&]() -> TranslationSemantics {
2389
2393
switch (inst->getKind ()) {
@@ -2395,7 +2399,7 @@ class PartitionOpTranslator {
2395
2399
};
2396
2400
2397
2401
auto kind = computeOpKind ();
2398
- LLVM_DEBUG (llvm::dbgs () << " Semantics: " << kind << ' \n ' );
2402
+ REGIONBASEDISOLATION_LOG (llvm::dbgs () << " Semantics: " << kind << ' \n ' );
2399
2403
switch (kind) {
2400
2404
case TranslationSemantics::Ignored:
2401
2405
return ;
@@ -3170,7 +3174,8 @@ PartitionOpTranslator::visitRefElementAddrInst(RefElementAddrInst *reai) {
3170
3174
// And the field is a let... then ignore it. We know that we cannot race on
3171
3175
// any writes to the field.
3172
3176
if (reai->getField ()->isLet ()) {
3173
- LLVM_DEBUG (llvm::dbgs () << " Found a let! Not tracking!\n " );
3177
+ REGIONBASEDISOLATION_LOG (llvm::dbgs ()
3178
+ << " Found a let! Not tracking!\n " );
3174
3179
return TranslationSemantics::Ignored;
3175
3180
}
3176
3181
@@ -3189,7 +3194,7 @@ PartitionOpTranslator::visitRefTailAddrInst(RefTailAddrInst *reai) {
3189
3194
// And our ref_tail_addr is immutable... we can ignore the access since we
3190
3195
// cannot race against a write to any of these fields.
3191
3196
if (reai->isImmutable ()) {
3192
- LLVM_DEBUG (
3197
+ REGIONBASEDISOLATION_LOG (
3193
3198
llvm::dbgs ()
3194
3199
<< " Found an immutable Sendable ref_tail_addr! Not tracking!\n " );
3195
3200
return TranslationSemantics::Ignored;
@@ -3326,14 +3331,14 @@ bool BlockPartitionState::recomputeExitFromEntry(
3326
3331
// will be surpressed. will be suppressed
3327
3332
eval.apply (partitionOp);
3328
3333
}
3329
- LLVM_DEBUG (llvm::dbgs() << " Working Partition: " ;
3330
- workingPartition.print(llvm::dbgs()));
3334
+ REGIONBASEDISOLATION_LOG (llvm::dbgs() << " Working Partition: " ;
3335
+ workingPartition.print(llvm::dbgs()));
3331
3336
bool exitUpdated = !Partition::equals(exitPartition, workingPartition);
3332
3337
exitPartition = workingPartition;
3333
- LLVM_DEBUG (llvm::dbgs() << " Exit Partition: ";
3334
- exitPartition.print(llvm::dbgs()));
3335
- LLVM_DEBUG (llvm::dbgs() << " Updated Partition: "
3336
- << (exitUpdated ? " yes\n " : " no\n " ));
3338
+ REGIONBASEDISOLATION_LOG (llvm::dbgs() << " Exit Partition: ";
3339
+ exitPartition.print(llvm::dbgs()));
3340
+ REGIONBASEDISOLATION_LOG (llvm::dbgs() << " Updated Partition: "
3341
+ << (exitUpdated ? " yes\n " : " no\n " ));
3337
3342
return exitUpdated;
3338
3343
}
3339
3344
@@ -3389,7 +3394,8 @@ static bool canComputeRegionsForFunction(SILFunction *fn) {
3389
3394
}
3390
3395
3391
3396
if (!fn->hasOwnership ()) {
3392
- LLVM_DEBUG (llvm::dbgs () << " Only runs on Ownership SSA, skipping!\n " );
3397
+ REGIONBASEDISOLATION_LOG (llvm::dbgs ()
3398
+ << " Only runs on Ownership SSA, skipping!\n " );
3393
3399
return false ;
3394
3400
}
3395
3401
@@ -3453,9 +3459,10 @@ void RegionAnalysisFunctionInfo::runDataflow() {
3453
3459
assert (!solved && " solve should only be called once" );
3454
3460
solved = true ;
3455
3461
3456
- LLVM_DEBUG (llvm::dbgs () << SEP_STR << " Performing Dataflow!\n " << SEP_STR);
3457
- LLVM_DEBUG (llvm::dbgs () << " Values!\n " ;
3458
- translator->getValueMap ().print (llvm::dbgs ()));
3462
+ REGIONBASEDISOLATION_LOG (llvm::dbgs () << SEP_STR << " Performing Dataflow!\n "
3463
+ << SEP_STR);
3464
+ REGIONBASEDISOLATION_LOG (llvm::dbgs () << " Values!\n " ;
3465
+ translator->getValueMap ().print (llvm::dbgs ()));
3459
3466
3460
3467
bool anyNeedUpdate = true ;
3461
3468
while (anyNeedUpdate) {
@@ -3465,9 +3472,11 @@ void RegionAnalysisFunctionInfo::runDataflow() {
3465
3472
auto &blockState = (*blockStates)[block];
3466
3473
blockState.isLive = true ;
3467
3474
3468
- LLVM_DEBUG (llvm::dbgs () << " Block: bb" << block->getDebugID () << " \n " );
3475
+ REGIONBASEDISOLATION_LOG (llvm::dbgs ()
3476
+ << " Block: bb" << block->getDebugID () << " \n " );
3469
3477
if (!blockState.needsUpdate ) {
3470
- LLVM_DEBUG (llvm::dbgs () << " Doesn't need update! Skipping!\n " );
3478
+ REGIONBASEDISOLATION_LOG (llvm::dbgs ()
3479
+ << " Doesn't need update! Skipping!\n " );
3471
3480
continue ;
3472
3481
}
3473
3482
@@ -3477,7 +3486,7 @@ void RegionAnalysisFunctionInfo::runDataflow() {
3477
3486
// Compute the new entry partition to this block.
3478
3487
Partition newEntryPartition = blockState.entryPartition ;
3479
3488
3480
- LLVM_DEBUG (llvm::dbgs () << " Visiting Preds!\n " );
3489
+ REGIONBASEDISOLATION_LOG (llvm::dbgs () << " Visiting Preds!\n " );
3481
3490
3482
3491
// This loop computes the union of the exit partitions of all
3483
3492
// predecessors of this block
@@ -3486,9 +3495,9 @@ void RegionAnalysisFunctionInfo::runDataflow() {
3486
3495
3487
3496
// Predecessors that have not been reached yet will have an empty pred
3488
3497
// state... so just merge them all. Also our initial value of
3489
- LLVM_DEBUG ( llvm::dbgs ()
3490
- << " Pred. bb" << predBlock->getDebugID () << " : " ;
3491
- predState.exitPartition .print (llvm::dbgs ()));
3498
+ REGIONBASEDISOLATION_LOG (
3499
+ llvm::dbgs () << " Pred. bb" << predBlock->getDebugID () << " : " ;
3500
+ predState.exitPartition .print (llvm::dbgs ()));
3492
3501
newEntryPartition =
3493
3502
Partition::join (newEntryPartition, predState.exitPartition );
3494
3503
}
0 commit comments