Skip to content

Commit 2044dd0

Browse files
authored
[InstrProf] Remove -forder-file-instrumentation (#130192)
1 parent 0ed5f9b commit 2044dd0

File tree

27 files changed

+32
-502
lines changed

27 files changed

+32
-502
lines changed

clang/docs/UsersManual.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3195,7 +3195,6 @@ be collected.
31953195
the profile file to ``Name``.
31963196
* ``void __llvm_profile_reset_counters(void)``: resets all counters to zero.
31973197
* ``int __llvm_profile_dump(void)``: write the profile data to disk.
3198-
* ``int __llvm_orderfile_dump(void)``: write the order file to disk.
31993198

32003199
For example, the following pattern can be used to skip profiling program
32013200
initialization, profile two specific hot regions, and skip profiling program

clang/include/clang/Driver/Options.td

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,15 +1811,13 @@ def fprofile_continuous : Flag<["-"], "fprofile-continuous">,
18111811
HelpText<"Enable continuous instrumentation profiling mode">,
18121812
MarshallingInfoFlag<CodeGenOpts<"ContinuousProfileSync">>;
18131813

1814-
defm pseudo_probe_for_profiling : BoolFOption<"pseudo-probe-for-profiling",
1815-
CodeGenOpts<"PseudoProbeForProfiling">, DefaultFalse,
1816-
PosFlag<SetTrue, [], [ClangOption], "Emit">,
1817-
NegFlag<SetFalse, [], [ClangOption], "Do not emit">,
1818-
BothFlags<[], [ClangOption, CC1Option],
1819-
" pseudo probes for sample profiling">>;
1820-
def forder_file_instrumentation : Flag<["-"], "forder-file-instrumentation">,
1821-
Group<f_Group>, Visibility<[ClangOption, CC1Option, CLOption]>,
1822-
HelpText<"Generate instrumented code to collect order file into default.profraw file (overridden by '=' form of option or LLVM_PROFILE_FILE env var). Deprecated, please use -ftemporal-profile">;
1814+
defm pseudo_probe_for_profiling
1815+
: BoolFOption<"pseudo-probe-for-profiling",
1816+
CodeGenOpts<"PseudoProbeForProfiling">, DefaultFalse,
1817+
PosFlag<SetTrue, [], [ClangOption], "Emit">,
1818+
NegFlag<SetFalse, [], [ClangOption], "Do not emit">,
1819+
BothFlags<[], [ClangOption, CC1Option],
1820+
" pseudo probes for sample profiling">>;
18231821
def fprofile_list_EQ : Joined<["-"], "fprofile-list=">,
18241822
Group<f_Group>, Visibility<[ClangOption, CC1Option, CLOption]>,
18251823
HelpText<"Filename defining the list of functions/files to instrument. "

clang/lib/Driver/ToolChain.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,6 @@ bool ToolChain::needsProfileRT(const ArgList &Args) {
955955
Args.hasArg(options::OPT_fprofile_instr_generate) ||
956956
Args.hasArg(options::OPT_fprofile_instr_generate_EQ) ||
957957
Args.hasArg(options::OPT_fcreate_profile) ||
958-
Args.hasArg(options::OPT_forder_file_instrumentation) ||
959958
Args.hasArg(options::OPT_fprofile_generate_cold_function_coverage) ||
960959
Args.hasArg(options::OPT_fprofile_generate_cold_function_coverage_EQ);
961960
}

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8030,21 +8030,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
80308030
}
80318031
}
80328032

