This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix fork/exec/clone and profile driven feedback corruption
- To: gcc-patches at gcc dot gnu dot org, rth at cygnus dot com
- Subject: Fix fork/exec/clone and profile driven feedback corruption
- From: Jan Hubicka <jh at suse dot cz>
- Date: Tue, 7 Aug 2001 13:31:53 +0200
Hi,
the fork/exec/clone are handled by calls.c by emitting __bb_fork_func libcall
before. This is wrong for profile driven feedback, as it changes the code and
in turn makes CFG to not match at profile.c time.
To handle it properly, we should probably recognize the calls at builtins
and translate them to wrapper, so exactly same code (modulo function name)
will result. Unfortunately this is somewhat tricky to do.
So for now I would suggest to simply disable this feature for FDO and keep
it for -ftest-coverage, where it works.
Honza
Po srp 6 21:31:17 CEST 2001 Jan Hubicka <jh@suse.cz>
* calls.c (expand_call): Warn on -fprofile-arcs with clone/fork/exec
instead of corrupting flow info.
*** calls.c.setjmp Mon Aug 6 20:26:02 2001
--- calls.c Mon Aug 6 21:01:23 2001
*************** expand_call (exp, target, ignore)
*** 2581,2587 ****
stack_pointer_delta = save_stack_pointer_delta;
}
! if (profile_arc_flag && (flags & ECF_FORK_OR_EXEC))
{
/* A fork duplicates the profile information, and an exec discards
it. We can't rely on fork/exec to be paired. So write out the
--- 2585,2591 ----
stack_pointer_delta = save_stack_pointer_delta;
}
! if (flag_test_coverage && (flags & ECF_FORK_OR_EXEC))
{
/* A fork duplicates the profile information, and an exec discards
it. We can't rely on fork/exec to be paired. So write out the
*************** expand_call (exp, target, ignore)
*** 2589,2601 ****
/* ??? When Linux's __clone is called with CLONE_VM set, profiling
is subject to race conditions, just as with multithreaded
programs. */
! if (flag_test_coverage)
! emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "__bb_fork_func"), 0,
! VOIDmode, 0);
! else
! warning
! ("Calling fork, clone or exec will corrupt the profile information");
}
/* Ensure current function's preferred stack boundary is at least
--- 2593,2606 ----
/* ??? When Linux's __clone is called with CLONE_VM set, profiling
is subject to race conditions, just as with multithreaded
programs. */
+ /* ??? We can't do the trick for -fprofile-arcs, as we will change
+ the CFG and we won't be able to read the data back. Proper
+ solution is probably to recognize the functions in question
+ as builtins and create __bb_XXX_func as a wrapper for each
+ call. */
! emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "__bb_fork_func"), 0,
! VOIDmode, 0);
}
/* Ensure current function's preferred stack boundary is at least