Skip to content

Commit a06c7d9

Browse files
authored
[NFC][InstrProf] Rename internal InstrProfiling to InstrLowerer (#75139)
Captures its responsibility a bit better.
1 parent 31b72b0 commit a06c7d9

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ cl::opt<bool> SkipRetExitBlock(
154154

155155
using LoadStorePair = std::pair<Instruction *, Instruction *>;
156156

157-
class InstrProfiling final {
157+
class InstrLowerer final {
158158
public:
159-
InstrProfiling(Module &M, const InstrProfOptions &Options,
160-
std::function<const TargetLibraryInfo &(Function &F)> GetTLI,
161-
bool IsCS)
159+
InstrLowerer(Module &M, const InstrProfOptions &Options,
160+
std::function<const TargetLibraryInfo &(Function &F)> GetTLI,
161+
bool IsCS)
162162
: M(M), Options(Options), TT(Triple(M.getTargetTriple())), IsCS(IsCS),
163163
GetTLI(GetTLI) {}
164164

@@ -563,14 +563,14 @@ PreservedAnalyses InstrProfilingLoweringPass::run(Module &M,
563563
auto GetTLI = [&FAM](Function &F) -> TargetLibraryInfo & {
564564
return FAM.getResult<TargetLibraryAnalysis>(F);
565565
};
566-
InstrProfiling Lowerer(M, Options, GetTLI, IsCS);
566+
InstrLowerer Lowerer(M, Options, GetTLI, IsCS);
567567
if (!Lowerer.lower())
568568
return PreservedAnalyses::all();
569569

570570
return PreservedAnalyses::none();
571571
}
572572

573-
bool InstrProfiling::lowerIntrinsics(Function *F) {
573+
bool InstrLowerer::lowerIntrinsics(Function *F) {
574574
bool MadeChange = false;
575575
PromotionCandidates.clear();
576576
for (BasicBlock &BB : *F) {
@@ -610,7 +610,7 @@ bool InstrProfiling::lowerIntrinsics(Function *F) {
610610
return true;
611611
}
612612

613-
bool InstrProfiling::isRuntimeCounterRelocationEnabled() const {
613+
bool InstrLowerer::isRuntimeCounterRelocationEnabled() const {
614614
// Mach-O don't support weak external references.
615615
if (TT.isOSBinFormatMachO())
616616
return false;
@@ -622,14 +622,14 @@ bool InstrProfiling::isRuntimeCounterRelocationEnabled() const {
622622
return TT.isOSFuchsia();
623623
}
624624

625-
bool InstrProfiling::isCounterPromotionEnabled() const {
625+
bool InstrLowerer::isCounterPromotionEnabled() const {
626626
if (DoCounterPromotion.getNumOccurrences() > 0)
627627
return DoCounterPromotion;
628628

629629
return Options.DoCounterPromotion;
630630
}
631631

632-
void InstrProfiling::promoteCounterLoadStores(Function *F) {
632+
void InstrLowerer::promoteCounterLoadStores(Function *F) {
633633
if (!isCounterPromotionEnabled())
634634
return;
635635

@@ -686,7 +686,7 @@ static bool containsProfilingIntrinsics(Module &M) {
686686
containsIntrinsic(llvm::Intrinsic::instrprof_value_profile);
687687
}
688688

689-
bool InstrProfiling::lower() {
689+
bool InstrLowerer::lower() {
690690
bool MadeChange = false;
691691
bool NeedsRuntimeHook = needsRuntimeHookUnconditionally(TT);
692692
if (NeedsRuntimeHook)
@@ -778,7 +778,7 @@ static FunctionCallee getOrInsertValueProfilingCall(
778778
return M.getOrInsertFunction(FuncName, ValueProfilingCallTy, AL);
779779
}
780780

781-
void InstrProfiling::computeNumValueSiteCounts(InstrProfValueProfileInst *Ind) {
781+
void InstrLowerer::computeNumValueSiteCounts(InstrProfValueProfileInst *Ind) {
782782
GlobalVariable *Name = Ind->getName();
783783
uint64_t ValueKind = Ind->getValueKind()->getZExtValue();
784784
uint64_t Index = Ind->getIndex()->getZExtValue();
@@ -787,7 +787,7 @@ void InstrProfiling::computeNumValueSiteCounts(InstrProfValueProfileInst *Ind) {
787787
std::max(PD.NumValueSites[ValueKind], (uint32_t)(Index + 1));
788788
}
789789

790-
void InstrProfiling::lowerValueProfileInst(InstrProfValueProfileInst *Ind) {
790+
void InstrLowerer::lowerValueProfileInst(InstrProfValueProfileInst *Ind) {
791791
// TODO: Value profiling heavily depends on the data section which is omitted
792792
// in lightweight mode. We need to move the value profile pointer to the
793793
// Counter struct to get this working.
@@ -833,7 +833,7 @@ void InstrProfiling::lowerValueProfileInst(InstrProfValueProfileInst *Ind) {
833833
Ind->eraseFromParent();
834834
}
835835

836-
Value *InstrProfiling::getCounterAddress(InstrProfCntrInstBase *I) {
836+
Value *InstrLowerer::getCounterAddress(InstrProfCntrInstBase *I) {
837837
auto *Counters = getOrCreateRegionCounters(I);
838838
IRBuilder<> Builder(I);
839839

@@ -873,7 +873,7 @@ Value *InstrProfiling::getCounterAddress(InstrProfCntrInstBase *I) {
873873
return Builder.CreateIntToPtr(Add, Addr->getType());
874874
}
875875

876-
Value *InstrProfiling::getBitmapAddress(InstrProfMCDCTVBitmapUpdate *I) {
876+
Value *InstrLowerer::getBitmapAddress(InstrProfMCDCTVBitmapUpdate *I) {
877877
auto *Bitmaps = getOrCreateRegionBitmaps(I);
878878
IRBuilder<> Builder(I);
879879

@@ -892,15 +892,15 @@ Value *InstrProfiling::getBitmapAddress(InstrProfMCDCTVBitmapUpdate *I) {
892892
return Addr;
893893
}
894894

895-
void InstrProfiling::lowerCover(InstrProfCoverInst *CoverInstruction) {
895+
void InstrLowerer::lowerCover(InstrProfCoverInst *CoverInstruction) {
896896
auto *Addr = getCounterAddress(CoverInstruction);
897897
IRBuilder<> Builder(CoverInstruction);
898898
// We store zero to represent that this block is covered.
899899
Builder.CreateStore(Builder.getInt8(0), Addr);
900900
CoverInstruction->eraseFromParent();
901901
}
902902

903-
void InstrProfiling::lowerTimestamp(
903+
void InstrLowerer::lowerTimestamp(
904904
InstrProfTimestampInst *TimestampInstruction) {
905905
assert(TimestampInstruction->getIndex()->isZeroValue() &&
906906
"timestamp probes are always the first probe for a function");
@@ -915,7 +915,7 @@ void InstrProfiling::lowerTimestamp(
915915
TimestampInstruction->eraseFromParent();
916916
}
917917

918-
void InstrProfiling::lowerIncrement(InstrProfIncrementInst *Inc) {
918+
void InstrLowerer::lowerIncrement(InstrProfIncrementInst *Inc) {
919919
auto *Addr = getCounterAddress(Inc);
920920

921921
IRBuilder<> Builder(Inc);
@@ -934,7 +934,7 @@ void InstrProfiling::lowerIncrement(InstrProfIncrementInst *Inc) {
934934
Inc->eraseFromParent();
935935
}
936936

937-
void InstrProfiling::lowerCoverageData(GlobalVariable *CoverageNamesVar) {
937+
void InstrLowerer::lowerCoverageData(GlobalVariable *CoverageNamesVar) {
938938
ConstantArray *Names =
939939
cast<ConstantArray>(CoverageNamesVar->getInitializer());
940940
for (unsigned I = 0, E = Names->getNumOperands(); I < E; ++I) {
@@ -951,7 +951,7 @@ void InstrProfiling::lowerCoverageData(GlobalVariable *CoverageNamesVar) {
951951
CoverageNamesVar->eraseFromParent();
952952
}
953953

954-
void InstrProfiling::lowerMCDCTestVectorBitmapUpdate(
954+
void InstrLowerer::lowerMCDCTestVectorBitmapUpdate(
955955
InstrProfMCDCTVBitmapUpdate *Update) {
956956
IRBuilder<> Builder(Update);
957957
auto *Int8Ty = Type::getInt8Ty(M.getContext());
@@ -1003,7 +1003,7 @@ void InstrProfiling::lowerMCDCTestVectorBitmapUpdate(
10031003
Update->eraseFromParent();
10041004
}
10051005

1006-
void InstrProfiling::lowerMCDCCondBitmapUpdate(
1006+
void InstrLowerer::lowerMCDCCondBitmapUpdate(
10071007
InstrProfMCDCCondBitmapUpdate *Update) {
10081008
IRBuilder<> Builder(Update);
10091009
auto *Int32Ty = Type::getInt32Ty(M.getContext());
@@ -1186,8 +1186,8 @@ static bool needsRuntimeRegistrationOfSectionRange(const Triple &TT) {
11861186
return true;
11871187
}
11881188

1189-
void InstrProfiling::maybeSetComdat(GlobalVariable *GV, Function *Fn,
1190-
StringRef VarName) {
1189+
void InstrLowerer::maybeSetComdat(GlobalVariable *GV, Function *Fn,
1190+
StringRef VarName) {
11911191
bool DataReferencedByCode = profDataReferencedByCode(M);
11921192
bool NeedComdat = needsComdatForCounter(*Fn, M);
11931193
bool UseComdat = (NeedComdat || TT.isOSBinFormatELF());
@@ -1208,8 +1208,8 @@ void InstrProfiling::maybeSetComdat(GlobalVariable *GV, Function *Fn,
12081208
GV->setLinkage(GlobalValue::InternalLinkage);
12091209
}
12101210

1211-
GlobalVariable *InstrProfiling::setupProfileSection(InstrProfInstBase *Inc,
1212-
InstrProfSectKind IPSK) {
1211+
GlobalVariable *InstrLowerer::setupProfileSection(InstrProfInstBase *Inc,
1212+
InstrProfSectKind IPSK) {
12131213
GlobalVariable *NamePtr = Inc->getName();
12141214

12151215
// Match the linkage and visibility of the name global.
@@ -1278,9 +1278,9 @@ GlobalVariable *InstrProfiling::setupProfileSection(InstrProfInstBase *Inc,
12781278
}
12791279

12801280
GlobalVariable *
1281-
InstrProfiling::createRegionBitmaps(InstrProfMCDCBitmapInstBase *Inc,
1282-
StringRef Name,
1283-
GlobalValue::LinkageTypes Linkage) {
1281+
InstrLowerer::createRegionBitmaps(InstrProfMCDCBitmapInstBase *Inc,
1282+
StringRef Name,
1283+
GlobalValue::LinkageTypes Linkage) {
12841284
uint64_t NumBytes = Inc->getNumBitmapBytes()->getZExtValue();
12851285
auto *BitmapTy = ArrayType::get(Type::getInt8Ty(M.getContext()), NumBytes);
12861286
auto GV = new GlobalVariable(M, BitmapTy, false, Linkage,
@@ -1290,7 +1290,7 @@ InstrProfiling::createRegionBitmaps(InstrProfMCDCBitmapInstBase *Inc,
12901290
}
12911291

12921292
GlobalVariable *
1293-
InstrProfiling::getOrCreateRegionBitmaps(InstrProfMCDCBitmapInstBase *Inc) {
1293+
InstrLowerer::getOrCreateRegionBitmaps(InstrProfMCDCBitmapInstBase *Inc) {
12941294
GlobalVariable *NamePtr = Inc->getName();
12951295
auto &PD = ProfileDataMap[NamePtr];
12961296
if (PD.RegionBitmaps)
@@ -1305,8 +1305,8 @@ InstrProfiling::getOrCreateRegionBitmaps(InstrProfMCDCBitmapInstBase *Inc) {
13051305
}
13061306

13071307
GlobalVariable *
1308-
InstrProfiling::createRegionCounters(InstrProfCntrInstBase *Inc, StringRef Name,
1309-
GlobalValue::LinkageTypes Linkage) {
1308+
InstrLowerer::createRegionCounters(InstrProfCntrInstBase *Inc, StringRef Name,
1309+
GlobalValue::LinkageTypes Linkage) {
13101310
uint64_t NumCounters = Inc->getNumCounters()->getZExtValue();
13111311
auto &Ctx = M.getContext();
13121312
GlobalVariable *GV;
@@ -1330,7 +1330,7 @@ InstrProfiling::createRegionCounters(InstrProfCntrInstBase *Inc, StringRef Name,
13301330
}
13311331

13321332
GlobalVariable *
1333-
InstrProfiling::getOrCreateRegionCounters(InstrProfCntrInstBase *Inc) {
1333+
InstrLowerer::getOrCreateRegionCounters(InstrProfCntrInstBase *Inc) {
13341334
GlobalVariable *NamePtr = Inc->getName();
13351335
auto &PD = ProfileDataMap[NamePtr];
13361336
if (PD.RegionCounters)
@@ -1383,7 +1383,7 @@ InstrProfiling::getOrCreateRegionCounters(InstrProfCntrInstBase *Inc) {
13831383
return PD.RegionCounters;
13841384
}
13851385

1386-
void InstrProfiling::createDataVariable(InstrProfCntrInstBase *Inc) {
1386+
void InstrLowerer::createDataVariable(InstrProfCntrInstBase *Inc) {
13871387
// When debug information is correlated to profile data, a data variable
13881388
// is not needed.
13891389
if (DebugInfoCorrelate)
@@ -1523,7 +1523,7 @@ void InstrProfiling::createDataVariable(InstrProfCntrInstBase *Inc) {
15231523
ReferencedNames.push_back(NamePtr);
15241524
}
15251525

1526-
void InstrProfiling::emitVNodes() {
1526+
void InstrLowerer::emitVNodes() {
15271527
if (!ValueProfileStaticAlloc)
15281528
return;
15291529

@@ -1574,7 +1574,7 @@ void InstrProfiling::emitVNodes() {
15741574
UsedVars.push_back(VNodesVar);
15751575
}
15761576

1577-
void InstrProfiling::emitNameData() {
1577+
void InstrLowerer::emitNameData() {
15781578
std::string UncompressedData;
15791579

15801580
if (ReferencedNames.empty())
@@ -1608,7 +1608,7 @@ void InstrProfiling::emitNameData() {
16081608
NamePtr->eraseFromParent();
16091609
}
16101610

1611-
void InstrProfiling::emitRegistration() {
1611+
void InstrLowerer::emitRegistration() {
16121612
if (!needsRuntimeRegistrationOfSectionRange(TT))
16131613
return;
16141614

@@ -1649,7 +1649,7 @@ void InstrProfiling::emitRegistration() {
16491649
IRB.CreateRetVoid();
16501650
}
16511651

1652-
bool InstrProfiling::emitRuntimeHook() {
1652+
bool InstrLowerer::emitRuntimeHook() {
16531653
// We expect the linker to be invoked with -u<hook_var> flag for Linux
16541654
// in which case there is no need to emit the external variable.
16551655
if (TT.isOSLinux() || TT.isOSAIX())
@@ -1691,7 +1691,7 @@ bool InstrProfiling::emitRuntimeHook() {
16911691
return true;
16921692
}
16931693

1694-
void InstrProfiling::emitUses() {
1694+
void InstrLowerer::emitUses() {
16951695
// The metadata sections are parallel arrays. Optimizers (e.g.
16961696
// GlobalOpt/ConstantMerge) may not discard associated sections as a unit, so
16971697
// we conservatively retain all unconditionally in the compiler.
@@ -1713,7 +1713,7 @@ void InstrProfiling::emitUses() {
17131713
appendToUsed(M, UsedVars);
17141714
}
17151715

1716-
void InstrProfiling::emitInitialization() {
1716+
void InstrLowerer::emitInitialization() {
17171717
// Create ProfileFileName variable. Don't don't this for the
17181718
// context-sensitive instrumentation lowering: This lowering is after
17191719
// LTO/ThinLTO linking. Pass PGOInstrumentationGenCreateVar should

0 commit comments

Comments
 (0)