Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/swift/AST/SILOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class SILOptions {
/// Remove all runtime assertions during optimizations.
bool RemoveRuntimeAsserts = false;

/// Enable existential specializer optimization.
bool ExistentialSpecializer = false;

/// Controls whether the SIL ARC optimizations are run.
bool EnableARCOptimizations = true;

Expand Down
3 changes: 3 additions & 0 deletions include/swift/Option/FrontendOptions.td
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,9 @@ def sil_unroll_threshold : Separate<["-"], "sil-unroll-threshold">,
MetaVarName<"<250>">,
HelpText<"Controls the aggressiveness of loop unrolling">;

def sil_existential_specializer : Flag<["-"], "sil-existential-specializer">,
HelpText<"Enable SIL existential specializer optimization">;

def sil_merge_partial_modules : Flag<["-"], "sil-merge-partial-modules">,
HelpText<"Merge SIL from all partial swiftmodules into the final module">;

Expand Down
2 changes: 2 additions & 0 deletions include/swift/SILOptimizer/PassManager/Passes.def
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ PASS(DeadStoreElimination, "dead-store-elim",
"Dead Store Elimination")
PASS(GenericSpecializer, "generic-specializer",
"Generic Function Specialization on Static Types")
PASS(ExistentialSpecializer, "existential-specializer",
"Existential Specializer")
PASS(GlobalOpt, "global-opt",
"SIL Global Optimization")
PASS(GlobalPropertyOpt, "global-property-opt",
Expand Down
8 changes: 5 additions & 3 deletions include/swift/SILOptimizer/Utils/Existential.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@

namespace swift {

/// Find InitExistential from global_addr and copy_addr.
SILValue findInitExistentialFromGlobalAddr(GlobalAddrInst *GAI,
CopyAddrInst *CAI);
/// Find init_existential from global_addr, if any.
SILValue findInitExistentialFromGlobalAddrAndCopyAddr(GlobalAddrInst *GAI,
CopyAddrInst *CAI);
SILValue findInitExistentialFromGlobalAddrAndApply(GlobalAddrInst *GAI,
ApplySite AI, int ArgIdx);

/// Returns the address of an object with which the stack location \p ASI is
/// initialized. This is either a init_existential_addr or the destination of a
Expand Down
3 changes: 3 additions & 0 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,9 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
return true;
}
}
if (Args.hasArg(OPT_sil_existential_specializer)) {
Opts.ExistentialSpecializer = true;
}
if (const Arg *A = Args.getLastArg(OPT_num_threads)) {
if (StringRef(A->getValue()).getAsInteger(10, Opts.NumThreads)) {
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ set(FUNCTIONSIGNATURETRANSFORMS_SOURCES
FunctionSignatureTransforms/DeadArgumentTransform.cpp
FunctionSignatureTransforms/ArgumentExplosionTransform.cpp
FunctionSignatureTransforms/OwnedToGuaranteedTransform.cpp
FunctionSignatureTransforms/ExistentialSpecializer.cpp
PARENT_SCOPE)
Loading