File tree 4 files changed +40
-1
lines changed
include/swift/SILOptimizer/Analysis
4 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,12 @@ class BlockPartitionState {
61
61
// / Set if this block in the next iteration needs to be visited.
62
62
bool needsUpdate = false ;
63
63
64
+ // / Set if this block is live.
65
+ // /
66
+ // / If the block is not live, then we shouldnt try to emit diagnostics for it
67
+ // / since we will not have performed dataflow upon it.
68
+ bool isLive = false ;
69
+
64
70
// / The partition of elements into regions at the top of the block.
65
71
Partition entryPartition;
66
72
@@ -81,6 +87,8 @@ class BlockPartitionState {
81
87
TransferringOperandSetFactory &ptrSetFactory);
82
88
83
89
public:
90
+ bool getLiveness () const { return isLive; }
91
+
84
92
ArrayRef<PartitionOp> getPartitionOps () const { return blockPartitionOps; }
85
93
86
94
const Partition &getEntryPartition () const { return entryPartition; }
Original file line number Diff line number Diff line change @@ -3057,6 +3057,7 @@ void RegionAnalysisFunctionInfo::runDataflow() {
3057
3057
3058
3058
for (auto *block : pofi->getReversePostOrder ()) {
3059
3059
auto &blockState = (*blockStates)[block];
3060
+ blockState.isLive = true ;
3060
3061
3061
3062
LLVM_DEBUG (llvm::dbgs () << " Block: bb" << block->getDebugID () << " \n " );
3062
3063
if (!blockState.needsUpdate ) {
Original file line number Diff line number Diff line change @@ -1324,6 +1324,12 @@ void TransferNonSendableImpl::runDiagnosticEvaluator() {
1324
1324
LLVM_DEBUG (llvm::dbgs () << " Walking blocks for diagnostics.\n " );
1325
1325
for (auto [block, blockState] : regionInfo->getRange ()) {
1326
1326
LLVM_DEBUG (llvm::dbgs () << " |--> Block bb" << block.getDebugID () << " \n " );
1327
+
1328
+ if (!blockState.getLiveness ()) {
1329
+ LLVM_DEBUG (llvm::dbgs () << " Dead block... skipping!\n " );
1330
+ continue ;
1331
+ }
1332
+
1327
1333
LLVM_DEBUG (llvm::dbgs () << " Entry Partition: " ;
1328
1334
blockState.getEntryPartition ().print (llvm::dbgs ()));
1329
1335
Original file line number Diff line number Diff line change @@ -174,4 +174,28 @@ bb0:
174
174
dealloc_stack %2 : $*NonSendableKlass
175
175
%19 = tuple ()
176
176
return %19 : $()
177
- }
177
+ }
178
+
179
+ // Dead block crasher
180
+ //
181
+ // We used to crash here since we attempted to process /all/ blocks for
182
+ // diagnostic even for non-dead blocks. This is a problem since the dataflow
183
+ // uses a reverse post order traversal to get quick convergence and that skips
184
+ // dead blocks.
185
+ sil [ossa] @dead_block_crasher : $@convention(thin) @async () -> () {
186
+ bb0:
187
+ %0 = function_ref @constructNonSendableKlass : $@convention(thin) () -> @owned NonSendableKlass
188
+ %1 = apply %0() : $@convention(thin) () -> @owned NonSendableKlass
189
+ br bb1
190
+
191
+ bbDeadBlock:
192
+ %transfer = function_ref @transferNonSendableKlass : $@convention(thin) @async (@guaranteed NonSendableKlass) -> ()
193
+ apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %transfer(%1) : $@convention(thin) @async (@guaranteed NonSendableKlass) -> ()
194
+ br bb1
195
+
196
+ bb1:
197
+ destroy_value %1 : $NonSendableKlass
198
+ %9999 = tuple ()
199
+ return %9999 : $()
200
+ }
201
+
You can’t perform that action at this time.
0 commit comments