Patchwork Fix fork instrumentation for libgcov

login
register
mail settings
Submitter Jan Hubicka
Date Aug. 31, 2013, 2:30 p.m.
Message ID <20130831143004.GA22772@kam.mff.cuni.cz>
Download mbox | patch
Permalink /patch/271536/
State New
Headers show

Comments

Jan Hubicka - Aug. 31, 2013, 2:30 p.m.
Hi,
as noticed by Martin Liska, -O0 -fprofile-generate code won't land into
__gcov_fork.  This is due to early exit from expand_builtin.

Fixed and will be comitted as obvious.
Honza
	* builtins.c (expand_builtin): Do not exit early for gcov
	instrumented functions.
	* gcc.dg/fork-instrumentation.c: New testcase.

Patch

Index: builtins.c
===================================================================
--- builtins.c	(revision 202100)
+++ builtins.c	(working copy)
@@ -5850,6 +5850,13 @@  expand_builtin (tree exp, rtx target, rt
      set of builtins.  */
   if (!optimize
       && !called_as_built_in (fndecl)
+      && fcode != BUILT_IN_FORK
+      && fcode != BUILT_IN_EXECL
+      && fcode != BUILT_IN_EXECV
+      && fcode != BUILT_IN_EXECLP
+      && fcode != BUILT_IN_EXECLE
+      && fcode != BUILT_IN_EXECVP
+      && fcode != BUILT_IN_EXECVE
       && fcode != BUILT_IN_ALLOCA
       && fcode != BUILT_IN_ALLOCA_WITH_ALIGN
       && fcode != BUILT_IN_FREE)
Index: testsuite/gcc.dg/fork-instrumentation.c
===================================================================
--- testsuite/gcc.dg/fork-instrumentation.c	(revision 0)
+++ testsuite/gcc.dg/fork-instrumentation.c	(working copy)
@@ -0,0 +1,8 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O0 -fprofile-generate" } */
+int fork(void);
+t()
+{
+  fork ();
+}
+/* { dg-final { scan-assembler "gcov_fork" } } */