2015-10-14 02:40:00 +08:00
|
|
|
/*===- InstrProfilingPlatformLinux.c - Profile data Linux platform ------===*\
|
|
|
|
|*
|
2019-01-19 16:50:56 +08:00
|
|
|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
|* See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2015-10-14 02:40:00 +08:00
|
|
|
|*
|
|
|
|
\*===----------------------------------------------------------------------===*/
|
|
|
|
|
2018-07-25 11:01:35 +08:00
|
|
|
#if defined(__linux__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \
|
2018-12-22 14:56:19 +08:00
|
|
|
(defined(__sun__) && defined(__svr4__)) || defined(__NetBSD__)
|
2015-10-14 02:40:00 +08:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2017-12-15 03:01:04 +08:00
|
|
|
#include "InstrProfiling.h"
|
|
|
|
|
[InstrProf] Implement static profdata registration
Summary:
The motivating use case is eliminating duplicate profile data registered
for the same inline function in two object files. Before this change,
users would observe multiple symbol definition errors with VC link, but
links with LLD would succeed.
Users (Mozilla) have reported that PGO works well with clang-cl and LLD,
but when using LLD without this static registration, we would get into a
"relocation against a discarded section" situation. I'm not sure what
happens in that situation, but I suspect that duplicate, unused profile
information was retained. If so, this change will reduce the size of
such binaries with LLD.
Now, Windows uses static registration and is in line with all the other
platforms.
Reviewers: davidxl, wmi, inglorion, void, calixte
Subscribers: mgorny, krytarowski, eraman, fedor.sergeev, hiraditya, #sanitizers, dmajor, llvm-commits
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D57929
llvm-svn: 353547
2019-02-09 03:03:50 +08:00
|
|
|
#define PROF_DATA_START INSTR_PROF_SECT_START(INSTR_PROF_DATA_COMMON)
|
|
|
|
#define PROF_DATA_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_DATA_COMMON)
|
|
|
|
#define PROF_NAME_START INSTR_PROF_SECT_START(INSTR_PROF_NAME_COMMON)
|
|
|
|
#define PROF_NAME_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_NAME_COMMON)
|
|
|
|
#define PROF_CNTS_START INSTR_PROF_SECT_START(INSTR_PROF_CNTS_COMMON)
|
|
|
|
#define PROF_CNTS_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_CNTS_COMMON)
|
2019-03-08 23:30:56 +08:00
|
|
|
#define PROF_ORDERFILE_START INSTR_PROF_SECT_START(INSTR_PROF_ORDERFILE_COMMON)
|
[InstrProf] Implement static profdata registration
Summary:
The motivating use case is eliminating duplicate profile data registered
for the same inline function in two object files. Before this change,
users would observe multiple symbol definition errors with VC link, but
links with LLD would succeed.
Users (Mozilla) have reported that PGO works well with clang-cl and LLD,
but when using LLD without this static registration, we would get into a
"relocation against a discarded section" situation. I'm not sure what
happens in that situation, but I suspect that duplicate, unused profile
information was retained. If so, this change will reduce the size of
such binaries with LLD.
Now, Windows uses static registration and is in line with all the other
platforms.
Reviewers: davidxl, wmi, inglorion, void, calixte
Subscribers: mgorny, krytarowski, eraman, fedor.sergeev, hiraditya, #sanitizers, dmajor, llvm-commits
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D57929
llvm-svn: 353547
2019-02-09 03:03:50 +08:00
|
|
|
#define PROF_VNODES_START INSTR_PROF_SECT_START(INSTR_PROF_VNODES_COMMON)
|
|
|
|
#define PROF_VNODES_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_VNODES_COMMON)
|
2015-11-24 02:56:03 +08:00
|
|
|
|
|
|
|
/* Declare section start and stop symbols for various sections
|
2020-06-10 17:25:47 +08:00
|
|
|
* generated by compiler instrumentation.
|
2015-11-24 02:56:03 +08:00
|
|
|
*/
|
2020-06-10 17:25:47 +08:00
|
|
|
extern __llvm_profile_data PROF_DATA_START COMPILER_RT_VISIBILITY;
|
|
|
|
extern __llvm_profile_data PROF_DATA_STOP COMPILER_RT_VISIBILITY;
|
|
|
|
extern uint64_t PROF_CNTS_START COMPILER_RT_VISIBILITY;
|
|
|
|
extern uint64_t PROF_CNTS_STOP COMPILER_RT_VISIBILITY;
|
|
|
|
extern uint32_t PROF_ORDERFILE_START COMPILER_RT_VISIBILITY;
|
|
|
|
extern char PROF_NAME_START COMPILER_RT_VISIBILITY;
|
|
|
|
extern char PROF_NAME_STOP COMPILER_RT_VISIBILITY;
|
|
|
|
extern ValueProfNode PROF_VNODES_START COMPILER_RT_VISIBILITY;
|
|
|
|
extern ValueProfNode PROF_VNODES_STOP COMPILER_RT_VISIBILITY;
|
|
|
|
|
|
|
|
/* Add dummy data to ensure the section is always created. */
|
|
|
|
__llvm_profile_data
|
|
|
|
__prof_data_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_DATA_SECT_NAME);
|
|
|
|
uint64_t
|
|
|
|
__prof_cnts_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_CNTS_SECT_NAME);
|
|
|
|
uint32_t
|
|
|
|
__prof_orderfile_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_ORDERFILE_SECT_NAME);
|
|
|
|
char __prof_nms_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_NAME_SECT_NAME);
|
|
|
|
ValueProfNode __prof_vnodes_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_VNODES_SECT_NAME);
|
2015-11-14 06:33:07 +08:00
|
|
|
|
2015-12-16 11:29:15 +08:00
|
|
|
COMPILER_RT_VISIBILITY const __llvm_profile_data *
|
2015-10-14 02:40:00 +08:00
|
|
|
__llvm_profile_begin_data(void) {
|
2015-11-24 02:56:03 +08:00
|
|
|
return &PROF_DATA_START;
|
2015-10-14 02:40:00 +08:00
|
|
|
}
|
2015-12-16 11:29:15 +08:00
|
|
|
COMPILER_RT_VISIBILITY const __llvm_profile_data *
|
2015-10-14 02:40:00 +08:00
|
|
|
__llvm_profile_end_data(void) {
|
2015-11-24 02:56:03 +08:00
|
|
|
return &PROF_DATA_STOP;
|
2015-10-14 02:40:00 +08:00
|
|
|
}
|
2015-12-16 11:29:15 +08:00
|
|
|
COMPILER_RT_VISIBILITY const char *__llvm_profile_begin_names(void) {
|
2015-11-24 02:56:03 +08:00
|
|
|
return &PROF_NAME_START;
|
2015-10-14 02:40:00 +08:00
|
|
|
}
|
2015-12-16 11:29:15 +08:00
|
|
|
COMPILER_RT_VISIBILITY const char *__llvm_profile_end_names(void) {
|
2015-11-24 02:56:03 +08:00
|
|
|
return &PROF_NAME_STOP;
|
2015-10-14 02:40:00 +08:00
|
|
|
}
|
2015-12-16 11:29:15 +08:00
|
|
|
COMPILER_RT_VISIBILITY uint64_t *__llvm_profile_begin_counters(void) {
|
2015-11-24 02:56:03 +08:00
|
|
|
return &PROF_CNTS_START;
|
2015-10-14 02:40:00 +08:00
|
|
|
}
|
2015-12-16 11:29:15 +08:00
|
|
|
COMPILER_RT_VISIBILITY uint64_t *__llvm_profile_end_counters(void) {
|
2015-11-24 02:56:03 +08:00
|
|
|
return &PROF_CNTS_STOP;
|
2015-10-14 02:40:00 +08:00
|
|
|
}
|
2019-03-08 23:30:56 +08:00
|
|
|
COMPILER_RT_VISIBILITY uint32_t *__llvm_profile_begin_orderfile(void) {
|
|
|
|
return &PROF_ORDERFILE_START;
|
|
|
|
}
|
2016-05-22 06:55:45 +08:00
|
|
|
|
|
|
|
COMPILER_RT_VISIBILITY ValueProfNode *
|
|
|
|
__llvm_profile_begin_vnodes(void) {
|
|
|
|
return &PROF_VNODES_START;
|
|
|
|
}
|
2016-05-23 00:36:03 +08:00
|
|
|
COMPILER_RT_VISIBILITY ValueProfNode *__llvm_profile_end_vnodes(void) {
|
2016-05-22 06:55:45 +08:00
|
|
|
return &PROF_VNODES_STOP;
|
|
|
|
}
|
2016-05-23 00:36:03 +08:00
|
|
|
COMPILER_RT_VISIBILITY ValueProfNode *CurrentVNode = &PROF_VNODES_START;
|
|
|
|
COMPILER_RT_VISIBILITY ValueProfNode *EndVNode = &PROF_VNODES_STOP;
|
|
|
|
|
2015-10-14 02:40:00 +08:00
|
|
|
#endif
|