public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* PR 47793 - Support relative paths using -fprofile-generate (issue4434055)
@ 2011-04-18 18:13 Martin Thuresson
  2011-04-18 19:01 ` Martin Thuresson
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Thuresson @ 2011-04-18 18:13 UTC (permalink / raw)
  To: reply, gcc-patches

This is slightly updated from my previous patch proposal. The test now
correctly work if multiple tests are executed in parallell.

2011-04-17  Martin Thuresson  <martint@google.com>

	* gcc/doc/invoke.tex: Document support for relative profile paths.
	* gcc/testsuite/gcc.dg/pr47793.c: New test.
	* gcc/libgcov.c	(gcov_exit): Support relative profile paths.

Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi	(revision 172439)
+++ gcc/doc/invoke.texi	(working copy)
@@ -7751,7 +7751,7 @@ Set the directory to search for the prof
 This option affects only the profile data generated by
 @option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs}
 and used by @option{-fprofile-use} and @option{-fbranch-probabilities}
-and its related options.
+and its related options.  Both absolute and relative paths can be used.
 By default, GCC will use the current directory as @var{path}, thus the
 profile data file will appear in the same directory as the object file.
 
Index: gcc/testsuite/gcc.dg/pr47793.c
===================================================================
--- gcc/testsuite/gcc.dg/pr47793.c	(revision 0)
+++ gcc/testsuite/gcc.dg/pr47793.c	(revision 0)
@@ -0,0 +1,12 @@
+/* Bug pr47793: Allow relative paths in profile-generate.  */
+/* { dg-do run } */
+/* { dg-options "-O -fprofile-generate=./" } */
+/* { dg-final { scan-file pr47793.gcda "."} } */
+
+int
+main(void)
+{
+  return 0;
+}
+
+/* { dg-final { cleanup-coverage-files } } */
Index: gcc/libgcov.c
===================================================================
--- gcc/libgcov.c	(revision 172439)
+++ gcc/libgcov.c	(working copy)
@@ -283,8 +283,9 @@ gcov_exit (void)
 	      }
         }
       /* Update complete filename with stripped original. */
-      if (!IS_DIR_SEPARATOR (*fname) && !HAS_DRIVE_SPEC(fname))
-	{
+      if (prefix_length != 0 && !IS_DIR_SEPARATOR (*fname))
+        {
+          /* If prefix is given, add directory separator.  */
 	  strcpy (gi_filename_up, "/");
 	  strcpy (gi_filename_up + 1, fname);
 	}

--
This patch is available for review at http://codereview.appspot.com/4434055

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: PR 47793 - Support relative paths using -fprofile-generate (issue4434055)
  2011-04-18 18:13 PR 47793 - Support relative paths using -fprofile-generate (issue4434055) Martin Thuresson
@ 2011-04-18 19:01 ` Martin Thuresson
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Thuresson @ 2011-04-18 19:01 UTC (permalink / raw)
  To: reply, gcc-patches; +Cc: hubicka

On Mon, Apr 18, 2011 at 10:48 AM, Martin Thuresson <martint@google.com> wrote:
> This is slightly updated from my previous patch proposal. The test now
> correctly work if multiple tests are executed in parallell.

Forgot to mention that this patch has been bootstrapped without
regression on x86_64 and should be considered for GCC trunk.

Thanks!
Martin

>
> 2011-04-17  Martin Thuresson  <martint@google.com>
>
>        * gcc/doc/invoke.tex: Document support for relative profile paths.
>        * gcc/testsuite/gcc.dg/pr47793.c: New test.
>        * gcc/libgcov.c (gcov_exit): Support relative profile paths.
>
> Index: gcc/doc/invoke.texi
> ===================================================================
> --- gcc/doc/invoke.texi (revision 172439)
> +++ gcc/doc/invoke.texi (working copy)
> @@ -7751,7 +7751,7 @@ Set the directory to search for the prof
>  This option affects only the profile data generated by
>  @option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs}
>  and used by @option{-fprofile-use} and @option{-fbranch-probabilities}
> -and its related options.
> +and its related options.  Both absolute and relative paths can be used.
>  By default, GCC will use the current directory as @var{path}, thus the
>  profile data file will appear in the same directory as the object file.
>
> Index: gcc/testsuite/gcc.dg/pr47793.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/pr47793.c      (revision 0)
> +++ gcc/testsuite/gcc.dg/pr47793.c      (revision 0)
> @@ -0,0 +1,12 @@
> +/* Bug pr47793: Allow relative paths in profile-generate.  */
> +/* { dg-do run } */
> +/* { dg-options "-O -fprofile-generate=./" } */
> +/* { dg-final { scan-file pr47793.gcda "."} } */
> +
> +int
> +main(void)
> +{
> +  return 0;
> +}
> +
> +/* { dg-final { cleanup-coverage-files } } */
> Index: gcc/libgcov.c
> ===================================================================
> --- gcc/libgcov.c       (revision 172439)
> +++ gcc/libgcov.c       (working copy)
> @@ -283,8 +283,9 @@ gcov_exit (void)
>              }
>         }
>       /* Update complete filename with stripped original. */
> -      if (!IS_DIR_SEPARATOR (*fname) && !HAS_DRIVE_SPEC(fname))
> -       {
> +      if (prefix_length != 0 && !IS_DIR_SEPARATOR (*fname))
> +        {
> +          /* If prefix is given, add directory separator.  */
>          strcpy (gi_filename_up, "/");
>          strcpy (gi_filename_up + 1, fname);
>        }
>
> --
> This patch is available for review at http://codereview.appspot.com/4434055
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-04-18 18:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-18 18:13 PR 47793 - Support relative paths using -fprofile-generate (issue4434055) Martin Thuresson
2011-04-18 19:01 ` Martin Thuresson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).