Skip to content

Commit 5e6f4b3

Browse files
committed
Add comments explaining the different profile files.
Also adjust ifdef to be a bit more clear.
1 parent f6f1974 commit 5e6f4b3

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

compiler-rt/lib/profile/InstrProfilingPlatformLinux.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,30 @@
66
|*
77
\*===----------------------------------------------------------------------===*/
88

9+
// This file defines profile data symbols for ELF, wasm, XCOFF. It assumes
10+
// __start_ and __stop_ symbols for profile data point at the beginning and
11+
// end of the sections in question. (This is technically a linker feature,
12+
// not a file format feature, but linkers for these targets support it.)
13+
//
14+
// MachO (MacOS/iOS) and PE-COFF (Windows) have a similar support, but the
15+
// identifiers are different, so the support is in separate files.
16+
//
17+
// Support for targets which don't have linker support is in
18+
// InstrProfilingPlatformOther.c.
19+
//
20+
// This file also contains code to extract ELF build IDs from the ELF file,
21+
// to identify the build which generated the file.
22+
923
#if defined(__linux__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \
1024
(defined(__sun__) && defined(__svr4__)) || defined(__NetBSD__) || \
1125
defined(_AIX) || defined(__wasm__) || defined(__HAIKU__) || \
1226
defined(COMPILER_RT_PROFILE_BAREMETAL)
1327

14-
#ifndef COMPILER_RT_PROFILE_BAREMETAL
15-
#if !defined(_AIX) && !defined(__wasm__)
28+
#if !defined(_AIX) && !defined(__wasm__) && \
29+
!defined(COMPILER_RT_PROFILE_BAREMETAL)
30+
// Includes for non-baremetal ELF targets, used to output build IDs.
1631
#include <elf.h>
1732
#include <link.h>
18-
#endif
1933
#include <stdlib.h>
2034
#include <string.h>
2135
#endif

compiler-rt/lib/profile/InstrProfilingPlatformOther.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
|*
77
\*===----------------------------------------------------------------------===*/
88

9+
// This file defines a fallback implementation to compute the locations of
10+
// profile data sections, for targets that don't have linker support. No
11+
// commonly used targets use this codepath.
12+
//
13+
// This implementation expects the compiler instrumentation pass to define a
14+
// constructor in each file which calls into this file.
15+
916
#if !defined(__APPLE__) && !defined(__linux__) && !defined(__FreeBSD__) && \
1017
!defined(__Fuchsia__) && !(defined(__sun__) && defined(__svr4__)) && \
1118
!defined(__NetBSD__) && !defined(_WIN32) && !defined(_AIX) && \

0 commit comments

Comments
 (0)