[ownership] Loosen restrictions around what we specialize and add generic specialization tests behind a flag.

The idea is that this will let me remove these assertions that were in place to
make sure we were really conservative around specializing ownership code. For me
to remove that I need to be able to actually test out this code (since I think
there are some code paths where this will trigger in other parts of the compiler
now).

So to work out the kinks, I added a flag that allows for the generic specializer
to process ownership code and translated most of the .sil test cases/fixed any
bugs that I found. This hopefully will expose anything that is missing.

NOTE: I have not enabled the generic specializer running in ownership in the
pipeline. This is just a step in that direction by adding tests/etc.
This commit is contained in:
Michael Gottesman
2020-06-09 19:25:32 -07:00
parent fbec91a1b5
commit 1b97c0393c
14 changed files with 2073 additions and 60 deletions

View File

@@ -28,6 +28,10 @@
using namespace swift;
// For testing during bring up.
static llvm::cl::opt<bool> EnableGenericSpecializerWithOwnership(
"sil-generic-specializer-enable-ownership", llvm::cl::init(false));
namespace {
class GenericSpecializer : public SILFunctionTransform {
@@ -39,7 +43,7 @@ class GenericSpecializer : public SILFunctionTransform {
SILFunction &F = *getFunction();
// TODO: We should be able to handle ownership.
if (F.hasOwnership())
if (F.hasOwnership() && !EnableGenericSpecializerWithOwnership)
return;
LLVM_DEBUG(llvm::dbgs() << "***** GenericSpecializer on function:"