mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[rbi] Thread through a SILFunction into print routines so we can access LangOpts.Features so we can change how we print based off of NonisolatedNonsendingByDefault.
We do not actually use this information yet though... This is just to ease
review.
(cherry picked from commit 4433ab8d81)
This commit is contained in:
@@ -179,16 +179,16 @@ public:
|
||||
|
||||
void removeFlag(TrackableValueFlag flag) { flagSet -= flag; }
|
||||
|
||||
void print(llvm::raw_ostream &os) const {
|
||||
void print(SILFunction *fn, llvm::raw_ostream &os) const {
|
||||
os << "TrackableValueState[id: " << id
|
||||
<< "][is_no_alias: " << (isNoAlias() ? "yes" : "no")
|
||||
<< "][is_sendable: " << (isSendable() ? "yes" : "no")
|
||||
<< "][region_value_kind: ";
|
||||
getIsolationRegionInfo().printForOneLineLogging(os);
|
||||
getIsolationRegionInfo().printForOneLineLogging(fn, os);
|
||||
os << "].";
|
||||
}
|
||||
|
||||
SWIFT_DEBUG_DUMP { print(llvm::dbgs()); }
|
||||
SWIFT_DEBUG_DUMPER(dump(SILFunction *fn)) { print(fn, llvm::dbgs()); }
|
||||
|
||||
private:
|
||||
bool hasIsolationRegionInfo() const { return bool(regionInfo); }
|
||||
@@ -249,26 +249,26 @@ public:
|
||||
/// parameter.
|
||||
bool isSendingParameter() const;
|
||||
|
||||
void printIsolationInfo(SmallString<64> &outString) const {
|
||||
void printIsolationInfo(SILFunction *fn, SmallString<64> &outString) const {
|
||||
llvm::raw_svector_ostream os(outString);
|
||||
getIsolationRegionInfo().printForDiagnostics(os);
|
||||
getIsolationRegionInfo().printForDiagnostics(fn, os);
|
||||
}
|
||||
|
||||
void print(llvm::raw_ostream &os) const {
|
||||
void print(SILFunction *fn, llvm::raw_ostream &os) const {
|
||||
os << "TrackableValue. State: ";
|
||||
valueState.print(os);
|
||||
valueState.print(fn, os);
|
||||
os << "\n Rep Value: ";
|
||||
getRepresentative().print(os);
|
||||
}
|
||||
|
||||
void printVerbose(llvm::raw_ostream &os) const {
|
||||
void printVerbose(SILFunction *fn, llvm::raw_ostream &os) const {
|
||||
os << "TrackableValue. State: ";
|
||||
valueState.print(os);
|
||||
valueState.print(fn, os);
|
||||
os << "\n Rep Value: " << getRepresentative();
|
||||
}
|
||||
|
||||
SWIFT_DEBUG_DUMP {
|
||||
print(llvm::dbgs());
|
||||
SWIFT_DEBUG_DUMPER(dump(SILFunction *fn)) {
|
||||
print(fn, llvm::dbgs());
|
||||
llvm::dbgs() << '\n';
|
||||
}
|
||||
};
|
||||
@@ -288,8 +288,8 @@ struct regionanalysisimpl::TrackableValueLookupResult {
|
||||
/// TrackableValue.
|
||||
std::optional<TrackableValue> base;
|
||||
|
||||
void print(llvm::raw_ostream &os) const;
|
||||
SWIFT_DEBUG_DUMP { print(llvm::dbgs()); }
|
||||
void print(SILFunction *fn, llvm::raw_ostream &os) const;
|
||||
SWIFT_DEBUG_DUMPER(dumper(SILFunction *fn)) { print(fn, llvm::dbgs()); }
|
||||
};
|
||||
|
||||
class RegionAnalysis;
|
||||
@@ -390,6 +390,8 @@ public:
|
||||
return getUnderlyingTrackedValue(value).value;
|
||||
}
|
||||
|
||||
SILFunction *getFunction() const { return fn; }
|
||||
|
||||
/// Returns the value for this instruction if it isn't a fake "represenative
|
||||
/// value" to inject actor isolatedness. Asserts in such a case.
|
||||
SILValue getRepresentative(Element trackableValueID) const;
|
||||
|
||||
@@ -337,16 +337,16 @@ public:
|
||||
return self;
|
||||
}
|
||||
|
||||
void print(llvm::raw_ostream &os) const;
|
||||
void print(SILFunction *fn, llvm::raw_ostream &os) const;
|
||||
|
||||
/// Print a textual representation of the text info that is meant to be
|
||||
/// included in other logging output for types that compose with
|
||||
/// SILIsolationInfo. As a result, we only print state that can fit on
|
||||
/// one line.
|
||||
void printForOneLineLogging(llvm::raw_ostream &os) const;
|
||||
void printForOneLineLogging(SILFunction *fn, llvm::raw_ostream &os) const;
|
||||
|
||||
SWIFT_DEBUG_DUMP {
|
||||
print(llvm::dbgs());
|
||||
SWIFT_DEBUG_DUMPER(dump(SILFunction *fn)) {
|
||||
print(fn, llvm::dbgs());
|
||||
llvm::dbgs() << '\n';
|
||||
}
|
||||
|
||||
@@ -355,12 +355,12 @@ public:
|
||||
///
|
||||
/// We do this programatically since task-isolated code needs a very different
|
||||
/// form of diagnostic than other cases.
|
||||
void printForCodeDiagnostic(llvm::raw_ostream &os) const;
|
||||
void printForCodeDiagnostic(SILFunction *fn, llvm::raw_ostream &os) const;
|
||||
|
||||
void printForDiagnostics(llvm::raw_ostream &os) const;
|
||||
void printForDiagnostics(SILFunction *fn, llvm::raw_ostream &os) const;
|
||||
|
||||
SWIFT_DEBUG_DUMPER(dumpForDiagnostics()) {
|
||||
printForDiagnostics(llvm::dbgs());
|
||||
SWIFT_DEBUG_DUMPER(dumpForDiagnostics(SILFunction *fn)) {
|
||||
printForDiagnostics(fn, llvm::dbgs());
|
||||
llvm::dbgs() << '\n';
|
||||
}
|
||||
|
||||
@@ -552,10 +552,9 @@ public:
|
||||
/// A helper function that prints ActorIsolation like we normally do except
|
||||
/// that it prints nonisolated(nonsending) as nonisolated. This is needed in
|
||||
/// certain cases when talking about use-after-free uses in send non sendable.
|
||||
static void
|
||||
printActorIsolationForDiagnostics(ActorIsolation iso, llvm::raw_ostream &os,
|
||||
StringRef openingQuotationMark = "'",
|
||||
bool asNoun = false);
|
||||
static void printActorIsolationForDiagnostics(
|
||||
SILFunction *fn, ActorIsolation iso, llvm::raw_ostream &os,
|
||||
StringRef openingQuotationMark = "'", bool asNoun = false);
|
||||
|
||||
void Profile(llvm::FoldingSetNodeID &id) const;
|
||||
|
||||
@@ -620,43 +619,25 @@ public:
|
||||
SILIsolationInfo::getDisconnected(isUnsafeNonIsolated));
|
||||
}
|
||||
|
||||
SWIFT_DEBUG_DUMP { innerInfo.dump(); }
|
||||
SWIFT_DEBUG_DUMPER(dump(SILFunction *fn)) { innerInfo.dump(fn); }
|
||||
|
||||
void printForDiagnostics(llvm::raw_ostream &os) const {
|
||||
innerInfo.printForDiagnostics(os);
|
||||
void printForDiagnostics(SILFunction *fn, llvm::raw_ostream &os) const {
|
||||
innerInfo.printForDiagnostics(fn, os);
|
||||
}
|
||||
|
||||
SWIFT_DEBUG_DUMPER(dumpForDiagnostics()) {
|
||||
innerInfo.dumpForDiagnostics();
|
||||
SWIFT_DEBUG_DUMPER(dumpForDiagnostics(SILFunction *fn)) {
|
||||
innerInfo.dumpForDiagnostics(fn);
|
||||
}
|
||||
|
||||
void printForCodeDiagnostic(llvm::raw_ostream &os) const {
|
||||
innerInfo.printForCodeDiagnostic(os);
|
||||
void printForCodeDiagnostic(SILFunction *fn, llvm::raw_ostream &os) const {
|
||||
innerInfo.printForCodeDiagnostic(fn, os);
|
||||
}
|
||||
|
||||
void printForOneLineLogging(llvm::raw_ostream &os) const {
|
||||
innerInfo.printForOneLineLogging(os);
|
||||
void printForOneLineLogging(SILFunction *fn, llvm::raw_ostream &os) const {
|
||||
innerInfo.printForOneLineLogging(fn, os);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace swift
|
||||
|
||||
namespace llvm {
|
||||
|
||||
inline llvm::raw_ostream &
|
||||
operator<<(llvm::raw_ostream &os,
|
||||
const swift::SILIsolationInfo &isolationInfo) {
|
||||
isolationInfo.printForOneLineLogging(os);
|
||||
return os;
|
||||
}
|
||||
|
||||
inline llvm::raw_ostream &
|
||||
operator<<(llvm::raw_ostream &os,
|
||||
const swift::SILDynamicMergedIsolationInfo &isolationInfo) {
|
||||
isolationInfo.printForOneLineLogging(os);
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace llvm
|
||||
|
||||
#endif
|
||||
|
||||
@@ -820,7 +820,7 @@ void RegionAnalysisValueMap::print(llvm::raw_ostream &os) const {
|
||||
for (auto p : temp) {
|
||||
os << "%%" << p.first << ": ";
|
||||
auto value = getValueForId(Element(p.first));
|
||||
value->print(os);
|
||||
value->print(getFunction(), os);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1127,12 +1127,13 @@ bool TrackableValue::isSendingParameter() const {
|
||||
// MARK: TrackableValueLookupResult
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
void TrackableValueLookupResult::print(llvm::raw_ostream &os) const {
|
||||
void TrackableValueLookupResult::print(SILFunction *fn,
|
||||
llvm::raw_ostream &os) const {
|
||||
os << "Value:\n";
|
||||
value.print(os);
|
||||
value.print(fn, os);
|
||||
if (base) {
|
||||
os << "Base:\n";
|
||||
base->print(os);
|
||||
base->print(fn, os);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1618,6 +1619,11 @@ struct PartitionOpBuilder {
|
||||
/// generating partition ops.
|
||||
SmallVector<PartitionOp, 8> currentInstPartitionOps;
|
||||
|
||||
SILFunction *getFunction() const {
|
||||
assert(currentInst);
|
||||
return currentInst->getFunction();
|
||||
}
|
||||
|
||||
void reset(SILInstruction *inst) {
|
||||
currentInst = inst;
|
||||
currentInstPartitionOps.clear();
|
||||
@@ -1978,7 +1984,8 @@ class PartitionOpTranslator {
|
||||
isNonSendableType(val->getType())) {
|
||||
auto trackVal = getTrackableValue(val, true);
|
||||
(void)trackVal;
|
||||
REGIONBASEDISOLATION_LOG(trackVal.print(llvm::dbgs()));
|
||||
REGIONBASEDISOLATION_LOG(
|
||||
trackVal.print(val->getFunction(), llvm::dbgs()));
|
||||
continue;
|
||||
}
|
||||
if (auto *pbi = dyn_cast<ProjectBoxInst>(val)) {
|
||||
@@ -2055,7 +2062,7 @@ public:
|
||||
// send list and to the region join list.
|
||||
REGIONBASEDISOLATION_LOG(
|
||||
llvm::dbgs() << " %%" << value.getID() << ": ";
|
||||
value.print(llvm::dbgs()); llvm::dbgs() << *arg);
|
||||
value.print(function, llvm::dbgs()); llvm::dbgs() << *arg);
|
||||
nonSendableJoinedIndices.push_back(value.getID());
|
||||
} else {
|
||||
REGIONBASEDISOLATION_LOG(llvm::dbgs() << " Sendable: " << *arg);
|
||||
@@ -2228,14 +2235,15 @@ public:
|
||||
REGIONBASEDISOLATION_LOG(
|
||||
llvm::dbgs() << "Merge Failure!\n"
|
||||
<< "Original Info: ";
|
||||
if (originalMergedInfo)
|
||||
originalMergedInfo->printForDiagnostics(llvm::dbgs());
|
||||
if (originalMergedInfo) originalMergedInfo->printForDiagnostics(
|
||||
builder.getFunction(), llvm::dbgs());
|
||||
else llvm::dbgs() << "nil";
|
||||
llvm::dbgs() << "\nValue Rep: "
|
||||
<< value.getRepresentative().getValue();
|
||||
llvm::dbgs() << "Original Src: " << src;
|
||||
llvm::dbgs() << "Value Info: ";
|
||||
value.getIsolationRegionInfo().printForDiagnostics(llvm::dbgs());
|
||||
value.getIsolationRegionInfo().printForDiagnostics(
|
||||
builder.getFunction(), llvm::dbgs());
|
||||
llvm::dbgs() << "\n");
|
||||
builder.addUnknownPatternError(src);
|
||||
continue;
|
||||
@@ -3220,7 +3228,7 @@ void PartitionOpBuilder::print(llvm::raw_ostream &os) const {
|
||||
auto trackableValue = translator->getValueForId(opArg);
|
||||
assert(trackableValue);
|
||||
llvm::dbgs() << "State: %%" << opArg << ". ";
|
||||
trackableValue->getValueState().print(llvm::dbgs());
|
||||
trackableValue->getValueState().print(getFunction(), llvm::dbgs());
|
||||
llvm::dbgs() << "\n Rep Value: "
|
||||
<< trackableValue->getRepresentative();
|
||||
if (auto value = trackableValue->getRepresentative().maybeGetValue()) {
|
||||
@@ -4310,7 +4318,7 @@ static FunctionTest
|
||||
RegionAnalysisValueMap valueMap(&function);
|
||||
auto value = arguments.takeValue();
|
||||
auto trackableValue = valueMap.getTrackableValue(value);
|
||||
trackableValue.print(llvm::outs());
|
||||
trackableValue.print(&function, llvm::outs());
|
||||
llvm::outs() << '\n';
|
||||
});
|
||||
|
||||
|
||||
@@ -690,7 +690,7 @@ public:
|
||||
{
|
||||
if (!namedValuesIsolationInfo.isDisconnected()) {
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
namedValuesIsolationInfo.printForDiagnostics(os);
|
||||
namedValuesIsolationInfo.printForDiagnostics(getFunction(), os);
|
||||
os << ' ';
|
||||
}
|
||||
}
|
||||
@@ -699,14 +699,14 @@ public:
|
||||
{
|
||||
llvm::raw_svector_ostream os(calleeIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
isolationCrossing.getCalleeIsolation(), os);
|
||||
getFunction(), isolationCrossing.getCalleeIsolation(), os);
|
||||
}
|
||||
|
||||
SmallString<64> callerIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(callerIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
isolationCrossing.getCallerIsolation(), os);
|
||||
getFunction(), isolationCrossing.getCallerIsolation(), os);
|
||||
}
|
||||
|
||||
if (auto callee = getSendingCallee()) {
|
||||
@@ -737,7 +737,7 @@ public:
|
||||
{
|
||||
if (!namedValuesIsolationInfo.isDisconnected()) {
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
namedValuesIsolationInfo.printForDiagnostics(os);
|
||||
namedValuesIsolationInfo.printForDiagnostics(getFunction(), os);
|
||||
os << ' ';
|
||||
}
|
||||
}
|
||||
@@ -746,14 +746,14 @@ public:
|
||||
{
|
||||
llvm::raw_svector_ostream os(calleeIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
isolationCrossing.getCalleeIsolation(), os);
|
||||
getFunction(), isolationCrossing.getCalleeIsolation(), os);
|
||||
}
|
||||
|
||||
SmallString<64> callerIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(callerIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
isolationCrossing.getCallerIsolation(), os);
|
||||
getFunction(), isolationCrossing.getCallerIsolation(), os);
|
||||
}
|
||||
|
||||
diagnoseNote(loc,
|
||||
@@ -786,14 +786,14 @@ public:
|
||||
{
|
||||
llvm::raw_svector_ostream os(calleeIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
isolationCrossing.getCalleeIsolation(), os);
|
||||
getFunction(), isolationCrossing.getCalleeIsolation(), os);
|
||||
}
|
||||
|
||||
SmallString<64> callerIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(callerIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
isolationCrossing.getCallerIsolation(), os);
|
||||
getFunction(), isolationCrossing.getCallerIsolation(), os);
|
||||
}
|
||||
|
||||
if (auto callee = getSendingCallee()) {
|
||||
@@ -852,7 +852,7 @@ public:
|
||||
{
|
||||
if (!namedValuesIsolationInfo.isDisconnected()) {
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
namedValuesIsolationInfo.printForDiagnostics(os);
|
||||
namedValuesIsolationInfo.printForDiagnostics(getFunction(), os);
|
||||
os << ' ';
|
||||
}
|
||||
}
|
||||
@@ -861,14 +861,14 @@ public:
|
||||
{
|
||||
llvm::raw_svector_ostream os(calleeIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
isolationCrossing.getCalleeIsolation(), os);
|
||||
getFunction(), isolationCrossing.getCalleeIsolation(), os);
|
||||
}
|
||||
|
||||
SmallString<64> callerIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(callerIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
isolationCrossing.getCallerIsolation(), os);
|
||||
getFunction(), isolationCrossing.getCallerIsolation(), os);
|
||||
}
|
||||
|
||||
diagnoseNote(
|
||||
@@ -890,14 +890,14 @@ public:
|
||||
{
|
||||
llvm::raw_svector_ostream os(calleeIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
isolationCrossing.getCalleeIsolation(), os);
|
||||
getFunction(), isolationCrossing.getCalleeIsolation(), os);
|
||||
}
|
||||
|
||||
SmallString<64> callerIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(callerIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
isolationCrossing.getCallerIsolation(), os);
|
||||
getFunction(), isolationCrossing.getCallerIsolation(), os);
|
||||
}
|
||||
|
||||
diagnoseNote(loc,
|
||||
@@ -1441,14 +1441,14 @@ public:
|
||||
SmallString<64> descriptiveKindStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().printForDiagnostics(os);
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction(), os);
|
||||
}
|
||||
|
||||
SmallString<64> calleeIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(calleeIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
crossing.getCalleeIsolation(), os);
|
||||
getFunction(), crossing.getCalleeIsolation(), os);
|
||||
}
|
||||
|
||||
if (auto callee = getSendingCallee()) {
|
||||
@@ -1470,7 +1470,7 @@ public:
|
||||
{
|
||||
if (!getIsolationRegionInfo().isDisconnected()) {
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().printForDiagnostics(os);
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction(), os);
|
||||
os << ' ';
|
||||
}
|
||||
}
|
||||
@@ -1479,14 +1479,14 @@ public:
|
||||
{
|
||||
llvm::raw_svector_ostream os(calleeIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
crossing.getCalleeIsolation(), os);
|
||||
getFunction(), crossing.getCalleeIsolation(), os);
|
||||
}
|
||||
|
||||
SmallString<64> callerIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(callerIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
crossing.getCallerIsolation(), os);
|
||||
getFunction(), crossing.getCallerIsolation(), os);
|
||||
}
|
||||
|
||||
diagnoseNote(
|
||||
@@ -1505,7 +1505,7 @@ public:
|
||||
SmallString<64> descriptiveKindStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().printForDiagnostics(os);
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction(), os);
|
||||
}
|
||||
|
||||
if (auto callee = getSendingCallee()) {
|
||||
@@ -1527,7 +1527,8 @@ public:
|
||||
SmallString<64> descriptiveKindStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().getIsolationInfo().printForCodeDiagnostic(os);
|
||||
getIsolationRegionInfo().getIsolationInfo().printForCodeDiagnostic(
|
||||
getFunction(), os);
|
||||
}
|
||||
|
||||
diagnoseError(partialApplyOp,
|
||||
@@ -1539,7 +1540,8 @@ public:
|
||||
descriptiveKindStr.clear();
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().getIsolationInfo().printForDiagnostics(os);
|
||||
getIsolationRegionInfo().getIsolationInfo().printForDiagnostics(
|
||||
getFunction(), os);
|
||||
}
|
||||
diagnoseNote(actualUse, diag::regionbasedisolation_closure_captures_actor,
|
||||
fArg->getDecl()->getName(), descriptiveKindStr);
|
||||
@@ -1558,7 +1560,8 @@ public:
|
||||
SmallString<64> descriptiveKindStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().getIsolationInfo().printForCodeDiagnostic(os);
|
||||
getIsolationRegionInfo().getIsolationInfo().printForCodeDiagnostic(
|
||||
getFunction(), os);
|
||||
}
|
||||
|
||||
diagnoseError(partialApplyOp,
|
||||
@@ -1586,7 +1589,7 @@ public:
|
||||
descriptiveKindStr.clear();
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().printForDiagnostics(os);
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction(), os);
|
||||
}
|
||||
|
||||
auto diag = diag::
|
||||
@@ -1607,7 +1610,7 @@ public:
|
||||
SmallString<64> descriptiveKindStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo()->printForCodeDiagnostic(os);
|
||||
getIsolationRegionInfo()->printForCodeDiagnostic(getFunction(), os);
|
||||
}
|
||||
|
||||
auto emitMainError = [&] {
|
||||
@@ -1643,7 +1646,7 @@ public:
|
||||
descriptiveKindStr.clear();
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().printForDiagnostics(os);
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction(), os);
|
||||
}
|
||||
auto diag = diag::
|
||||
regionbasedisolation_typed_tns_passed_to_sending_closure_helper_have_value_region;
|
||||
@@ -1688,7 +1691,7 @@ public:
|
||||
SmallString<64> descriptiveKindStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().printForDiagnostics(os);
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction(), os);
|
||||
}
|
||||
|
||||
diagnoseNote(loc, diag::regionbasedisolation_named_send_nt_asynclet_capture,
|
||||
@@ -1704,7 +1707,7 @@ public:
|
||||
if (!getIsolationRegionInfo().isDisconnected()) {
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().printForDiagnostics(os);
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction(), os);
|
||||
}
|
||||
descriptiveKindStrWithSpace = descriptiveKindStr;
|
||||
descriptiveKindStrWithSpace.push_back(' ');
|
||||
@@ -1715,7 +1718,7 @@ public:
|
||||
{
|
||||
llvm::raw_svector_ostream os(calleeIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
isolationCrossing.getCalleeIsolation(), os);
|
||||
getFunction(), isolationCrossing.getCalleeIsolation(), os);
|
||||
}
|
||||
|
||||
if (auto callee = getSendingCallee()) {
|
||||
@@ -1737,7 +1740,7 @@ public:
|
||||
{
|
||||
if (!getIsolationRegionInfo().isDisconnected()) {
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().printForDiagnostics(os);
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction(), os);
|
||||
os << ' ';
|
||||
}
|
||||
}
|
||||
@@ -1753,7 +1756,7 @@ public:
|
||||
if (!getIsolationRegionInfo().isDisconnected()) {
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().printForDiagnostics(os);
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction(), os);
|
||||
}
|
||||
descriptiveKindStrWithSpace = descriptiveKindStr;
|
||||
descriptiveKindStrWithSpace.push_back(' ');
|
||||
@@ -2316,7 +2319,7 @@ void InOutSendingNotDisconnectedDiagnosticEmitter::emit() {
|
||||
SmallString<64> descriptiveKindStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
actorIsolatedRegionInfo.printForDiagnostics(os);
|
||||
actorIsolatedRegionInfo.printForDiagnostics(getFunction(), os);
|
||||
os << ' ';
|
||||
}
|
||||
|
||||
@@ -2476,7 +2479,7 @@ void AssignIsolatedIntoSendingResultDiagnosticEmitter::emit() {
|
||||
SmallString<64> descriptiveKindStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
isolatedValueIsolationRegionInfo.printForDiagnostics(os);
|
||||
isolatedValueIsolationRegionInfo.printForDiagnostics(getFunction(), os);
|
||||
}
|
||||
|
||||
// Grab the var name if we can find it.
|
||||
@@ -2601,6 +2604,10 @@ struct NonSendableIsolationCrossingResultDiagnosticEmitter {
|
||||
: valueMap(valueMap), error(error),
|
||||
representative(valueMap.getRepresentative(error.returnValueElement)) {}
|
||||
|
||||
SILFunction *getFunction() const {
|
||||
return error.op->getSourceInst()->getFunction();
|
||||
}
|
||||
|
||||
void emit();
|
||||
|
||||
ASTContext &getASTContext() const {
|
||||
@@ -2721,14 +2728,14 @@ void NonSendableIsolationCrossingResultDiagnosticEmitter::emit() {
|
||||
{
|
||||
llvm::raw_svector_ostream os(calleeIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
isolationCrossing->getCalleeIsolation(), os);
|
||||
getFunction(), isolationCrossing->getCalleeIsolation(), os);
|
||||
}
|
||||
|
||||
SmallString<64> callerIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(callerIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
isolationCrossing->getCallerIsolation(), os);
|
||||
getFunction(), isolationCrossing->getCallerIsolation(), os);
|
||||
}
|
||||
|
||||
auto type = getType();
|
||||
|
||||
@@ -46,7 +46,7 @@ void PartitionOpError::SentNeverSendableError::print(
|
||||
<< " ID: %%" << sentElement << "\n"
|
||||
<< " Rep: " << *info.getRepresentative(sentElement)
|
||||
<< " Dynamic Isolation Region: ";
|
||||
isolationRegionInfo.printForOneLineLogging(os);
|
||||
isolationRegionInfo.printForOneLineLogging(info.getFunction(), os);
|
||||
os << '\n';
|
||||
if (auto isolatedValue = isolationRegionInfo->maybeGetIsolatedValue()) {
|
||||
os << " Isolated Value: " << isolatedValue;
|
||||
@@ -90,7 +90,7 @@ void PartitionOpError::InOutSendingNotDisconnectedAtExitError::print(
|
||||
<< " ID: %%" << inoutSendingElement << "\n"
|
||||
<< " Rep: " << valueMap.getRepresentativeValue(inoutSendingElement)
|
||||
<< " Dynamic Isolation Region: ";
|
||||
isolationInfo.printForOneLineLogging(os);
|
||||
isolationInfo.printForOneLineLogging(valueMap.getFunction(), os);
|
||||
os << '\n';
|
||||
}
|
||||
|
||||
|
||||
@@ -1237,15 +1237,13 @@ void SILIsolationInfo::printOptions(llvm::raw_ostream &os) const {
|
||||
llvm::interleave(data, os, ", ");
|
||||
}
|
||||
|
||||
/// We want to treat nonisolated(nonsending) just like nonisolated. So we use
|
||||
/// this with composition.
|
||||
void SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
ActorIsolation iso, llvm::raw_ostream &os, StringRef openingQuotationMark,
|
||||
bool asNoun) {
|
||||
SILFunction *fn, ActorIsolation iso, llvm::raw_ostream &os,
|
||||
StringRef openingQuotationMark, bool asNoun) {
|
||||
return iso.printForDiagnostics(os, openingQuotationMark, asNoun);
|
||||
}
|
||||
|
||||
void SILIsolationInfo::print(llvm::raw_ostream &os) const {
|
||||
void SILIsolationInfo::print(SILFunction *fn, llvm::raw_ostream &os) const {
|
||||
switch (Kind(*this)) {
|
||||
case Unknown:
|
||||
os << "unknown";
|
||||
@@ -1292,7 +1290,7 @@ void SILIsolationInfo::print(llvm::raw_ostream &os) const {
|
||||
}
|
||||
}
|
||||
|
||||
printActorIsolationForDiagnostics(getActorIsolation(), os);
|
||||
printActorIsolationForDiagnostics(fn, getActorIsolation(), os);
|
||||
printOptions(os);
|
||||
return;
|
||||
case Task:
|
||||
@@ -1379,7 +1377,8 @@ void SILIsolationInfo::Profile(llvm::FoldingSetNodeID &id) const {
|
||||
}
|
||||
}
|
||||
|
||||
void SILIsolationInfo::printForDiagnostics(llvm::raw_ostream &os) const {
|
||||
void SILIsolationInfo::printForDiagnostics(SILFunction *fn,
|
||||
llvm::raw_ostream &os) const {
|
||||
switch (Kind(*this)) {
|
||||
case Unknown:
|
||||
llvm::report_fatal_error("Printing unknown for diagnostics?!");
|
||||
@@ -1414,7 +1413,7 @@ void SILIsolationInfo::printForDiagnostics(llvm::raw_ostream &os) const {
|
||||
}
|
||||
}
|
||||
|
||||
printActorIsolationForDiagnostics(getActorIsolation(), os);
|
||||
printActorIsolationForDiagnostics(fn, getActorIsolation(), os);
|
||||
return;
|
||||
case Task:
|
||||
os << "task-isolated";
|
||||
@@ -1422,7 +1421,8 @@ void SILIsolationInfo::printForDiagnostics(llvm::raw_ostream &os) const {
|
||||
}
|
||||
}
|
||||
|
||||
void SILIsolationInfo::printForCodeDiagnostic(llvm::raw_ostream &os) const {
|
||||
void SILIsolationInfo::printForCodeDiagnostic(SILFunction *fn,
|
||||
llvm::raw_ostream &os) const {
|
||||
switch (Kind(*this)) {
|
||||
case Unknown:
|
||||
llvm::report_fatal_error("Printing unknown for code diagnostic?!");
|
||||
@@ -1457,7 +1457,7 @@ void SILIsolationInfo::printForCodeDiagnostic(llvm::raw_ostream &os) const {
|
||||
}
|
||||
}
|
||||
|
||||
printActorIsolationForDiagnostics(getActorIsolation(), os);
|
||||
printActorIsolationForDiagnostics(fn, getActorIsolation(), os);
|
||||
os << " code";
|
||||
return;
|
||||
case Task:
|
||||
@@ -1466,7 +1466,8 @@ void SILIsolationInfo::printForCodeDiagnostic(llvm::raw_ostream &os) const {
|
||||
}
|
||||
}
|
||||
|
||||
void SILIsolationInfo::printForOneLineLogging(llvm::raw_ostream &os) const {
|
||||
void SILIsolationInfo::printForOneLineLogging(SILFunction *fn,
|
||||
llvm::raw_ostream &os) const {
|
||||
switch (Kind(*this)) {
|
||||
case Unknown:
|
||||
os << "unknown";
|
||||
@@ -1506,7 +1507,7 @@ void SILIsolationInfo::printForOneLineLogging(llvm::raw_ostream &os) const {
|
||||
}
|
||||
}
|
||||
|
||||
printActorIsolationForDiagnostics(getActorIsolation(), os);
|
||||
printActorIsolationForDiagnostics(fn, getActorIsolation(), os);
|
||||
printOptions(os);
|
||||
return;
|
||||
case Task:
|
||||
@@ -1713,7 +1714,8 @@ static FunctionTest
|
||||
SILIsolationInfo::get(value);
|
||||
llvm::outs() << "Input Value: " << *value;
|
||||
llvm::outs() << "Isolation: ";
|
||||
info.printForOneLineLogging(llvm::outs());
|
||||
info.printForOneLineLogging(&function,
|
||||
llvm::outs());
|
||||
llvm::outs() << "\n";
|
||||
});
|
||||
|
||||
@@ -1733,13 +1735,13 @@ static FunctionTest IsolationMergeTest(
|
||||
mergedInfo = mergedInfo->merge(secondValueInfo);
|
||||
llvm::outs() << "First Value: " << *firstValue;
|
||||
llvm::outs() << "First Isolation: ";
|
||||
firstValueInfo.printForOneLineLogging(llvm::outs());
|
||||
firstValueInfo.printForOneLineLogging(&function, llvm::outs());
|
||||
llvm::outs() << "\nSecond Value: " << *secondValue;
|
||||
llvm::outs() << "Second Isolation: ";
|
||||
secondValueInfo.printForOneLineLogging(llvm::outs());
|
||||
secondValueInfo.printForOneLineLogging(&function, llvm::outs());
|
||||
llvm::outs() << "\nMerged Isolation: ";
|
||||
if (mergedInfo) {
|
||||
mergedInfo->printForOneLineLogging(llvm::outs());
|
||||
mergedInfo->printForOneLineLogging(&function, llvm::outs());
|
||||
} else {
|
||||
llvm::outs() << "Merge failure!";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user