Skip to content

Commit ecb4265

Browse files
[compiler-rt][profile] Use encapsulation symbols for Wasm format
Use `InstrProfilingPlatformLinux.c` for Wasm as well as Wasm format has encapsulation symbols (`__start_` and `__stop_`) similar to ELF. This unlocks several additional profile features like value profiling.
1 parent 605e1ad commit ecb4265

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

compiler-rt/lib/profile/InstrProfilingPlatformLinux.c

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

9-
#if defined(__linux__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \
10-
(defined(__sun__) && defined(__svr4__)) || defined(__NetBSD__) || \
11-
defined(_AIX)
9+
#if defined(__linux__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \
10+
(defined(__sun__) && defined(__svr4__)) || defined(__NetBSD__) || \
11+
defined(_AIX) || defined(__wasm__)
1212

13-
#if !defined(_AIX)
13+
#if !defined(_AIX) && !defined(__wasm__)
1414
#include <elf.h>
1515
#include <link.h>
1616
#endif

compiler-rt/lib/profile/InstrProfilingPlatformOther.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
#if !defined(__APPLE__) && !defined(__linux__) && !defined(__FreeBSD__) && \
1010
!defined(__Fuchsia__) && !(defined(__sun__) && defined(__svr4__)) && \
11-
!defined(__NetBSD__) && !defined(_WIN32) && !defined(_AIX)
11+
!defined(__NetBSD__) && !defined(_WIN32) && !defined(_AIX) && \
12+
!defined(__wasm__)
1213

1314
#include <stdlib.h>
1415
#include <stdio.h>

llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,9 +1406,10 @@ static inline Constant *getFuncAddrForProfData(Function *Fn) {
14061406

14071407
static bool needsRuntimeRegistrationOfSectionRange(const Triple &TT) {
14081408
// compiler-rt uses linker support to get data/counters/name start/end for
1409-
// ELF, COFF, Mach-O and XCOFF.
1409+
// ELF, COFF, Mach-O, XCOFF, and Wasm.
14101410
if (TT.isOSBinFormatELF() || TT.isOSBinFormatCOFF() ||
1411-
TT.isOSBinFormatMachO() || TT.isOSBinFormatXCOFF())
1411+
TT.isOSBinFormatMachO() || TT.isOSBinFormatXCOFF() ||
1412+
TT.isOSBinFormatWasm())
14121413
return false;
14131414

14141415
return true;

0 commit comments

Comments
 (0)