Hi,
the fortran testcase mismatches parameter count on inlined function and makes
us to ICE
on out of bounds array acces in remap_predicate.
Fixed thus.
Bootstrapped/regtested x86_64-linux, committed.
PR middle-end/49494
* ipa-inline-analysis.c (remap_predicate): Add bounds check.
* gfortran.dg/pr49494.f90: New testcase.
Index: testsuite/gfortran.dg/pr49494.f90
===================================================================
*** testsuite/gfortran.dg/pr49494.f90 (revision 0)
--- testsuite/gfortran.dg/pr49494.f90 (revision 0)
***************
*** 0 ****
--- 1,12 ----
+ ! { dg-do compile }
+ ! { dg-options "-O -findirect-inlining -fno-guess-branch-probability
-finline-functions -finline-small-functions" }
+ function more_OK (fcn)
+ character(*) more_OK
+ character (*), external :: fcn
+ more_OK = fcn ()
+ end function more_OK
+ character(4) :: answer
+ character(4), external :: is_OK, more_OK
+ answer = more_OK (is_OK)
+ contains
+ END
Index: ipa-inline-analysis.c
===================================================================
*** ipa-inline-analysis.c (revision 177482)
--- ipa-inline-analysis.c (working copy)
*************** remap_predicate (struct inline_summary *
*** 1873,1878 ****
--- 1873,1879 ----
/* See if we can remap condition operand to caller's operand.
Otherwise give up. */
if (!operand_map
+ || VEC_length (int, operand_map) <= c->operand_num
|| VEC_index (int, operand_map, c->operand_num) == -1)
cond_predicate = true_predicate ();
else