Skip to content

Commit f809d72

Browse files
authored
Merge pull request swiftlang#72504 from atrick/complete-ossa-flags
Options for complete OSSA lifetimes.
2 parents 9fcd80c + 38d9557 commit f809d72

File tree

7 files changed

+30
-5
lines changed

7 files changed

+30
-5
lines changed

include/swift/AST/SILOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ class SILOptions {
185185
/// Require linear OSSA lifetimes after SILGen
186186
bool OSSACompleteLifetimes = false;
187187

188+
/// Verify linear OSSA lifetimes after SILGen
189+
bool OSSAVerifyComplete = false;
190+
188191
/// Enable pack metadata stack "promotion".
189192
///
190193
/// More accurately, enable skipping mandatory heapification of pack metadata

include/swift/Option/FrontendOptions.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,16 @@ def experimental_spi_only_imports :
13191319
def enable_ossa_complete_lifetimes :
13201320
Flag<["-"], "enable-ossa-complete-lifetimes">,
13211321
HelpText<"Require linear OSSA lifetimes after SILGen">;
1322+
def disable_ossa_complete_lifetimes :
1323+
Flag<["-"], "disable-ossa-complete-lifetimes">,
1324+
HelpText<"Do not require linear OSSA lifetimes after SILGen">;
1325+
1326+
def enable_ossa_verify_complete :
1327+
Flag<["-"], "enable-ossa-verify-complete">,
1328+
HelpText<"Verify linear OSSA lifetimes after SILGen">;
1329+
def disable_ossa_verify_complete :
1330+
Flag<["-"], "disable-ossa-verify-complete">,
1331+
HelpText<"Do not verify linear OSSA lifetimes after SILGen">;
13221332

13231333
def platform_c_calling_convention :
13241334
Separate<["-"], "experimental-platform-c-calling-convention">,

lib/DriverTool/sil_opt_main.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,10 @@ struct SILOptOptions {
209209

210210
llvm::cl::opt<bool>
211211
EnableOSSACompleteLifetimes = llvm::cl::opt<bool>("enable-ossa-complete-lifetimes",
212-
llvm::cl::desc("Compile the module with sil-opaque-values enabled."));
212+
llvm::cl::desc("Require linear OSSA lifetimes after SILGenCleanup."));
213+
llvm::cl::opt<bool>
214+
EnableOSSAVerifyComplete = llvm::cl::opt<bool>("enable-ossa-verify-complete",
215+
llvm::cl::desc("Verify linear OSSA lifetimes after SILGenCleanup."));
213216

214217
llvm::cl::opt<bool>
215218
EnableObjCInterop = llvm::cl::opt<bool>("enable-objc-interop",
@@ -759,6 +762,7 @@ int sil_opt_main(ArrayRef<const char *> argv, void *MainAddr) {
759762
SILOpts.EnableOSSAModules = options.EnableOSSAModules;
760763
SILOpts.EnableSILOpaqueValues = options.EnableSILOpaqueValues;
761764
SILOpts.OSSACompleteLifetimes = options.EnableOSSACompleteLifetimes;
765+
SILOpts.OSSAVerifyComplete = options.EnableOSSAVerifyComplete;
762766

763767
if (options.CopyPropagationState) {
764768
SILOpts.CopyPropagation = *options.CopyPropagationState;

lib/Frontend/CompilerInvocation.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2528,7 +2528,15 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
25282528
parseExclusivityEnforcementOptions(A, Opts, Diags);
25292529
}
25302530

2531-
Opts.OSSACompleteLifetimes |= Args.hasArg(OPT_enable_ossa_complete_lifetimes);
2531+
Opts.OSSACompleteLifetimes =
2532+
Args.hasFlag(OPT_enable_ossa_complete_lifetimes,
2533+
OPT_disable_ossa_complete_lifetimes,
2534+
Opts.OSSACompleteLifetimes);
2535+
2536+
Opts.OSSAVerifyComplete =
2537+
Args.hasFlag(OPT_enable_ossa_verify_complete,
2538+
OPT_disable_ossa_verify_complete,
2539+
Opts.OSSAVerifyComplete);
25322540

25332541
Opts.NoAllocations = Args.hasArg(OPT_no_allocations);
25342542

lib/SIL/Verifier/SILOwnershipVerifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ void SILModule::verifyOwnership() const {
902902

903903
for (const SILFunction &function : *this) {
904904
std::unique_ptr<DeadEndBlocks> deBlocks;
905-
if (!getOptions().OSSACompleteLifetimes) {
905+
if (!getOptions().OSSAVerifyComplete) {
906906
deBlocks =
907907
std::make_unique<DeadEndBlocks>(const_cast<SILFunction *>(&function));
908908
}

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7070,7 +7070,7 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
70707070
}
70717071

70727072
void verify(bool isCompleteOSSA) {
7073-
if (!isCompleteOSSA || !F.getModule().getOptions().OSSACompleteLifetimes) {
7073+
if (!isCompleteOSSA || !F.getModule().getOptions().OSSAVerifyComplete) {
70747074
DEBlocks = std::make_unique<DeadEndBlocks>(const_cast<SILFunction *>(&F));
70757075
}
70767076
visitSILFunction(const_cast<SILFunction*>(&F));

lib/SILOptimizer/PassManager/Passes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ bool swift::runSILDiagnosticPasses(SILModule &Module) {
5858
SILPassPipelinePlan::getSILGenPassPipeline(opts),
5959
/*isMandatory*/ true);
6060

61-
if (opts.VerifyAll && opts.OSSACompleteLifetimes)
61+
if (opts.VerifyAll && opts.OSSAVerifyComplete)
6262
Module.verifyOwnership();
6363

6464
executePassPipelinePlan(&Module,

0 commit comments

Comments
 (0)