mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[sil] Add the ability to mark a function with isolation just so we can write more concurrency tests in SIL.
Specifically, we write a string out like: sil [isolation "$REPRESENTATION OF ISOLATION"] @function : $@convention(thin) ... The idea is that by using a string, we avoid parsing issues of the isolation and have flexibility. I left in the way we put isolation into the comment above functions so I did not break any tests that rely on it. I also made it so that we only accept this with sil tests that pass in the flag "sil-print-function-isolation-info". I am going to for the next release put in a full real implementation of this that allows for actor isolation to become a true first class citizen in SIL. But for now this at least lets us write tests in the short term. Since this is temporary and behind a flag, I did not add support for serialization since this is just for writing textual SIL tests.
This commit is contained in:
@@ -95,6 +95,11 @@ llvm::cl::opt<bool> SILPrintGenericSpecializationInfo(
|
||||
llvm::cl::desc("Include generic specialization"
|
||||
"information info in SIL output"));
|
||||
|
||||
llvm::cl::opt<bool> SILPrintFunctionIsolationInfo(
|
||||
"sil-print-function-isolation-info", llvm::cl::init(false),
|
||||
llvm::cl::desc("Print out isolation info on functions in a manner that SIL "
|
||||
"understands [e.x.: not in comments]"));
|
||||
|
||||
static std::string demangleSymbol(StringRef Name) {
|
||||
if (SILFullDemangle)
|
||||
return Demangle::demangleSymbolAsString(Name);
|
||||
@@ -3630,6 +3635,15 @@ void SILFunction::print(SILPrintContext &PrintCtx) const {
|
||||
OS << "[available " << availability.getVersionString() << "] ";
|
||||
}
|
||||
|
||||
// This is here only for testing purposes.
|
||||
if (SILPrintFunctionIsolationInfo) {
|
||||
if (auto isolation = getActorIsolation()) {
|
||||
OS << "[isolation \"";
|
||||
isolation->printForSIL(OS);
|
||||
OS << "\"] ";
|
||||
}
|
||||
}
|
||||
|
||||
switch (getInlineStrategy()) {
|
||||
case NoInline: OS << "[noinline] "; break;
|
||||
case AlwaysInline: OS << "[always_inline] "; break;
|
||||
|
||||
Reference in New Issue
Block a user