Skip to content

Commit e9859e3

Browse files
author
Raj Barik
committed
ExistentialSpecializer Pass
1 parent 6f94f6c commit e9859e3

File tree

13 files changed

+1670
-13
lines changed

13 files changed

+1670
-13
lines changed

include/swift/AST/SILOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ class SILOptions {
5050
/// Remove all runtime assertions during optimizations.
5151
bool RemoveRuntimeAsserts = false;
5252

53+
/// Enable existential specializer optimization.
54+
bool ExistentialSpecializer = false;
55+
5356
/// Controls whether the SIL ARC optimizations are run.
5457
bool EnableARCOptimizations = true;
5558

include/swift/Option/FrontendOptions.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,9 @@ def sil_unroll_threshold : Separate<["-"], "sil-unroll-threshold">,
393393
MetaVarName<"<250>">,
394394
HelpText<"Controls the aggressiveness of loop unrolling">;
395395

396+
def sil_existential_specializer : Flag<["-"], "sil-existential-specializer">,
397+
HelpText<"Enable SIL existential specializer optimization">;
398+
396399
def sil_merge_partial_modules : Flag<["-"], "sil-merge-partial-modules">,
397400
HelpText<"Merge SIL from all partial swiftmodules into the final module">;
398401

include/swift/SILOptimizer/PassManager/Passes.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ PASS(DeadStoreElimination, "dead-store-elim",
156156
"Dead Store Elimination")
157157
PASS(GenericSpecializer, "generic-specializer",
158158
"Generic Function Specialization on Static Types")
159+
PASS(ExistentialSpecializer, "existential-specializer",
160+
"Existential Specializer")
159161
PASS(GlobalOpt, "global-opt",
160162
"SIL Global Optimization")
161163
PASS(GlobalPropertyOpt, "global-property-opt",

include/swift/SILOptimizer/Utils/Existential.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717

1818
namespace swift {
1919

20-
/// Find InitExistential from global_addr and copy_addr.
21-
SILValue findInitExistentialFromGlobalAddr(GlobalAddrInst *GAI,
22-
CopyAddrInst *CAI);
20+
/// Find init_existential from global_addr, if any.
21+
SILValue findInitExistentialFromGlobalAddrAndCopyAddr(GlobalAddrInst *GAI,
22+
CopyAddrInst *CAI);
23+
SILValue findInitExistentialFromGlobalAddrAndApply(GlobalAddrInst *GAI,
24+
ApplySite AI, int ArgIdx);
2325

2426
/// Returns the address of an object with which the stack location \p ASI is
2527
/// initialized. This is either a init_existential_addr or the destination of a

lib/Frontend/CompilerInvocation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,9 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
573573
return true;
574574
}
575575
}
576+
if (Args.hasArg(OPT_sil_existential_specializer)) {
577+
Opts.ExistentialSpecializer = true;
578+
}
576579
if (const Arg *A = Args.getLastArg(OPT_num_threads)) {
577580
if (StringRef(A->getValue()).getAsInteger(10, Opts.NumThreads)) {
578581
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,

lib/SILOptimizer/FunctionSignatureTransforms/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ set(FUNCTIONSIGNATURETRANSFORMS_SOURCES
33
FunctionSignatureTransforms/DeadArgumentTransform.cpp
44
FunctionSignatureTransforms/ArgumentExplosionTransform.cpp
55
FunctionSignatureTransforms/OwnedToGuaranteedTransform.cpp
6+
FunctionSignatureTransforms/ExistentialSpecializer.cpp
67
PARENT_SCOPE)

0 commit comments

Comments
 (0)