Skip to content

Commit a825d2a

Browse files
port new object file sections and helper functions for non-ELF files
1 parent d0757f4 commit a825d2a

File tree

8 files changed

+82
-10
lines changed

8 files changed

+82
-10
lines changed

compiler-rt/include/profile/InstrProfData.inc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
748748
than WIN32 */
749749
#define INSTR_PROF_DATA_COMMON __llvm_prf_data
750750
#define INSTR_PROF_NAME_COMMON __llvm_prf_names
751-
#define INSTR_PROF_VNAME_COMMON __llvm_prf_vtabnames
751+
#define INSTR_PROF_VNAME_COMMON __llvm_prf_vns
752752
#define INSTR_PROF_CNTS_COMMON __llvm_prf_cnts
753753
#define INSTR_PROF_BITS_COMMON __llvm_prf_bits
754754
#define INSTR_PROF_VALS_COMMON __llvm_prf_vals
@@ -785,6 +785,8 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
785785
#define INSTR_PROF_NAME_SECT_NAME INSTR_PROF_NAME_COFF
786786
#define INSTR_PROF_CNTS_SECT_NAME INSTR_PROF_CNTS_COFF
787787
#define INSTR_PROF_BITS_SECT_NAME INSTR_PROF_BITS_COFF
788+
#define INSTR_PROF_VTAB_SECT_NAME INSTR_PROF_VTAB_COFF
789+
#define INSTR_PROF_VNAME_SECT_NAME INSTR_PROF_VNAME_COFF
788790
/* Array of pointers. Each pointer points to a list
789791
* of value nodes associated with one value site.
790792
*/
@@ -802,6 +804,8 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
802804
#define INSTR_PROF_NAME_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_NAME_COMMON)
803805
#define INSTR_PROF_CNTS_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_CNTS_COMMON)
804806
#define INSTR_PROF_BITS_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_BITS_COMMON)
807+
#define INSTR_PROF_VTAB_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_VTAB_COMMON)
808+
#define INSTR_PROF_VNAME_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_VNAME_COMMON)
805809
/* Array of pointers. Each pointer points to a list
806810
* of value nodes associated with one value site.
807811
*/

compiler-rt/lib/profile/InstrProfiling.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ char *__llvm_profile_begin_bitmap(void);
117117
char *__llvm_profile_end_bitmap(void);
118118
ValueProfNode *__llvm_profile_begin_vnodes();
119119
ValueProfNode *__llvm_profile_end_vnodes();
120-
VTableProfData *__llvm_profile_begin_vtables();
121-
VTableProfData *__llvm_profile_end_vtables();
120+
const VTableProfData *__llvm_profile_begin_vtables();
121+
const VTableProfData *__llvm_profile_end_vtables();
122122
uint32_t *__llvm_profile_begin_orderfile();
123123

124124
/*!

compiler-rt/lib/profile/InstrProfilingFile.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,18 @@ static int mmapForContinuousMode(uint64_t CurrentFileOffset, FILE *File) {
137137
DataBegin, PageSize);
138138
return 1;
139139
}
140+
140141
int Fileno = fileno(File);
141142
/* Determine how much padding is needed before/after the counters and
142143
* after the names. */
143144
uint64_t PaddingBytesBeforeCounters, PaddingBytesAfterCounters,
144-
PaddingBytesAfterNames, PaddingBytesAfterBitmapBytes;
145+
PaddingBytesAfterNames, PaddingBytesAfterBitmapBytes,
146+
PaddingBytesAfterVTable, PaddingBytesAfterVNames;
145147
__llvm_profile_get_padding_sizes_for_counters(
146-
DataSize, CountersSize, NumBitmapBytes, NamesSize,
147-
&PaddingBytesBeforeCounters, &PaddingBytesAfterCounters,
148-
&PaddingBytesAfterBitmapBytes, &PaddingBytesAfterNames);
148+
DataSize, CountersSize, NumBitmapBytes, NamesSize, /*VTableSize=*/0,
149+
/*VNameSize=*/0, &PaddingBytesBeforeCounters, &PaddingBytesAfterCounters,
150+
&PaddingBytesAfterBitmapBytes, &PaddingBytesAfterNames,
151+
&PaddingBytesAfterVTable, &PaddingBytesAfterVNames);
149152

