[llvm] r372346 - [Analysis] Allow -scalar-evolution-max-iterations more than once

Shoaib Meenai via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 19 11:21:33 PDT 2019


Author: smeenai
Date: Thu Sep 19 11:21:32 2019
New Revision: 372346

URL: http://llvm.org/viewvc/llvm-project?rev=372346&view=rev
Log:
[Analysis] Allow -scalar-evolution-max-iterations more than once

At present, `-scalar-evolution-max-iterations` is a `cl::Optional`
option, which means it demands to be passed exactly zero or one times.
Our build system makes it pretty tricky to guarantee this. We often
accidentally pass the flag more than once (but always with the same
value) which results in an error, after which compilation fails:

```
clang (LLVM option parsing): for the -scalar-evolution-max-iterations option: may only occur zero or one times!
```

It seems reasonable to allow -scalar-evolution-max-iterations to be
passed more than once. Quoting the [[ http://llvm.org/docs/CommandLine.html#controlling-the-number-of-occurrences-required-and-allowed | documentation ]]:

> The cl::ZeroOrMore modifier ... indicates that your program will allow the option to be specified zero or more times.
> ...
> If an option is specified multiple times for an option of the cl::opt class, only the last value will be retained.

Original patch by: Enrico Bern Hardy Tanuwidjaja <etanuwid at fb.com>

Differential Revision: https://reviews.llvm.org/D67512

Added:
    llvm/trunk/test/Analysis/ScalarEvolution/multiple-max-iterations.ll
Modified:
    llvm/trunk/lib/Analysis/ScalarEvolution.cpp

Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=372346&r1=372345&r2=372346&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Thu Sep 19 11:21:32 2019
@@ -148,6 +148,7 @@ STATISTIC(NumBruteForceTripCountsCompute
 
 static cl::opt<unsigned>
 MaxBruteForceIterations("scalar-evolution-max-iterations", cl::ReallyHidden,
+                        cl::ZeroOrMore,
                         cl::desc("Maximum number of iterations SCEV will "
                                  "symbolically execute a constant "
                                  "derived loop"),

Added: llvm/trunk/test/Analysis/ScalarEvolution/multiple-max-iterations.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/multiple-max-iterations.ll?rev=372346&view=auto
==============================================================================
--- llvm/trunk/test/Analysis/ScalarEvolution/multiple-max-iterations.ll (added)
+++ llvm/trunk/test/Analysis/ScalarEvolution/multiple-max-iterations.ll Thu Sep 19 11:21:32 2019
@@ -0,0 +1,2 @@
+; Ensure we can pass -scalar-evolution-max-iterations multiple times
+; RUN: opt -S -scalar-evolution -scalar-evolution-max-iterations=42 -scalar-evolution-max-iterations=42 < %s




More information about the llvm-commits mailing list