Commit 135a171d by Jakub Jelinek Committed by Jakub Jelinek

re PR gcov-profile/34610 (ICE with "-fprofile-arcs -fopenmp")

	PR gcov-profile/34610
	* tree-cfg.c (make_edges): Mark both outgoing edges from
	OMP_CONTINUE and from OMP_FOR as EDGE_ABNORMAL.
	* omp-low.c (expand_omp_for): Clear EDGE_ABNORMAL bits
	from OMP_FOR and OMP_CONTINUE outgoing edges.

	* tree-profile.c (tree_profiling): Return early if
	cfun->after_tree_profile != 0.  Set cfun->after_tree_profile
	at the end.
	* omp-low.c (expand_omp_parallel): Copy after_tree_profile
	from cfun to child_cfun.
	* function.h (struct function): Add after_tree_profile bit.

	* gcc.dg/gomp/pr34610.c: New test.

From-SVN: r131653
parent d7e2fcd0
2008-01-19 Jakub Jelinek <jakub@redhat.com>
PR gcov-profile/34610
* tree-cfg.c (make_edges): Mark both outgoing edges from
OMP_CONTINUE and from OMP_FOR as EDGE_ABNORMAL.
* omp-low.c (expand_omp_for): Clear EDGE_ABNORMAL bits
from OMP_FOR and OMP_CONTINUE outgoing edges.
* tree-profile.c (tree_profiling): Return early if
cfun->after_tree_profile != 0. Set cfun->after_tree_profile
at the end.
* omp-low.c (expand_omp_parallel): Copy after_tree_profile
from cfun to child_cfun.
* function.h (struct function): Add after_tree_profile bit.
2008-01-19 Anatoly Sokolov <aesok@post.ru> 2008-01-19 Anatoly Sokolov <aesok@post.ru>
* config/avr/avr.S (_exit): Disable interrupt. * config/avr/avr.S (_exit): Disable interrupt.
......
/* Structure for saving state for a nested function. /* Structure for saving state for a nested function.
Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2008
Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -459,6 +460,9 @@ struct function GTY(()) ...@@ -459,6 +460,9 @@ struct function GTY(())
/* Nonzero if function being compiled needs to /* Nonzero if function being compiled needs to
return the address of where it has put a structure value. */ return the address of where it has put a structure value. */
unsigned int returns_pcc_struct : 1; unsigned int returns_pcc_struct : 1;
/* Nonzero if pass_tree_profile was run on this function. */
unsigned int after_tree_profile : 1;
}; };
/* If va_list_[gf]pr_size is set to this, it means we don't know how /* If va_list_[gf]pr_size is set to this, it means we don't know how
......
...@@ -2497,6 +2497,9 @@ expand_omp_parallel (struct omp_region *region) ...@@ -2497,6 +2497,9 @@ expand_omp_parallel (struct omp_region *region)
entry_stmt = last_stmt (region->entry); entry_stmt = last_stmt (region->entry);
child_fn = OMP_PARALLEL_FN (entry_stmt); child_fn = OMP_PARALLEL_FN (entry_stmt);
child_cfun = DECL_STRUCT_FUNCTION (child_fn); child_cfun = DECL_STRUCT_FUNCTION (child_fn);
/* If this function has been already instrumented, make sure
the child function isn't instrumented again. */
child_cfun->after_tree_profile = cfun->after_tree_profile;
entry_bb = region->entry; entry_bb = region->entry;
exit_bb = region->exit; exit_bb = region->exit;
...@@ -3337,6 +3340,16 @@ expand_omp_for (struct omp_region *region) ...@@ -3337,6 +3340,16 @@ expand_omp_for (struct omp_region *region)
extract_omp_for_data (last_stmt (region->entry), &fd); extract_omp_for_data (last_stmt (region->entry), &fd);
region->sched_kind = fd.sched_kind; region->sched_kind = fd.sched_kind;
gcc_assert (EDGE_COUNT (region->entry->succs) == 2);
BRANCH_EDGE (region->entry)->flags &= ~EDGE_ABNORMAL;
FALLTHRU_EDGE (region->entry)->flags &= ~EDGE_ABNORMAL;
if (region->cont)
{
gcc_assert (EDGE_COUNT (region->cont->succs) == 2);
BRANCH_EDGE (region->cont)->flags &= ~EDGE_ABNORMAL;
FALLTHRU_EDGE (region->cont)->flags &= ~EDGE_ABNORMAL;
}
if (fd.sched_kind == OMP_CLAUSE_SCHEDULE_STATIC if (fd.sched_kind == OMP_CLAUSE_SCHEDULE_STATIC
&& !fd.have_ordered && !fd.have_ordered
&& region->cont != NULL) && region->cont != NULL)
......
2008-01-19 Jakub Jelinek <jakub@redhat.com>
PR gcov-profile/34610
* gcc.dg/gomp/pr34610.c: New test.
2008-01-19 Tobias Burnus <burnus@net-b.de> 2008-01-19 Tobias Burnus <burnus@net-b.de>
PR fortran/34760 PR fortran/34760
/* PR gcov-profile/34610 */
/* { dg-do compile } */
/* { dg-options "-O2 -fprofile-arcs -fopenmp" } */
extern void bar (int);
extern void baz (int) __attribute__((noreturn));
void
foo (int k)
{
int i;
#pragma omp for schedule(dynamic)
for (i = 0; i < 10; ++i)
bar (i);
#pragma omp parallel for schedule(static)
for (i = 0; i < 10; ++i)
bar (i);
#pragma omp parallel for schedule(static, 4)
for (i = 0; i < 10; ++i)
bar (i);
if (k)
#pragma omp for schedule(dynamic)
for (i = 0; i < 10; ++i)
baz (i);
#pragma omp parallel
for (i = 0; i < 10; ++i)
bar (i);
}
/* { dg-final { cleanup-coverage-files } } */
/* Control flow functions for trees. /* Control flow functions for trees.
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
Free Software Foundation, Inc. Free Software Foundation, Inc.
Contributed by Diego Novillo <dnovillo@redhat.com> Contributed by Diego Novillo <dnovillo@redhat.com>
...@@ -544,14 +544,19 @@ make_edges (void) ...@@ -544,14 +544,19 @@ make_edges (void)
switch (cur_region->type) switch (cur_region->type)
{ {
case OMP_FOR: case OMP_FOR:
/* Mark all OMP_FOR and OMP_CONTINUE succs edges as abnormal
to prevent splitting them. */
single_succ_edge (cur_region->entry)->flags |= EDGE_ABNORMAL;
/* Make the loopback edge. */ /* Make the loopback edge. */
make_edge (bb, single_succ (cur_region->entry), 0); make_edge (bb, single_succ (cur_region->entry),
EDGE_ABNORMAL);
/* Create an edge from OMP_FOR to exit, which corresponds to /* Create an edge from OMP_FOR to exit, which corresponds to
the case that the body of the loop is not executed at the case that the body of the loop is not executed at
all. */ all. */
make_edge (cur_region->entry, bb->next_bb, 0); make_edge (cur_region->entry, bb->next_bb, EDGE_ABNORMAL);
fallthru = true; make_edge (bb, bb->next_bb, EDGE_FALLTHRU | EDGE_ABNORMAL);
fallthru = false;
break; break;
case OMP_SECTIONS: case OMP_SECTIONS:
......
/* Calculate branch probabilities, and basic block execution counts. /* Calculate branch probabilities, and basic block execution counts.
Copyright (C) 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 1999, Copyright (C) 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 1999,
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
Free Software Foundation, Inc. Free Software Foundation, Inc.
Contributed by James E. Wilson, UC Berkeley/Cygnus Support; Contributed by James E. Wilson, UC Berkeley/Cygnus Support;
based on some ideas from Dain Samples of UC Berkeley. based on some ideas from Dain Samples of UC Berkeley.
...@@ -419,8 +419,11 @@ static unsigned int ...@@ -419,8 +419,11 @@ static unsigned int
tree_profiling (void) tree_profiling (void)
{ {
/* Don't profile functions produced at destruction time, particularly /* Don't profile functions produced at destruction time, particularly
the gcov datastructure initializer. */ the gcov datastructure initializer. Don't profile if it has been
if (cgraph_state == CGRAPH_STATE_FINISHED) already instrumented either (when OpenMP expansion creates
child function from already instrumented body). */
if (cgraph_state == CGRAPH_STATE_FINISHED
|| cfun->after_tree_profile)
return 0; return 0;
/* Re-set global shared temporary variable for edge-counters. */ /* Re-set global shared temporary variable for edge-counters. */
...@@ -441,6 +444,7 @@ tree_profiling (void) ...@@ -441,6 +444,7 @@ tree_profiling (void)
easy to adjust it, if and when there is some. */ easy to adjust it, if and when there is some. */
free_dominance_info (CDI_DOMINATORS); free_dominance_info (CDI_DOMINATORS);
free_dominance_info (CDI_POST_DOMINATORS); free_dominance_info (CDI_POST_DOMINATORS);
cfun->after_tree_profile = 1;
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment