Skip to content

Commit de7a5e9

Browse files
Dmitry Chernenkovsmallp-o-p
Dmitry Chernenkov
authored and
smallp-o-p
committed
Revert "[InstrPGO] Support cold function coverage instrumentation (llvm#109837)"
This reverts commit e517cfc.
1 parent 0e354c0 commit de7a5e9

File tree

8 files changed

+2
-126
lines changed

8 files changed

+2
-126
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,12 +1786,6 @@ defm debug_info_for_profiling : BoolFOption<"debug-info-for-profiling",
17861786
PosFlag<SetTrue, [], [ClangOption, CC1Option],
17871787
"Emit extra debug info to make sample profile more accurate">,
17881788
NegFlag<SetFalse>>;
1789-
def fprofile_generate_cold_function_coverage : Flag<["-"], "fprofile-generate-cold-function-coverage">,
1790-
Group<f_Group>, Visibility<[ClangOption, CLOption]>,
1791-
HelpText<"Generate instrumented code to collect coverage info for cold functions into default.profraw file (overridden by '=' form of option or LLVM_PROFILE_FILE env var)">;
1792-
def fprofile_generate_cold_function_coverage_EQ : Joined<["-"], "fprofile-generate-cold-function-coverage=">,
1793-
Group<f_Group>, Visibility<[ClangOption, CLOption]>, MetaVarName<"<directory>">,
1794-
HelpText<"Generate instrumented code to collect coverage info for cold functions into <directory>/default.profraw (overridden by LLVM_PROFILE_FILE env var)">;
17951789
def fprofile_instr_generate : Flag<["-"], "fprofile-instr-generate">,
17961790
Group<f_Group>, Visibility<[ClangOption, CLOption]>,
17971791
HelpText<"Generate instrumented code to collect execution counts into default.profraw file (overridden by '=' form of option or LLVM_PROFILE_FILE env var)">;

clang/lib/Driver/ToolChain.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -899,9 +899,7 @@ bool ToolChain::needsProfileRT(const ArgList &Args) {
899899
Args.hasArg(options::OPT_fprofile_instr_generate) ||
900900
Args.hasArg(options::OPT_fprofile_instr_generate_EQ) ||
901901
Args.hasArg(options::OPT_fcreate_profile) ||
902-
Args.hasArg(options::OPT_forder_file_instrumentation) ||
903-
Args.hasArg(options::OPT_fprofile_generate_cold_function_coverage) ||
904-
Args.hasArg(options::OPT_fprofile_generate_cold_function_coverage_EQ);
902+
Args.hasArg(options::OPT_forder_file_instrumentation);
905903
}
906904

907905
bool ToolChain::needsGCovInstrumentation(const llvm::opt::ArgList &Args) {

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -632,26 +632,6 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, Compilation &C,
632632
}
633633
}
634634

