Skip InductionVarAnalysis for a pathological case

Having a long chain of loop header phis hangs up the compiler.

Note that we can still compile the method if we skip the
InductionVarAnalysis phase.

Bug: 246249941
Fixes: 246249941
Bug: 32545907
Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b
Test: dex2oat compile the app in 246249941
Change-Id: Id2d14b1c4d787f98d656055274c7cfcae6491686
diff --git a/compiler/optimizing/induction_var_analysis.h b/compiler/optimizing/induction_var_analysis.h
index 124c3b4..0509500 100644
--- a/compiler/optimizing/induction_var_analysis.h
+++ b/compiler/optimizing/induction_var_analysis.h
@@ -39,7 +39,9 @@
  */
 class HInductionVarAnalysis : public HOptimization {
  public:
-  explicit HInductionVarAnalysis(HGraph* graph, const char* name = kInductionPassName);
+  explicit HInductionVarAnalysis(HGraph* graph,
+                                 OptimizingCompilerStats* stats = nullptr,
+                                 const char* name = kInductionPassName);
 
   bool Run() override;
 
@@ -308,6 +310,15 @@
   static std::string FetchToString(HInstruction* fetch);
   static std::string InductionToString(InductionInfo* info);
 
+  // Returns true if we have a pathological case we don't want to analyze.
+  bool IsPathologicalCase();
+  // Starting with initial_phi, it calculates how many loop header phis in a row we have. To do
+  // this, we count the loop header phi which are used as an input of other loop header phis. It
+  // uses `cached_values` to avoid recomputing results.
+  void CalculateLoopHeaderPhisInARow(HPhi* initial_phi,
+                                     ScopedArenaSafeMap<HPhi*, int>& cached_values,
+                                     ScopedArenaAllocator& allocator);
+
   /**
    * Maintains the results of the analysis as a mapping from loops to a mapping from instructions
    * to the induction information for that instruction in that loop.