mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[semantic-arc] Add the assume-parsing-unqualified-ownership-sil argument ath forces the Parser to assume that all parsed code is unqualified. This overrides the parser ownership heuristic.
This commit is contained in:
@@ -116,6 +116,9 @@ public:
|
|||||||
|
|
||||||
/// If set to true, compile with the SIL Ownership Model enabled.
|
/// If set to true, compile with the SIL Ownership Model enabled.
|
||||||
bool EnableSILOwnership = false;
|
bool EnableSILOwnership = false;
|
||||||
|
|
||||||
|
/// When parsing SIL, assume unqualified ownership.
|
||||||
|
bool AssumeUnqualifiedOwnershipWhenParsing = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace swift
|
} // end namespace swift
|
||||||
|
|||||||
@@ -230,6 +230,9 @@ def emit_verbose_sil : Flag<["-"], "emit-verbose-sil">,
|
|||||||
def enable_sil_ownership : Flag<["-"], "enable-sil-ownership">,
|
def enable_sil_ownership : Flag<["-"], "enable-sil-ownership">,
|
||||||
HelpText<"Enable the SIL Ownership Model">;
|
HelpText<"Enable the SIL Ownership Model">;
|
||||||
|
|
||||||
|
def assume_parsing_unqualified_ownership_sil : Flag<["-"], "assume-parsing-unqualified-ownership-sil">,
|
||||||
|
HelpText<"Assume unqualified SIL ownership when parsing SIL">;
|
||||||
|
|
||||||
def enable_experimental_property_behaviors :
|
def enable_experimental_property_behaviors :
|
||||||
Flag<["-"], "enable-experimental-property-behaviors">,
|
Flag<["-"], "enable-experimental-property-behaviors">,
|
||||||
HelpText<"Enable experimental property behaviors">;
|
HelpText<"Enable experimental property behaviors">;
|
||||||
|
|||||||
@@ -1153,6 +1153,8 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
|
|||||||
Opts.DisableSILPartialApply |=
|
Opts.DisableSILPartialApply |=
|
||||||
Args.hasArg(OPT_disable_sil_partial_apply);
|
Args.hasArg(OPT_disable_sil_partial_apply);
|
||||||
Opts.EnableSILOwnership |= Args.hasArg(OPT_enable_sil_ownership);
|
Opts.EnableSILOwnership |= Args.hasArg(OPT_enable_sil_ownership);
|
||||||
|
Opts.AssumeUnqualifiedOwnershipWhenParsing
|
||||||
|
|= Args.hasArg(OPT_assume_parsing_unqualified_ownership_sil);
|
||||||
|
|
||||||
if (Args.hasArg(OPT_debug_on_sil)) {
|
if (Args.hasArg(OPT_debug_on_sil)) {
|
||||||
// Derive the name of the SIL file for debugging from
|
// Derive the name of the SIL file for debugging from
|
||||||
|
|||||||
@@ -3994,6 +3994,8 @@ bool SILParser::parseSILBasicBlock(SILBuilder &B) {
|
|||||||
F->getBlocks().remove(BB);
|
F->getBlocks().remove(BB);
|
||||||
F->getBlocks().push_back(BB);
|
F->getBlocks().push_back(BB);
|
||||||
|
|
||||||
|
bool AssumeUnqualifiedOwnershipWhenParsing =
|
||||||
|
F->getModule().getOptions().AssumeUnqualifiedOwnershipWhenParsing;
|
||||||
do {
|
do {
|
||||||
if (parseSILInstruction(BB, B))
|
if (parseSILInstruction(BB, B))
|
||||||
return true;
|
return true;
|
||||||
@@ -4001,7 +4003,9 @@ bool SILParser::parseSILBasicBlock(SILBuilder &B) {
|
|||||||
// Qualification. For more details, see the comment on the
|
// Qualification. For more details, see the comment on the
|
||||||
// FunctionOwnershipEvaluator class.
|
// FunctionOwnershipEvaluator class.
|
||||||
SILInstruction *ParsedInst = &*BB->rbegin();
|
SILInstruction *ParsedInst = &*BB->rbegin();
|
||||||
if (!OwnershipEvaluator.evaluate(ParsedInst)) {
|
if (AssumeUnqualifiedOwnershipWhenParsing) {
|
||||||
|
F->setUnqualifiedOwnership();
|
||||||
|
} else if (!OwnershipEvaluator.evaluate(ParsedInst)) {
|
||||||
P.diagnose(ParsedInst->getLoc().getSourceLoc(),
|
P.diagnose(ParsedInst->getLoc().getSourceLoc(),
|
||||||
diag::found_unqualified_instruction_in_qualified_function,
|
diag::found_unqualified_instruction_in_qualified_function,
|
||||||
F->getName());
|
F->getName());
|
||||||
|
|||||||
@@ -164,6 +164,11 @@ ASTVerifierProcessId("ast-verifier-process-id", llvm::cl::Hidden,
|
|||||||
static llvm::cl::opt<bool>
|
static llvm::cl::opt<bool>
|
||||||
PerformWMO("wmo", llvm::cl::desc("Enable whole-module optimizations"));
|
PerformWMO("wmo", llvm::cl::desc("Enable whole-module optimizations"));
|
||||||
|
|
||||||
|
static llvm::cl::opt<bool>
|
||||||
|
AssumeUnqualifiedOwnershipWhenParsing(
|
||||||
|
"assume-parsing-unqualified-ownership-sil", llvm::cl::Hidden, llvm::cl::init(false),
|
||||||
|
llvm::cl::desc("Assume all parsed functions have unqualified ownership"));
|
||||||
|
|
||||||
static void runCommandLineSelectedPasses(SILModule *Module) {
|
static void runCommandLineSelectedPasses(SILModule *Module) {
|
||||||
SILPassManager PM(Module);
|
SILPassManager PM(Module);
|
||||||
|
|
||||||
@@ -232,6 +237,8 @@ int main(int argc, char **argv) {
|
|||||||
if (OptimizationGroup != OptGroup::Diagnostics)
|
if (OptimizationGroup != OptGroup::Diagnostics)
|
||||||
SILOpts.Optimization = SILOptions::SILOptMode::Optimize;
|
SILOpts.Optimization = SILOptions::SILOptMode::Optimize;
|
||||||
SILOpts.EnableSILOwnership = EnableSILOwnershipOpt;
|
SILOpts.EnableSILOwnership = EnableSILOwnershipOpt;
|
||||||
|
SILOpts.AssumeUnqualifiedOwnershipWhenParsing =
|
||||||
|
AssumeUnqualifiedOwnershipWhenParsing;
|
||||||
|
|
||||||
// Load the input file.
|
// Load the input file.
|
||||||
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileBufOrErr =
|
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileBufOrErr =
|
||||||
|
|||||||
Reference in New Issue
Block a user