Skip to content

Commit 0c1b56a

Browse files
committed
Error on bad copy propagation flag combo.
Diagnose passing both -enable-copy-propagation and -disable-copy-propagation.
1 parent 1147f7f commit 0c1b56a

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
@@ -1543,6 +1543,14 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
15431543
}
15441544
}
15451545

1546+
if (Args.hasArg(OPT_enable_copy_propagation) &&
1547+
Args.hasArg(OPT_disable_copy_propagation)) {
1548+
// Error if copy propagation is enabled and copy propagation is disabled.
1549+
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_combination,
1550+
"enable-copy-propagation", "disable-copy-propagation");
1551+
return true;
1552+
}
1553+
15461554
Opts.EnableCopyPropagation |= Args.hasArg(OPT_enable_copy_propagation);
15471555
Opts.DisableCopyPropagation |= Args.hasArg(OPT_disable_copy_propagation);
15481556
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)