150153
uint64_t PageAlignedCountersLength = CountersSize + PaddingBytesAfterCounters;
151154
uint64_t FileOffsetToCounters = CurrentFileOffset +

compiler-rt/lib/profile/InstrProfilingPlatformAIX.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ void __llvm_profile_register_names_function(void *NamesStart,
175175
uint64_t NamesSize) {}
176176

177177
// The __start_SECNAME and __stop_SECNAME symbols (for SECNAME \in
178-
// {"__llvm_prf_cnts", "__llvm_prf_data", "__llvm_prf_name", "__llvm_prf_vnds"})
178+
// {"__llvm_prf_cnts", "__llvm_prf_data", "__llvm_prf_name", "__llvm_prf_vnds",
179+
// "__llvm_prf_vns", "__llvm_prf_vtab"})
179180
// are always live when linking on AIX, regardless if the .o's being linked
180181
// reference symbols from the profile library (for example when no files were
181182
// compiled with -fprofile-generate). That's because these symbols are kept
@@ -197,6 +198,8 @@ static int dummy_vnds[0] COMPILER_RT_SECTION(
197198
COMPILER_RT_SEG INSTR_PROF_VNODES_SECT_NAME);
198199
static int dummy_orderfile[0] COMPILER_RT_SECTION(
199200
COMPILER_RT_SEG INSTR_PROF_ORDERFILE_SECT_NAME);
201+
static int dummy_vname[0] COMPILER_RT_SECTION(COMPILER_RT_SEG INSTR_PROF_VNAME_SECT_NAME);
202+
static int dummy_vtab[0] COMPILER_RT_SECTION(COMPILER_RT_SEG INSTR_PROF_VTAB_SECT_NAME);
200203

201204
// To avoid GC'ing of the dummy variables by the linker, reference them in an
202205
// array and reference the array in the runtime registration code
@@ -208,7 +211,8 @@ static int dummy_orderfile[0] COMPILER_RT_SECTION(
208211
COMPILER_RT_VISIBILITY
209212
void *__llvm_profile_keep[] = {(void *)&dummy_cnts, (void *)&dummy_bits,
210213
(void *)&dummy_data, (void *)&dummy_name,
211-
(void *)&dummy_vnds, (void *)&dummy_orderfile};
214+
(void *)&dummy_vnds, (void *)&dummy_orderfile,
215+
(void *)&dummy_vname, (void* )&dummy_vtab};
212216
#ifdef __GNUC__
213217
#pragma GCC diagnostic pop
214218
#endif

compiler-rt/lib/profile/InstrProfilingPlatformDarwin.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ extern char
3636
COMPILER_RT_VISIBILITY
3737
extern char BitmapEnd __asm("section$end$__DATA$" INSTR_PROF_BITS_SECT_NAME);
3838
COMPILER_RT_VISIBILITY
39+
extern VTableProfData
40+
VTableProfStart __asm("section$start$__DATA$" INSTR_PROF_VTAB_SECT_NAME);
41+
COMPILER_RT_VISIBILITY
42+
extern VTableProfData
43+
VTableProfEnd __asm("section$end$__DATA$" INSTR_PROF_VTAB_SECT_NAME);
44+
COMPILER_RT_VISIBILITY
45+
extern char
46+
VNameStart __asm("section$start$__DATA$" INSTR_PROF_VNAME_SECT_NAME);
47+
COMPILER_RT_VISIBILITY
48+
extern char VNameEnd __asm("section$end$__DATA$" INSTR_PROF_VNAME_SECT_NAME);
49+
COMPILER_RT_VISIBILITY
3950
extern uint32_t
4051
OrderFileStart __asm("section$start$__DATA$" INSTR_PROF_ORDERFILE_SECT_NAME);
4152

