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