From a45c05572191ff9fe6b0f260008a4408453d6a7f Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Sat, 4 Jun 2011 20:00:47 +0200 Subject: [PATCH] re PR middle-end/48893 (ICE in evaulate_conditions_for_edge at ipa-inline-analysis.c:477) PR tree-optimization/48893 PR tree-optimization/49091 PR tree-optimization/49179 * ipa-inline-analysis.c (evaluate_conditions_for_known_args): Bounds check. * gfortran.dg/pr49179.f90: New testcase From-SVN: r174648 --- gcc/ChangeLog | 8 ++++++++ gcc/ipa-inline-analysis.c | 10 +++++++++- gcc/testsuite/ChangeLog | 7 +++++++ gcc/testsuite/gfortran.dg/pr49179.f90 | 11 +++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/pr49179.f90 diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5fdd07ca2cf..3082d711c8c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2011-06-04 Jan Hubicka + + PR tree-optimization/48893 + PR tree-optimization/49091 + PR tree-optimization/49179 + * ipa-inline-analysis.c (evaluate_conditions_for_known_args): + Bounds check. + 2011-06-04 Jan Hubicka PR lto/48954 diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c index 45bfeb6f471..ccda67de462 100644 --- a/gcc/ipa-inline-analysis.c +++ b/gcc/ipa-inline-analysis.c @@ -555,9 +555,17 @@ evaluate_conditions_for_known_args (struct cgraph_node *node, for (i = 0; VEC_iterate (condition, info->conds, i, c); i++) { - tree val = VEC_index (tree, known_vals, c->operand_num); + tree val; tree res; + /* We allow call stmt to have fewer arguments than the callee + function (especially for K&R style programs). So bound + check here. */ + if (c->operand_num < (int)VEC_length (tree, known_vals)) + val = VEC_index (tree, known_vals, c->operand_num); + else + val = NULL; + if (!val) { clause |= 1 << (i + predicate_first_dynamic_condition); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b88637cbddc..c4080ff2930 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2011-06-04 Jan Hubicka + + PR tree-optimization/48893 + PR tree-optimization/49091 + PR tree-optimization/49179 + * gfortran.dg/pr49179.f90: New testcase + 2011-06-04 Jan Hubicka PR lto/48954 diff --git a/gcc/testsuite/gfortran.dg/pr49179.f90 b/gcc/testsuite/gfortran.dg/pr49179.f90 new file mode 100644 index 00000000000..0a86e9e8650 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr49179.f90 @@ -0,0 +1,11 @@ +! { dg-options " -O -findirect-inlining" } +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 -- 2.30.2