[PATCH] D71145: [InstCombine] Allow to limit the max number of iterations

Jakub Kuderski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 10 08:01:04 PST 2019


kuhar marked 3 inline comments as done.
kuhar added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:125
 
+static constexpr unsigned InstCombineDefaultMaxIterations = 1000;
+
----------------
spatel wrote:
> kuhar wrote:
> > lebedev.ri wrote:
> > > kuhar wrote:
> > > > lebedev.ri wrote:
> > > > > I think it should be
> > > > > ```
> > > > > static constexpr unsigned InstCombineDefaultMaxIterations = std::numeric_limits<unsigned>::max - 1;
> > > > > ```
> > > > > if the goal is to catch infinite loops while avoiding unintentional capping of iteration limit.
> > > > UINT_MAX is about 4*10^9. I don't think we will ever reach that number of iterations on any reasonable-sized input bitcode.
> > > Yes, that is kind-of the point, i'm not confident we won't reach `1000` in normal situations.
> > See my full answer below.
> If we want to be safer, we could set the limit to UINT_MAX in this patch, then make a follow-up that just changes that single constant value.
> 
> Based on the data so far, either way seems ok to me.
Sounds good to me. Making the bound tighter can be a follow-up patch.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71145/new/

https://reviews.llvm.org/D71145





More information about the llvm-commits mailing list