Skip to content

Commit 868ae0e

Browse files
committed
Error on bad copy propagation flag combo.
Diagnose passing both -enable-copy-propagation and -disable-copy-propagation.
1 parent afe5fdc commit 868ae0e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,6 +1551,14 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
15511551
}
15521552
}
15531553

1554+
if (Args.hasArg(OPT_enable_copy_propagation) &&
1555+
Args.hasArg(OPT_disable_copy_propagation)) {
1556+
// Error if copy propagation is enabled and copy propagation is disabled.
1557+
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_combination,
1558+
"enable-copy-propagation", "disable-copy-propagation");
1559+
return true;
1560+
}
1561+
15541562
Opts.EnableCopyPropagation |= Args.hasArg(OPT_enable_copy_propagation);
15551563
Opts.DisableCopyPropagation |= Args.hasArg(OPT_disable_copy_propagation);
15561564
Opts.EnableARCOptimizations &= !Args.hasArg(OPT_disable_arc_opts);

tools/sil-opt/SILOpt.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,13 @@ int main(int argc, char **argv) {
524524
SILOpts.EnableSpeculativeDevirtualization = EnableSpeculativeDevirtualization;
525525
SILOpts.IgnoreAlwaysInline = IgnoreAlwaysInline;
526526
SILOpts.EnableOSSAModules = EnableOSSAModules;
527+
528+
if (EnableCopyPropagation && DisableCopyPropagation) {
529+
fprintf(stderr, "Error! Cannot specify both -enable-copy-propagation "
530+
"and -disable-copy-propagation.");
531+
exit(-1);
532+
}
533+
527534
SILOpts.EnableCopyPropagation = EnableCopyPropagation;
528535
SILOpts.DisableCopyPropagation = DisableCopyPropagation;
529536

0 commit comments

Comments
 (0)