@@ -252,20 +252,21 @@ static cl::opt<unsigned> PrecentMismatchForStalenessError(
252
252
253
253
static cl::opt<bool > CallsitePrioritizedInline (
254
254
" sample-profile-prioritized-inline" , cl::Hidden,
255
-
256
255
cl::desc (" Use call site prioritized inlining for sample profile loader."
257
256
" Currently only CSSPGO is supported." ));
258
257
259
258
static cl::opt<bool > UsePreInlinerDecision (
260
259
" sample-profile-use-preinliner" , cl::Hidden,
261
-
262
260
cl::desc (" Use the preinliner decisions stored in profile context." ));
263
261
264
262
static cl::opt<bool > AllowRecursiveInline (
265
263
" sample-profile-recursive-inline" , cl::Hidden,
266
-
267
264
cl::desc (" Allow sample loader inliner to inline recursive calls." ));
268
265
266
+ static cl::opt<bool > RemoveProbeAfterProfileAnnotation (
267
+ " sample-profile-remove-probe" , cl::Hidden, cl::init(false ),
268
+ cl::desc(" Remove pseudo-probe after sample profile annotation." ));
269
+
269
270
static cl::opt<std::string> ProfileInlineReplayFile (
270
271
" sample-profile-inline-replay" , cl::init(" " ), cl::value_desc(" filename" ),
271
272
cl::desc(
@@ -518,6 +519,7 @@ class SampleProfileLoader final : public SampleProfileLoaderBaseImpl<Function> {
518
519
void generateMDProfMetadata (Function &F);
519
520
bool rejectHighStalenessProfile (Module &M, ProfileSummaryInfo *PSI,
520
521
const SampleProfileMap &Profiles);
522
+ void removePseudoProbeInsts (Module &M);
521
523
522
524
// / Map from function name to Function *. Used to find the function from
523
525
// / the function name. If the function name contains suffix, additional
@@ -2127,6 +2129,20 @@ bool SampleProfileLoader::rejectHighStalenessProfile(
2127
2129
return false ;
2128
2130
}
2129
2131
2132
+ void SampleProfileLoader::removePseudoProbeInsts (Module &M) {
2133
+ for (auto &F : M) {
2134
+ std::vector<Instruction *> InstsToDel;
2135
+ for (auto &BB : F) {
2136
+ for (auto &I : BB) {
2137
+ if (isa<PseudoProbeInst>(&I))
2138
+ InstsToDel.push_back (&I);
2139
+ }
2140
+ }
2141
+ for (auto *I : InstsToDel)
2142
+ I->eraseFromParent ();
2143
+ }
2144
+ }
2145
+
2130
2146
bool SampleProfileLoader::runOnModule (Module &M, ModuleAnalysisManager *AM,
2131
2147
ProfileSummaryInfo *_PSI,
2132
2148
LazyCallGraph &CG) {
@@ -2196,6 +2212,9 @@ bool SampleProfileLoader::runOnModule(Module &M, ModuleAnalysisManager *AM,
2196
2212
notInlinedCallInfo)
2197
2213
updateProfileCallee (pair.first , pair.second .entryCount );
2198
2214
2215
+ if (RemoveProbeAfterProfileAnnotation && FunctionSamples::ProfileIsProbeBased)
2216
+ removePseudoProbeInsts (M);
2217
+
2199
2218
return retval;
2200
2219
}
2201
2220
0 commit comments