@@ -65,6 +76,18 @@ char *__llvm_profile_begin_bitmap(void) { return &BitmapStart; }
6576
COMPILER_RT_VISIBILITY
6677
char *__llvm_profile_end_bitmap(void) { return &BitmapEnd; }
6778
COMPILER_RT_VISIBILITY
79+
const VTableProfData *__llvm_profile_begin_vtables(void) {
80+
return &VTableProfStart;
81+
}
82+
COMPILER_RT_VISIBILITY
83+
const VTableProfData *__llvm_profile_end_vtables(void) {
84+
return &VTableProfEnd;
85+
}
86+
COMPILER_RT_VISIBILITY
87+
const char *__llvm_profile_begin_vtabnames(void) { return &VNameStart; }
88+
COMPILER_RT_VISIBILITY
89+
const char *__llvm_profile_end_vtabnames(void) { return &VNameEnd; }
90+
COMPILER_RT_VISIBILITY
6891
uint32_t *__llvm_profile_begin_orderfile(void) { return &OrderFileStart; }
6992

7093
COMPILER_RT_VISIBILITY

compiler-rt/lib/profile/InstrProfilingPlatformOther.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818

1919
static const __llvm_profile_data *DataFirst = NULL;
2020
static const __llvm_profile_data *DataLast = NULL;
21+
static const VTableProfData* VTableProfDataFirst = NULL;
22+
static const VTableProfData* VTableProfDataLast = NULL;
2123
static const char *NamesFirst = NULL;
2224
static const char *NamesLast = NULL;
25+
static const char* VNamesFirst = NULL;
26+
sttatic const char* VNamesLast = NULL;
2327
static char *CountersFirst = NULL;
2428
static char *CountersLast = NULL;
2529
static uint32_t *OrderFileFirst = NULL;
@@ -80,11 +84,20 @@ COMPILER_RT_VISIBILITY
8084
const __llvm_profile_data *__llvm_profile_begin_data(void) { return DataFirst; }
8185
COMPILER_RT_VISIBILITY
8286
const __llvm_profile_data *__llvm_profile_end_data(void) { return DataLast; }
87+
COMPILER_RT_VISIBILITY const VTableProfData* __llvm_profile_begin_vtables(void) {
88+
return VTableProfDataFirst;
89+
}
90+
COMPILER_RT_VISIBILITY const VTableProfData* __llvm_profile_end_vtables(void) {
91+
return VTableProfDataLast;
92+
}
8393
COMPILER_RT_VISIBILITY
8494
const char *__llvm_profile_begin_names(void) { return NamesFirst; }
8595
COMPILER_RT_VISIBILITY
8696
const char *__llvm_profile_end_names(void) { return NamesLast; }
8797
COMPILER_RT_VISIBILITY
98+
const char* __llvm_profile_begin_vtabnames(void) { return VNamesFirst; }
99+
const char* __llvm_profile_end_vtabnames(void) { return VNamesLast; }
100+
COMPILER_RT_VISIBILITY
88101
char *__llvm_profile_begin_counters(void) { return CountersFirst; }
89102
COMPILER_RT_VISIBILITY
90103
char *__llvm_profile_end_counters(void) { return CountersLast; }

compiler-rt/lib/profile/InstrProfilingPlatformWindows.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
/* Allocate read-only section bounds. */
2727
#pragma section(".lprfn$A", read)
2828
#pragma section(".lprfn$Z", read)
29+
#pragma section(".lprfvn$A", read)
30+
#pragma section(".lprfvn$Z", read)
31+
#pragma section(".lprfvt$A", read)
32+
#pragma section(".lprfvt$Z", read)
2933

3034
/* Allocate read-write section bounds. */
3135
#pragma section(".lprfd$A", read, write)
@@ -42,9 +46,15 @@
4246
__llvm_profile_data COMPILER_RT_SECTION(".lprfd$A") DataStart = {0};
4347
__llvm_profile_data COMPILER_RT_SECTION(".lprfd$Z") DataEnd = {0};
4448