8033-
if (const Arg *A =
8034-
Args.getLastArg(options::OPT_forder_file_instrumentation)) {
8035-
D.Diag(diag::warn_drv_deprecated_arg)
8036-
<< A->getAsString(Args) << /*hasReplacement=*/true
8037-
<< "-ftemporal-profile";
8038-
CmdArgs.push_back("-forder-file-instrumentation");
8039-
// Enable order file instrumentation when ThinLTO is not on. When ThinLTO is
8040-
// on, we need to pass these flags as linker flags and that will be handled
8041-
// outside of the compiler.
8042-
if (!IsUsingLTO) {
8043-
CmdArgs.push_back("-mllvm");
8044-
CmdArgs.push_back("-enable-order-file-instrumentation");
8045-
}
8046-
}
8047-
80488033
if (Arg *A = Args.getLastArg(options::OPT_fforce_enable_int128,
80498034
options::OPT_fno_force_enable_int128)) {
80508035
if (A->getOption().matches(options::OPT_fforce_enable_int128))

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ static ArrayRef<options::ID> getUnsupportedOpts() {
4949
options::OPT_fno_profile_arcs, // -f[no-]profile-arcs
5050
options::OPT_fcreate_profile, // -fcreate-profile
5151
options::OPT_fprofile_instr_use,
52-
options::OPT_fprofile_instr_use_EQ, // -fprofile-instr-use
53-
options::OPT_forder_file_instrumentation, // -forder-file-instrumentation
54-
options::OPT_fcs_profile_generate, // -fcs-profile-generate
52+
options::OPT_fprofile_instr_use_EQ, // -fprofile-instr-use
53+
options::OPT_fcs_profile_generate, // -fcs-profile-generate
5554
options::OPT_fcs_profile_generate_EQ,
5655
};
5756
return UnsupportedOpts;

clang/test/Driver/clang_f_opts.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@
110110
// RUN: %clang -### -S -fcoverage-mapping -fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE %s
111111
// RUN: %clang -### -S -fprofile-instr-generate -fcoverage-mapping -fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE %s
112112
// RUN: %clang -### -S -fprofile-remapping-file=foo/bar.txt %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-REMAP %s
113-
// RUN: %clang -### -S -forder-file-instrumentation %s 2>&1 | FileCheck -check-prefix=CHECK-ORDERFILE-INSTR %s
114-
// RUN: %clang -### --target=x86_64-linux-gnu -flto -forder-file-instrumentation %s 2>&1 | FileCheck -check-prefix=CHECK-ORDERFILE-INSTR-LTO %s
115113
// CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang"
116114
// CHECK-PROFILE-GENERATE-LLVM: "-fprofile-instrument=llvm"
117115
// CHECK-PROFILE-GENERATE-DIR: "-fprofile-instrument-path=/some/dir{{/|\\\\}}{{.*}}"
@@ -123,10 +121,6 @@
123121
// CHECK-COVERAGE-AND-GEN: '-fcoverage-mapping' only allowed with '-fprofile-instr-generate'
124122
// CHECK-DISABLE-COVERAGE-NOT: "-fcoverage-mapping"
125123
// CHECK-PROFILE-REMAP: "-fprofile-remapping-file=foo/bar.txt"
126-
// CHECK-ORDERFILE-INSTR: "-forder-file-instrumentation"
127-
// CHECK-ORDERFILE-INSTR: "-enable-order-file-instrumentation"
128-
// CHECK-ORDERFILE-INSTR-LTO: "-forder-file-instrumentation"
129-
// CHECK-ORDERFILE-INSTR-LTO-NOT: "-enable-order-file-instrumentation"
130124

131125
// RUN: %clang -### -S -fprofile-use %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE %s
132126
// RUN: %clang -### -S -fprofile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE %s
@@ -371,7 +365,6 @@
371365
// RUN: -fno-devirtualize-speculatively \
372366
// RUN: -fslp-vectorize-aggressive \
373367
// RUN: -fno-slp-vectorize-aggressive \
374-
// RUN: -forder-file-instrumentation \
375368
// RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-WARNING %s
376369
// CHECK-WARNING-DAG: optimization flag '-finline-limit=1000' is not supported
377370
// CHECK-WARNING-DAG: optimization flag '-finline-limit' is not supported
@@ -431,7 +424,6 @@
431424
// CHECK-WARNING-DAG: optimization flag '-fno-devirtualize-speculatively' is not supported
432425
// CHECK-WARNING-DAG: the flag '-fslp-vectorize-aggressive' has been deprecated and will be ignored
433426
// CHECK-WARNING-DAG: the flag '-fno-slp-vectorize-aggressive' has been deprecated and will be ignored
434-
// CHECK-WARNING-DAG: argument '-forder-file-instrumentation' is deprecated, use '-ftemporal-profile' instead
435427

436428
// Test that we mute the warning on these
437429
// RUN: %clang -### -finline-limit=1000 -Wno-invalid-command-line-argument \

compiler-rt/include/profile/InstrProfData.inc

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,6 @@ INSTR_PROF_SECT_ENTRY(IPSK_covmap, \
348348
INSTR_PROF_SECT_ENTRY(IPSK_covfun, \
349349
INSTR_PROF_QUOTE(INSTR_PROF_COVFUN_COMMON), \
350350
INSTR_PROF_COVFUN_COFF, "__LLVM_COV,")
351-
INSTR_PROF_SECT_ENTRY(IPSK_orderfile, \
352-
INSTR_PROF_QUOTE(INSTR_PROF_ORDERFILE_COMMON), \
353-
INSTR_PROF_QUOTE(INSTR_PROF_ORDERFILE_COFF), "__DATA,")
354351
INSTR_PROF_SECT_ENTRY(IPSK_covdata, \
355352
INSTR_PROF_QUOTE(INSTR_PROF_COVDATA_COMMON), \
356353
INSTR_PROF_COVDATA_COFF, "__LLVM_COV,")
@@ -778,7 +775,6 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
778775
#define INSTR_PROF_COVFUN_COMMON __llvm_covfun
779776
#define INSTR_PROF_COVDATA_COMMON __llvm_covdata
780777
#define INSTR_PROF_COVNAME_COMMON __llvm_covnames
781-
#define INSTR_PROF_ORDERFILE_COMMON __llvm_orderfile
782778
#define INSTR_PROF_COVINIT_COMMON __llvm_covinit
783779

784780
/* Windows section names. Because these section names contain dollar characters,
@@ -799,7 +795,6 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
799795
*/
800796
#define INSTR_PROF_COVDATA_COFF ".lcovd"
801797
#define INSTR_PROF_COVNAME_COFF ".lcovn"
802-
#define INSTR_PROF_ORDERFILE_COFF ".lorderfile$M"
803798

804799
// FIXME: Placeholder for Windows. Windows currently does not initialize
805800
// the GCOV functions in the runtime.
@@ -823,7 +818,6 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
823818
#define INSTR_PROF_COVFUN_SECT_NAME INSTR_PROF_COVFUN_COFF
824819
#define INSTR_PROF_COVDATA_SECT_NAME INSTR_PROF_COVDATA_COFF
825820
#define INSTR_PROF_COVNAME_SECT_NAME INSTR_PROF_COVNAME_COFF
826-
#define INSTR_PROF_ORDERFILE_SECT_NAME INSTR_PROF_ORDERFILE_COFF
827821
#define INSTR_PROF_COVINIT_SECT_NAME INSTR_PROF_COVINIT_COFF
828822
#else
829823
/* Runtime section names and name strings. */
@@ -843,19 +837,9 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
843837
#define INSTR_PROF_COVFUN_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_COVFUN_COMMON)
844838
#define INSTR_PROF_COVDATA_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_COVDATA_COMMON)
845839
#define INSTR_PROF_COVNAME_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_COVNAME_COMMON)
846-
/* Order file instrumentation. */
847-
#define INSTR_PROF_ORDERFILE_SECT_NAME \
848-
INSTR_PROF_QUOTE(INSTR_PROF_ORDERFILE_COMMON)
849840
#define INSTR_PROF_COVINIT_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_COVINIT_COMMON)
850841
#endif
851842

852-
#define INSTR_PROF_ORDERFILE_BUFFER_NAME _llvm_order_file_buffer
853-
#define INSTR_PROF_ORDERFILE_BUFFER_NAME_STR \
854-
INSTR_PROF_QUOTE(INSTR_PROF_ORDERFILE_BUFFER_NAME)
855-
#define INSTR_PROF_ORDERFILE_BUFFER_IDX_NAME _llvm_order_file_buffer_idx
856-
#define INSTR_PROF_ORDERFILE_BUFFER_IDX_NAME_STR \
857-
INSTR_PROF_QUOTE(INSTR_PROF_ORDERFILE_BUFFER_IDX_NAME)
858-
859843
/* Macros to define start/stop section symbol for a given
860844
* section on Linux. For instance
861845
* INSTR_PROF_SECT_START(INSTR_PROF_DATA_SECT_NAME) will
@@ -889,12 +873,6 @@ typedef struct InstrProfValueData {
889873

890874
#endif /* INSTR_PROF_DATA_INC */
891875

892-
#ifndef INSTR_ORDER_FILE_INC
893-
/* The maximal # of functions: 128*1024 (the buffer size will be 128*4 KB). */
894-
#define INSTR_ORDER_FILE_BUFFER_SIZE 131072
895-
#define INSTR_ORDER_FILE_BUFFER_BITS 17
896-
#define INSTR_ORDER_FILE_BUFFER_MASK 0x1ffff
897-
#endif /* INSTR_ORDER_FILE_INC */
898876
#else
899877
#undef INSTR_PROF_DATA_DEFINED
900878
#endif

compiler-rt/include/profile/instr_prof_interface.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,11 @@ void __llvm_profile_reset_counters(void);
7373
*/
7474
int __llvm_profile_dump(void);
7575

76-
// Interface to dump the current process' order file to disk.
77-
int __llvm_orderfile_dump(void);
78-
7976
#else
8077

8178
#define __llvm_profile_set_filename(Name)
8279
#define __llvm_profile_reset_counters()
8380
#define __llvm_profile_dump() (0)
84-
#define __llvm_orderfile_dump() (0)
8581

8682
#endif
8783

compiler-rt/lib/profile/InstrProfiling.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ ValueProfNode *__llvm_profile_begin_vnodes(void);
124124
ValueProfNode *__llvm_profile_end_vnodes(void);
125125
const VTableProfData *__llvm_profile_begin_vtables(void);
126126
const VTableProfData *__llvm_profile_end_vtables(void);
127-
uint32_t *__llvm_profile_begin_orderfile(void);
128127

129128
/*!
130129
* \brief Merge profile data from buffer.
@@ -175,8 +174,6 @@ void __llvm_profile_instrument_target_value(uint64_t TargetValue, void *Data,
175174
*/
176175
int __llvm_profile_write_file(void);
177176

178-
int __llvm_orderfile_write_file(void);
179-
180177
/*!
181178
* \brief Set the FILE object for writing instrumentation data. Return 0 if set
182179
* successfully or return 1 if failed.

compiler-rt/lib/profile/InstrProfilingFile.c

Lines changed: 1 addition & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -357,15 +357,6 @@ static uint32_t fileWriter(ProfDataWriter *This, ProfDataIOVec *IOVecs,
357357
return 0;
358358
}
359359

360-
/* TODO: make buffer size controllable by an internal option, and compiler can pass the size
361-
to runtime via a variable. */
362-
static uint32_t orderFileWriter(FILE *File, const uint32_t *DataStart) {
363-
if (fwrite(DataStart, sizeof(uint32_t), INSTR_ORDER_FILE_BUFFER_SIZE, File) !=
364-
INSTR_ORDER_FILE_BUFFER_SIZE)
365-
return 1;
366-
return 0;
367-
}
368-
369360
static void initFileWriter(ProfDataWriter *This, FILE *File) {
370361
This->Write = fileWriter;
371362
This->WriterCtx = File;
@@ -503,7 +494,7 @@ static void createProfileDir(const char *Filename) {
503494
* the original profile data is truncated and gets ready for the profile
504495
* dumper. With profile merging enabled, each executable as well as any of
505496
* its instrumented shared libraries dump profile data into their own data file.
506-
*/
497+
*/
507498
static FILE *openFileForMerging(const char *ProfileFileName, int *MergeDone) {
508499
FILE *ProfileFile = getProfileFile();
509500
int rc;
@@ -577,27 +568,6 @@ static int writeFile(const char *OutputName) {
577568
return RetVal;
578569
}
579570

580-
/* Write order data to file \c OutputName. */
581-
static int writeOrderFile(const char *OutputName) {
582-
int RetVal;
583-
FILE *OutputFile;
584-
585-
OutputFile = fopen(OutputName, "w");
586-
587-
if (!OutputFile) {
588-
PROF_WARN("can't open file with mode ab: %s\n", OutputName);
589-
return -1;
590-
}
591-
592-
FreeHook = &free;
593-
setupIOBuffer();
594-
const uint32_t *DataBegin = __llvm_profile_begin_orderfile();
595-
RetVal = orderFileWriter(OutputFile, DataBegin);
596-
597-
fclose(OutputFile);
598-
return RetVal;
599-
}
600-
601571
#define LPROF_INIT_ONCE_ENV "__LLVM_PROFILE_RT_INIT_ONCE"
602572

603573
static void truncateCurrentFile(void) {
@@ -1239,65 +1209,6 @@ int __llvm_profile_dump(void) {
12391209
return rc;
12401210
}
12411211

1242-
/* Order file data will be saved in a file with suffx .order. */
1243-
static const char *OrderFileSuffix = ".order";
1244-
1245-
COMPILER_RT_VISIBILITY
1246-
int __llvm_orderfile_write_file(void) {
1247-
int rc, Length, LengthBeforeAppend, SuffixLength;
1248-
const char *Filename;
1249-
char *FilenameBuf;
1250-
1251-
// Temporarily suspend getting SIGKILL when the parent exits.
1252-
int PDeathSig = lprofSuspendSigKill();
1253-
1254-
SuffixLength = strlen(OrderFileSuffix);
1255-
Length = getCurFilenameLength() + SuffixLength;
1256-
FilenameBuf = (char *)COMPILER_RT_ALLOCA(Length + 1);
1257-
Filename = getCurFilename(FilenameBuf, 1);
1258-
1259-
/* Check the filename. */
1260-
if (!Filename) {
1261-
PROF_ERR("Failed to write file : %s\n", "Filename not set");
1262-
if (PDeathSig == 1)
1263-
lprofRestoreSigKill();
1264-
return -1;
1265-
}
1266-
1267-
/* Append order file suffix */
1268-
LengthBeforeAppend = strlen(Filename);
1269-
memcpy(FilenameBuf + LengthBeforeAppend, OrderFileSuffix, SuffixLength);
1270-
FilenameBuf[LengthBeforeAppend + SuffixLength] = '\0';
1271-
1272-
/* Check if there is llvm/runtime version mismatch. */
1273-
if (GET_VERSION(__llvm_profile_get_version()) != INSTR_PROF_RAW_VERSION) {
1274-
PROF_ERR("Runtime and instrumentation version mismatch : "
1275-
"expected %d, but get %d\n",
1276-
INSTR_PROF_RAW_VERSION,
1277-
(int)GET_VERSION(__llvm_profile_get_version()));
1278-
if (PDeathSig == 1)
1279-
lprofRestoreSigKill();
1280-
return -1;
1281-
}
1282-
1283-
/* Write order data to the file. */
1284-
rc = writeOrderFile(Filename);
1285-
if (rc)
1286-
PROF_ERR("Failed to write file \"%s\": %s\n", Filename, strerror(errno));
1287-
1288-
// Restore SIGKILL.
1289-
if (PDeathSig == 1)
1290-
lprofRestoreSigKill();
1291-
1292-
return rc;
1293-
}
1294-
1295-
COMPILER_RT_VISIBILITY
1296-
int __llvm_orderfile_dump(void) {
1297-
int rc = __llvm_orderfile_write_file();
1298-
return rc;
1299-
}
1300-
13011212
static void writeFileWithoutReturn(void) { __llvm_profile_write_file(); }
13021213

13031214
COMPILER_RT_VISIBILITY

0 commit comments

Comments
 (0)