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

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 10 07:52:24 PST 2019


spatel added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:125
 
+static constexpr unsigned InstCombineDefaultMaxIterations = 1000;
+
----------------
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.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71145





More information about the llvm-commits mailing list