49+
VTableProfData COMPILER_RT_SECTION(".lprfvt$A") VTableProfDataStart = {0};
50+
VTableProfData COMPILER_RT_SECTION(".lprfvt$Z") VTableProfDataEnd = {0};
51+
4552
const char COMPILER_RT_SECTION(".lprfn$A") NamesStart = '\0';
4653
const char COMPILER_RT_SECTION(".lprfn$Z") NamesEnd = '\0';
4754

55+
const char COMPILER_RT_SECTION(".lprfvn$A") VNamesStart = '\0';
56+
const char COMPILER_RT_SECTION(".lprfvn$Z") VNamesEnd = '\0';
57+
4858
char COMPILER_RT_SECTION(".lprfc$A") CountersStart;
4959
char COMPILER_RT_SECTION(".lprfc$Z") CountersEnd;
5060
char COMPILER_RT_SECTION(".lprfb$A") BitmapStart;
@@ -59,9 +69,20 @@ const __llvm_profile_data *__llvm_profile_begin_data(void) {
5969
}
6070
const __llvm_profile_data *__llvm_profile_end_data(void) { return &DataEnd; }
6171

72+
const VTableProfData* __llvm_profile_begin_vtables(void) {
73+
return &VTableProfDataStart + 1;
74+
}
75+
76+
const VTableProfData* __llvm_profile_end_vtables(void) {
77+
return &VTableProfDataEnd;
78+
}
79+
6280
const char *__llvm_profile_begin_names(void) { return &NamesStart + 1; }
6381
const char *__llvm_profile_end_names(void) { return &NamesEnd; }
6482

83+
const char* __llvm_profile_begin_vtabnames(void) { return &VNamesStart + 1; }
84+
const char* __llvm_profile_end_vtabnames(void) { return &VNamesEnd; }
85+
6586
char *__llvm_profile_begin_counters(void) { return &CountersStart + 1; }
6687
char *__llvm_profile_end_counters(void) { return &CountersEnd; }
6788
char *__llvm_profile_begin_bitmap(void) { return &BitmapStart + 1; }

llvm/include/llvm/ProfileData/InstrProfData.inc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
748748
than WIN32 */
749749
#define INSTR_PROF_DATA_COMMON __llvm_prf_data
750750
#define INSTR_PROF_NAME_COMMON __llvm_prf_names
751-
#define INSTR_PROF_VNAME_COMMON __llvm_prf_vtabnames
751+
#define INSTR_PROF_VNAME_COMMON __llvm_prf_vns
752752
#define INSTR_PROF_CNTS_COMMON __llvm_prf_cnts
753753
#define INSTR_PROF_BITS_COMMON __llvm_prf_bits
754754
#define INSTR_PROF_VALS_COMMON __llvm_prf_vals
@@ -785,6 +785,8 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
785785
#define INSTR_PROF_NAME_SECT_NAME INSTR_PROF_NAME_COFF
786786
#define INSTR_PROF_CNTS_SECT_NAME INSTR_PROF_CNTS_COFF
787787
#define INSTR_PROF_BITS_SECT_NAME INSTR_PROF_BITS_COFF
788+
#define INSTR_PROF_VTAB_SECT_NAME INSTR_PROF_VTAB_COFF
789+
#define INSTR_PROF_VNAME_SECT_NAME INSTR_PROF_VNAME_COFF
788790
/* Array of pointers. Each pointer points to a list
789791
* of value nodes associated with one value site.
790792
*/
@@ -802,6 +804,8 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
802804
#define INSTR_PROF_NAME_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_NAME_COMMON)
803805
#define INSTR_PROF_CNTS_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_CNTS_COMMON)
804806
#define INSTR_PROF_BITS_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_BITS_COMMON)
807+
#define INSTR_PROF_VTAB_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_VTAB_COMMON)
808+
#define INSTR_PROF_VNAME_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_VNAME_COMMON)
805809
/* Array of pointers. Each pointer points to a list
806810
* of value nodes associated with one value site.
807811
*/

0 commit comments

Comments
 (0)