public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug gcov-profile/112829] New: Dump PGO profiles to a memory buffer
@ 2023-12-03  5:58 zamazan4ik at tut dot by
  2023-12-04  0:27 ` [Bug gcov-profile/112829] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: zamazan4ik at tut dot by @ 2023-12-03  5:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112829

            Bug ID: 112829
           Summary: Dump PGO profiles to a memory buffer
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: gcov-profile
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zamazan4ik at tut dot by
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

According to the GCC documentation
(https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html) the only
option is to dump PGO profiles to a filesystem. I am looking for an option to
dump PGO profiles into a memory buffer. LLVM infrastructure has such an ability
- it's documented here:
https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#using-the-profiling-runtime-without-a-filesystem
. If GCC has such an ability too - would be great if it would be described
somewhere in the Instrumentation documentation (or in any other better place in
your opinion).

The use case for having this is simple - in some systems, a filesystem can be
read-only (e.g. due to security concerns) or even not enough to handle the PGO
profile. With the memory approach, we will be able to collect PGO profiles and
then deliver and expose them via other interfaces like HTTP or MQTT.

I guess some related information can be found here
(https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libgcc/libgcov-profiler.c) but I
am not sure.

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

* [Bug gcov-profile/112829] Dump PGO profiles to a memory buffer
  2023-12-03  5:58 [Bug gcov-profile/112829] New: Dump PGO profiles to a memory buffer zamazan4ik at tut dot by
@ 2023-12-04  0:27 ` pinskia at gcc dot gnu.org
  2023-12-04  0:34 ` zamazan4ik at tut dot by
  2023-12-04  2:37 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-04  0:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112829

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
One way is to simple replace all of the functions in gcov-io.c and implement
them, gcov_open, etc.

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

* [Bug gcov-profile/112829] Dump PGO profiles to a memory buffer
  2023-12-03  5:58 [Bug gcov-profile/112829] New: Dump PGO profiles to a memory buffer zamazan4ik at tut dot by
  2023-12-04  0:27 ` [Bug gcov-profile/112829] " pinskia at gcc dot gnu.org
@ 2023-12-04  0:34 ` zamazan4ik at tut dot by
  2023-12-04  2:37 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: zamazan4ik at tut dot by @ 2023-12-04  0:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112829

--- Comment #2 from Alexander Zaitsev <zamazan4ik at tut dot by> ---
Am I right that right now in GCC there are no ready-to-use alternatives to "int
__llvm_profile_write_buffer(char *Buffer)" from LLVM and it should be
implemented somehow manually (as you described)?

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

* [Bug gcov-profile/112829] Dump PGO profiles to a memory buffer
  2023-12-03  5:58 [Bug gcov-profile/112829] New: Dump PGO profiles to a memory buffer zamazan4ik at tut dot by
  2023-12-04  0:27 ` [Bug gcov-profile/112829] " pinskia at gcc dot gnu.org
  2023-12-04  0:34 ` zamazan4ik at tut dot by
@ 2023-12-04  2:37 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-04  2:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112829

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
GCC does not currently have a way. Though I suspect one of the reasons is that
for embedded, folks don't use -fprofile-generate/-fprofile-use that much or
they use a simulator which then has direct access to the host machine to
generate the files.

I Know for Octeon SE (MIPS baremetal interface on the Cavium Octeon) that they
had a way to do this using memory dump but it was hooked up outside of gcov and
in newlib instead.

I do think this is a good idea for embedded env but I am not sure if anyone who
is interested in doing it. for Linux env, using nfs mount and
-fprofile-dir=/-fprofile-prefix-map=/-fprofile-prefix-path= is one way of doing
it.

Also if you are using Zephyr, it does handle the writes and does the store to
memory and such too.  See
https://docs.zephyrproject.org/latest/develop/test/coverage.html .

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

end of thread, other threads:[~2023-12-04  2:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-03  5:58 [Bug gcov-profile/112829] New: Dump PGO profiles to a memory buffer zamazan4ik at tut dot by
2023-12-04  0:27 ` [Bug gcov-profile/112829] " pinskia at gcc dot gnu.org
2023-12-04  0:34 ` zamazan4ik at tut dot by
2023-12-04  2:37 ` pinskia at gcc dot gnu.org

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).