635-
if (auto *ColdFuncCoverageArg = Args.getLastArg(
636-
options::OPT_fprofile_generate_cold_function_coverage,
637-
options::OPT_fprofile_generate_cold_function_coverage_EQ)) {
638-
SmallString<128> Path(
639-
ColdFuncCoverageArg->getOption().matches(
640-
options::OPT_fprofile_generate_cold_function_coverage_EQ)
641-
? ColdFuncCoverageArg->getValue()
642-
: "");
643-
llvm::sys::path::append(Path, "default_%m.profraw");
644-
// FIXME: Idealy the file path should be passed through
645-
// `-fprofile-instrument-path=`(InstrProfileOutput), however, this field is
646-
// shared with other profile use path(see PGOOptions), we need to refactor
647-
// PGOOptions to make it work.
648-
CmdArgs.push_back("-mllvm");
649-
CmdArgs.push_back(Args.MakeArgString(
650-
Twine("--instrument-cold-function-only-path=") + Path));
651-
CmdArgs.push_back("-mllvm");
652-
CmdArgs.push_back("--pgo-function-entry-coverage");
653-
}
654-
655635
Arg *PGOGenArg = nullptr;
656636
if (PGOGenerateArg) {
657637
assert(!CSPGOGenerateArg);

clang/test/CodeGen/pgo-cold-function-coverage.c

Lines changed: 0 additions & 19 deletions
This file was deleted.

clang/test/Driver/fprofile-generate-cold-function-coverage.c

Lines changed: 0 additions & 8 deletions
This file was deleted.

llvm/lib/Passes/PassBuilderPipelines.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,7 @@ static cl::opt<bool> UseLoopVersioningLICM(
296296
"enable-loop-versioning-licm", cl::init(false), cl::Hidden,
297297
cl::desc("Enable the experimental Loop Versioning LICM pass"));
298298

299-
static cl::opt<std::string> InstrumentColdFuncOnlyPath(
300-
"instrument-cold-function-only-path", cl::init(""),
301-
cl::desc("File path for cold function only instrumentation"), cl::Hidden);
302-
303299
extern cl::opt<std::string> UseCtxProfile;
304-
extern cl::opt<bool> PGOInstrumentColdFunctionOnly;
305300

306301
namespace llvm {
307302
extern cl::opt<bool> EnableMemProfContextDisambiguation;
@@ -1188,13 +1183,8 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
11881183
const bool IsCtxProfUse =
11891184
!UseCtxProfile.empty() && Phase == ThinOrFullLTOPhase::ThinLTOPreLink;
11901185

1191-
// Enable cold function coverage instrumentation if
1192-
// InstrumentColdFuncOnlyPath is provided.
1193-
const bool IsColdFuncOnlyInstrGen = PGOInstrumentColdFunctionOnly =
1194-
IsPGOPreLink && !InstrumentColdFuncOnlyPath.empty();
1195-
11961186
if (IsPGOInstrGen || IsPGOInstrUse || IsMemprofUse || IsCtxProfGen ||
1197-
IsCtxProfUse || IsColdFuncOnlyInstrGen)
1187+
IsCtxProfUse)
11981188
addPreInlinerPasses(MPM, Level, Phase);
11991189

12001190
// Add all the requested passes for instrumentation PGO, if requested.
@@ -1216,11 +1206,6 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
12161206
return MPM;
12171207
addPostPGOLoopRotation(MPM, Level);
12181208
MPM.addPass(PGOCtxProfLoweringPass());
1219-
} else if (IsColdFuncOnlyInstrGen) {
1220-
addPGOInstrPasses(
1221-
MPM, Level, /* RunProfileGen */ true, /* IsCS */ false,
1222-
/* AtomicCounterUpdate */ false, InstrumentColdFuncOnlyPath,
1223-
/* ProfileRemappingFile */ "", IntrusiveRefCntPtr<vfs::FileSystem>());
12241209
}
12251210

12261211
if (IsPGOInstrGen || IsPGOInstrUse || IsCtxProfGen)

llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -319,20 +319,6 @@ static cl::opt<unsigned> PGOFunctionCriticalEdgeThreshold(
319319
cl::desc("Do not instrument functions with the number of critical edges "
320320
" greater than this threshold."));
321321

322-
static cl::opt<uint64_t> PGOColdInstrumentEntryThreshold(
323-
"pgo-cold-instrument-entry-threshold", cl::init(0), cl::Hidden,
324-
cl::desc("For cold function instrumentation, skip instrumenting functions "
325-
"whose entry count is above the given value."));
326-
327-
static cl::opt<bool> PGOTreatUnknownAsCold(
328-
"pgo-treat-unknown-as-cold", cl::init(false), cl::Hidden,
329-
cl::desc("For cold function instrumentation, treat count unknown(e.g. "
330-
"unprofiled) functions as cold."));
331-
332-
cl::opt<bool> PGOInstrumentColdFunctionOnly(
333-
"pgo-instrument-cold-function-only", cl::init(false), cl::Hidden,
334-
cl::desc("Enable cold function only instrumentation."));
335-
336322
extern cl::opt<unsigned> MaxNumVTableAnnotations;
337323

338324
namespace llvm {
@@ -1911,11 +1897,6 @@ static bool skipPGOGen(const Function &F) {
19111897
return true;
19121898
if (F.getInstructionCount() < PGOFunctionSizeThreshold)
19131899
return true;
1914-
if (PGOInstrumentColdFunctionOnly) {
1915-
if (auto EntryCount = F.getEntryCount())
1916-
return EntryCount->getCount() > PGOColdInstrumentEntryThreshold;
1917-
return !PGOTreatUnknownAsCold;
1918-
}
19191900
return false;
19201901
}
19211902

llvm/test/Transforms/PGOProfile/instr-gen-cold-function.ll

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)