Skip to content

Commit 8a20df1

Browse files
committed
[region-isolation] When dumping send never-sendable errors, dump the isolated value and its name if we can compute it.
This just makes it quicker/easier to diagnose inability to infer the appropriate name of an isolated value and what the isolated value itself is.
1 parent 2535ef0 commit 8a20df1

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

include/swift/SILOptimizer/Utils/SILIsolationInfo.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,12 @@ class SILIsolationInfo {
323323
return (kind == Task || kind == Actor) && bool(isolatedValue);
324324
}
325325

326+
SILValue maybeGetIsolatedValue() const {
327+
if (!hasIsolatedValue())
328+
return {};
329+
return getIsolatedValue();
330+
}
331+
326332
static SILIsolationInfo getDisconnected(bool isUnsafeNonIsolated) {
327333
return {Kind::Disconnected,
328334
isUnsafeNonIsolated ? Flag::UnsafeNonIsolated : Flag::None};

lib/SILOptimizer/Mandatory/TransferNonSendable.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2217,7 +2217,16 @@ struct DiagnosticEvaluator final
22172217
<< *info->getValueMap().getRepresentative(transferredVal)
22182218
<< " Dynamic Isolation Region: ";
22192219
isolationRegionInfo.printForOneLineLogging(llvm::dbgs());
2220-
llvm::dbgs() << '\n');
2220+
llvm::dbgs() << '\n';
2221+
if (auto isolatedValue = isolationRegionInfo->maybeGetIsolatedValue()) {
2222+
llvm::dbgs() << " Isolated Value: " << isolatedValue;
2223+
auto name = inferNameHelper(isolatedValue);
2224+
llvm::dbgs() << " Isolated Value Name: "
2225+
<< (name.has_value() ? name->get() : "none") << '\n';
2226+
} else {
2227+
llvm::dbgs() << " Isolated Value: none\n";
2228+
}
2229+
);
22212230
auto *self = const_cast<DiagnosticEvaluator *>(this);
22222231
auto nonTransferrableValue =
22232232
info->getValueMap().getRepresentative(transferredVal);

0 commit comments

Comments
 (0)