public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Richard Biener <richard.guenther@gmail.com>,
	Jan Hubicka <hubicka@ucw.cz>
Subject: [PATCH] Append PWD to path when using -fprofile-generate=/some/path.
Date: Fri, 27 Oct 2017 13:19:00 -0000	[thread overview]
Message-ID: <41f0b7e4-1a6b-3f5e-1e3a-750502e73043@suse.cz> (raw)
In-Reply-To: <f61115af-55e1-8d59-545f-295f7e5b53cb@suse.cz>

[-- Attachment #1: Type: text/plain, Size: 225 bytes --]

Hello.

It's improvement that I consider still useful even though we're not going to use
it for profiled bootstrap.

Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

Ready for trunk?
Thanks,
Martin

[-- Attachment #2: 0001-Append-PWD-to-path-when-using-fprofile-generate-some.patch --]
[-- Type: text/x-patch, Size: 2189 bytes --]

From 1a32e0b41b291bef3d58126754834f6c41148ace Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Wed, 16 Aug 2017 10:22:57 +0200
Subject: [PATCH] Append PWD to path when using -fprofile-generate=/some/path.

gcc/ChangeLog:

2017-10-27  Martin Liska  <mliska@suse.cz>

	* coverage.c (coverage_init): Append absolute path of object
	file.
	* doc/invoke.texi: Document the behavior.
---
 gcc/coverage.c      | 20 ++++++++++++++++++--
 gcc/doc/invoke.texi |  3 +++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/gcc/coverage.c b/gcc/coverage.c
index 8a56a677f15..c66651f1045 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -1220,8 +1220,24 @@ coverage_init (const char *filename)
     g->get_passes ()->get_pass_profile ()->static_pass_number;
   g->get_dumps ()->dump_start (profile_pass_num, NULL);
 
-  if (!profile_data_prefix && !IS_ABSOLUTE_PATH (filename))
-    profile_data_prefix = getpwd ();
+  if (!IS_ABSOLUTE_PATH (filename))
+    {
+      if (profile_data_prefix)
+	{
+	  const char *pwd = getpwd ();
+	  unsigned l1 = strlen (profile_data_prefix);
+	  unsigned l2 = strlen (pwd);
+
+	  char *b = XNEWVEC (char, l1 + l2 + 2);
+	  memcpy (b, profile_data_prefix, l1);
+	  b[l1] = '/';
+	  memcpy (b + l1 + 1, pwd, l2);
+	  b[l1 + l2 + 1] = '\0';
+	  profile_data_prefix = b;
+	}
+      else
+	profile_data_prefix = getpwd ();
+    }
 
   if (profile_data_prefix)
     prefix_len = strlen (profile_data_prefix);
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 71b2445f70f..682ab570584 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -10915,6 +10915,9 @@ and used by @option{-fprofile-use} and @option{-fbranch-probabilities}
 and its related options.  Both absolute and relative paths can be used.
 By default, GCC uses the current directory as @var{path}, thus the
 profile data file appears in the same directory as the object file.
+In order to prevent filename clashing, if object file name is not an absolute
+path, current working directory path is appended to @var{path}
+and used as a destination for @file{@var{sourcename}.gcda} file.
 
 @item -fprofile-generate
 @itemx -fprofile-generate=@var{path}
-- 
2.14.2


  parent reply	other threads:[~2017-10-27 13:17 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-25 10:00 [PATCH] Introduce 4-stages profiledbootstrap to get a better profile Martin Liška
2017-05-25 10:00 ` Martin Liška
2017-05-25 11:38 ` Markus Trippelsdorf
2017-05-25 16:28   ` Martin Liška
2017-05-29 15:11     ` Jan Hubicka
2017-05-29  5:14 ` Markus Trippelsdorf
2017-06-06 13:30   ` Martin Liška
2017-06-19 10:37     ` Jan Hubicka
2017-08-30 10:44       ` [RFC] Make 4-stage PGO bootstrap really working Martin Liška
2017-09-14 12:21         ` Martin Liška
2017-10-19 12:59           ` Martin Liška
2017-10-19 14:53             ` Markus Trippelsdorf
2017-10-25 12:43         ` Markus Trippelsdorf
2017-10-27 13:07           ` Martin Liška
2017-10-27 15:00             ` Markus Trippelsdorf
2017-10-30 11:08               ` Richard Biener
2017-10-27 13:17           ` [PATCH][OBVIOUS] Fix profiledbootstrap Martin Liška
2017-10-27 13:19 ` Martin Liška [this message]
2017-12-20 14:55   ` [PATCH] Append PWD to path when using -fprofile-generate=/some/path Martin Liška
2017-12-20 17:35   ` Martin Sebor
2017-12-20 17:45     ` Jakub Jelinek
2017-12-20 18:00       ` Martin Sebor
2017-12-21  9:13       ` Martin Liška
2017-12-21 16:30         ` Martin Sebor
2018-05-16 12:26         ` [PATCH] When using -fprofile-generate=/some/path mangle absolute path of file (PR lto/85759) Martin Liška
2018-06-20 11:54           ` Martin Liška
2018-06-22 20:35           ` Jeff Law
2018-06-29 14:38             ` Martin Liška
2018-07-02  8:51               ` Rainer Orth
2018-07-20  4:02               ` Bin.Cheng
2018-07-20  8:43                 ` Martin Liška
2018-07-03  9:39           ` Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41f0b7e4-1a6b-3f5e-1e3a-750502e73043@suse.cz \
    --to=mliska@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=richard.guenther@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).