[PATCH] D101000: Coverage: Document how to collect a profile without a filesystem

Duncan P. N. Exon Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 21 15:06:36 PDT 2021


dexonsmith created this revision.
dexonsmith added a reviewer: vsk.
dexonsmith requested review of this revision.
Herald added a project: clang.

The profiling runtime was designed to work without static initializers
or a a filesystem (see 117cf2bd1ff585f9754b5f30f5a4cfd65b230bbf and
others). The no-static-initializers part was already documented but this
part got missed before.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101000

Files:
  clang/docs/SourceBasedCodeCoverage.rst


Index: clang/docs/SourceBasedCodeCoverage.rst
===================================================================
--- clang/docs/SourceBasedCodeCoverage.rst
+++ clang/docs/SourceBasedCodeCoverage.rst
@@ -346,6 +346,27 @@
 
 In C++ files, declare these as ``extern "C"``.
 
+Using the profiling runtime without a filesystem
+------------------------------------------------
+
+The profiling runtime also supports environments that lack a filesystem. Here's
+how to collect the profile into a buffer under your control:
+
+* Forward-declare ``uint64_t __llvm_profile_get_size_for_buffer(void)`` and
+  call it to determine the size of the profile. You'll need to allocate a
+  buffer of this size.
+
+* Forward-declare ``int __llvm_profile_write_buffer(char *Buffer)`` and call it
+  to copy the current counters to ``Buffer``, which is expected to already be
+  allocated and big enough for the profile.
+
+* Optionally, forward-declare ``void __llvm_profile_reset_counters(void)`` and
+  call it to reset the counters before entering a specific section to be
+  profiled. This is only useful if there is some setup that should be excluded
+  from the profile.
+
+In C++ files, declare these as ``extern "C"``.
+
 Collecting coverage reports for the llvm project
 ================================================
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101000.339401.patch
Type: text/x-patch
Size: 1314 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210421/bfdf7b71/attachment.bin>


More information about the cfe-commits mailing list