@@ -154,11 +154,11 @@ cl::opt<bool> SkipRetExitBlock(
154
154
155
155
using LoadStorePair = std::pair<Instruction *, Instruction *>;
156
156
157
- class InstrProfiling final {
157
+ class InstrLowerer final {
158
158
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)
162
162
: M(M), Options(Options), TT(Triple(M.getTargetTriple())), IsCS(IsCS),
163
163
GetTLI (GetTLI) {}
164
164
@@ -563,14 +563,14 @@ PreservedAnalyses InstrProfilingLoweringPass::run(Module &M,
563
563
auto GetTLI = [&FAM](Function &F) -> TargetLibraryInfo & {
564
564
return FAM.getResult <TargetLibraryAnalysis>(F);
565
565
};
566
- InstrProfiling Lowerer (M, Options, GetTLI, IsCS);
566
+ InstrLowerer Lowerer (M, Options, GetTLI, IsCS);
567
567
if (!Lowerer.lower ())
568
568
return PreservedAnalyses::all ();
569
569
570
570
return PreservedAnalyses::none ();
571
571
}
572
572
573
- bool InstrProfiling ::lowerIntrinsics (Function *F) {
573
+ bool InstrLowerer ::lowerIntrinsics (Function *F) {
574
574
bool MadeChange = false ;
575
575
PromotionCandidates.clear ();
576
576
for (BasicBlock &BB : *F) {
@@ -610,7 +610,7 @@ bool InstrProfiling::lowerIntrinsics(Function *F) {
610
610
return true ;
611
611
}
612
612
613
- bool InstrProfiling ::isRuntimeCounterRelocationEnabled () const {
613
+ bool InstrLowerer ::isRuntimeCounterRelocationEnabled () const {
614
614
// Mach-O don't support weak external references.
615
615
if (TT.isOSBinFormatMachO ())
616
616
return false ;
@@ -622,14 +622,14 @@ bool InstrProfiling::isRuntimeCounterRelocationEnabled() const {
622
622
return TT.isOSFuchsia ();
623
623
}
624
624
625
- bool InstrProfiling ::isCounterPromotionEnabled () const {
625
+ bool InstrLowerer ::isCounterPromotionEnabled () const {
626
626
if (DoCounterPromotion.getNumOccurrences () > 0 )
627
627
return DoCounterPromotion;
628
628
629
629
return Options.DoCounterPromotion ;
630
630
}
631
631
632
- void InstrProfiling ::promoteCounterLoadStores (Function *F) {
632
+ void InstrLowerer ::promoteCounterLoadStores (Function *F) {
633
633
if (!isCounterPromotionEnabled ())
634
634
return ;
635
635
@@ -686,7 +686,7 @@ static bool containsProfilingIntrinsics(Module &M) {
686
686
containsIntrinsic (llvm::Intrinsic::instrprof_value_profile);
687
687
}
688
688
689
- bool InstrProfiling ::lower () {
689
+ bool InstrLowerer ::lower () {
690
690
bool MadeChange = false ;
691
691
bool NeedsRuntimeHook = needsRuntimeHookUnconditionally (TT);
692
692
if (NeedsRuntimeHook)
@@ -778,7 +778,7 @@ static FunctionCallee getOrInsertValueProfilingCall(
778
778
return M.getOrInsertFunction (FuncName, ValueProfilingCallTy, AL);
779
779
}
780
780
781
- void InstrProfiling ::computeNumValueSiteCounts (InstrProfValueProfileInst *Ind) {
781
+ void InstrLowerer ::computeNumValueSiteCounts (InstrProfValueProfileInst *Ind) {
782
782
GlobalVariable *Name = Ind->getName ();
783
783
uint64_t ValueKind = Ind->getValueKind ()->getZExtValue ();
784
784
uint64_t Index = Ind->getIndex ()->getZExtValue ();
@@ -787,7 +787,7 @@ void InstrProfiling::computeNumValueSiteCounts(InstrProfValueProfileInst *Ind) {
787
787
std::max (PD.NumValueSites [ValueKind], (uint32_t )(Index + 1 ));
788
788
}
789
789
790
- void InstrProfiling ::lowerValueProfileInst (InstrProfValueProfileInst *Ind) {
790
+ void InstrLowerer ::lowerValueProfileInst (InstrProfValueProfileInst *Ind) {
791
791
// TODO: Value profiling heavily depends on the data section which is omitted
792
792
// in lightweight mode. We need to move the value profile pointer to the
793
793
// Counter struct to get this working.
@@ -833,7 +833,7 @@ void InstrProfiling::lowerValueProfileInst(InstrProfValueProfileInst *Ind) {
833
833
Ind->eraseFromParent ();
834
834
}
835
835
836
- Value *InstrProfiling ::getCounterAddress (InstrProfCntrInstBase *I) {
836
+ Value *InstrLowerer ::getCounterAddress (InstrProfCntrInstBase *I) {
837
837
auto *Counters = getOrCreateRegionCounters (I);
838
838
IRBuilder<> Builder (I);
839
839
@@ -873,7 +873,7 @@ Value *InstrProfiling::getCounterAddress(InstrProfCntrInstBase *I) {
873
873
return Builder.CreateIntToPtr (Add, Addr->getType ());
874
874
}
875
875
876
- Value *InstrProfiling ::getBitmapAddress (InstrProfMCDCTVBitmapUpdate *I) {
876
+ Value *InstrLowerer ::getBitmapAddress (InstrProfMCDCTVBitmapUpdate *I) {
877
877
auto *Bitmaps = getOrCreateRegionBitmaps (I);
878
878
IRBuilder<> Builder (I);
879
879
@@ -892,15 +892,15 @@ Value *InstrProfiling::getBitmapAddress(InstrProfMCDCTVBitmapUpdate *I) {
892
892
return Addr;
893
893
}
894
894
895
- void InstrProfiling ::lowerCover (InstrProfCoverInst *CoverInstruction) {
895
+ void InstrLowerer ::lowerCover (InstrProfCoverInst *CoverInstruction) {
896
896
auto *Addr = getCounterAddress (CoverInstruction);
897
897
IRBuilder<> Builder (CoverInstruction);
898
898
// We store zero to represent that this block is covered.
899
899
Builder.CreateStore (Builder.getInt8 (0 ), Addr);
900
900
CoverInstruction->eraseFromParent ();
901
901
}
902
902
903
- void InstrProfiling ::lowerTimestamp (
903
+ void InstrLowerer ::lowerTimestamp (
904
904
InstrProfTimestampInst *TimestampInstruction) {
905
905
assert (TimestampInstruction->getIndex ()->isZeroValue () &&
906
906
" timestamp probes are always the first probe for a function" );
@@ -915,7 +915,7 @@ void InstrProfiling::lowerTimestamp(
915
915
TimestampInstruction->eraseFromParent ();
916
916
}
917
917
918
- void InstrProfiling ::lowerIncrement (InstrProfIncrementInst *Inc) {
918
+ void InstrLowerer ::lowerIncrement (InstrProfIncrementInst *Inc) {
919
919
auto *Addr = getCounterAddress (Inc);
920
920
921
921
IRBuilder<> Builder (Inc);
@@ -934,7 +934,7 @@ void InstrProfiling::lowerIncrement(InstrProfIncrementInst *Inc) {
934
934
Inc->eraseFromParent ();
935
935
}
936
936
937
- void InstrProfiling ::lowerCoverageData (GlobalVariable *CoverageNamesVar) {
937
+ void InstrLowerer ::lowerCoverageData (GlobalVariable *CoverageNamesVar) {
938
938
ConstantArray *Names =
939
939
cast<ConstantArray>(CoverageNamesVar->getInitializer ());
940
940
for (unsigned I = 0 , E = Names->getNumOperands (); I < E; ++I) {
@@ -951,7 +951,7 @@ void InstrProfiling::lowerCoverageData(GlobalVariable *CoverageNamesVar) {
951
951
CoverageNamesVar->eraseFromParent ();
952
952
}
953
953
954
- void InstrProfiling ::lowerMCDCTestVectorBitmapUpdate (
954
+ void InstrLowerer ::lowerMCDCTestVectorBitmapUpdate (
955
955
InstrProfMCDCTVBitmapUpdate *Update) {
956
956
IRBuilder<> Builder (Update);
957
957
auto *Int8Ty = Type::getInt8Ty (M.getContext ());
@@ -1003,7 +1003,7 @@ void InstrProfiling::lowerMCDCTestVectorBitmapUpdate(
1003
1003
Update->eraseFromParent ();
1004
1004
}
1005
1005
1006
- void InstrProfiling ::lowerMCDCCondBitmapUpdate (
1006
+ void InstrLowerer ::lowerMCDCCondBitmapUpdate (
1007
1007
InstrProfMCDCCondBitmapUpdate *Update) {
1008
1008
IRBuilder<> Builder (Update);
1009
1009
auto *Int32Ty = Type::getInt32Ty (M.getContext ());
@@ -1186,8 +1186,8 @@ static bool needsRuntimeRegistrationOfSectionRange(const Triple &TT) {
1186
1186
return true ;
1187
1187
}
1188
1188
1189
- void InstrProfiling ::maybeSetComdat (GlobalVariable *GV, Function *Fn,
1190
- StringRef VarName) {
1189
+ void InstrLowerer ::maybeSetComdat (GlobalVariable *GV, Function *Fn,
1190
+ StringRef VarName) {
1191
1191
bool DataReferencedByCode = profDataReferencedByCode (M);
1192
1192
bool NeedComdat = needsComdatForCounter (*Fn, M);
1193
1193
bool UseComdat = (NeedComdat || TT.isOSBinFormatELF ());
@@ -1208,8 +1208,8 @@ void InstrProfiling::maybeSetComdat(GlobalVariable *GV, Function *Fn,
1208
1208
GV->setLinkage (GlobalValue::InternalLinkage);
1209
1209
}
1210
1210
1211
- GlobalVariable *InstrProfiling ::setupProfileSection (InstrProfInstBase *Inc,
1212
- InstrProfSectKind IPSK) {
1211
+ GlobalVariable *InstrLowerer ::setupProfileSection (InstrProfInstBase *Inc,
1212
+ InstrProfSectKind IPSK) {
1213
1213
GlobalVariable *NamePtr = Inc->getName ();
1214
1214
1215
1215
// Match the linkage and visibility of the name global.
@@ -1278,9 +1278,9 @@ GlobalVariable *InstrProfiling::setupProfileSection(InstrProfInstBase *Inc,
1278
1278
}
1279
1279
1280
1280
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) {
1284
1284
uint64_t NumBytes = Inc->getNumBitmapBytes ()->getZExtValue ();
1285
1285
auto *BitmapTy = ArrayType::get (Type::getInt8Ty (M.getContext ()), NumBytes);
1286
1286
auto GV = new GlobalVariable (M, BitmapTy, false , Linkage,
@@ -1290,7 +1290,7 @@ InstrProfiling::createRegionBitmaps(InstrProfMCDCBitmapInstBase *Inc,
1290
1290
}
1291
1291
1292
1292
GlobalVariable *
1293
- InstrProfiling ::getOrCreateRegionBitmaps (InstrProfMCDCBitmapInstBase *Inc) {
1293
+ InstrLowerer ::getOrCreateRegionBitmaps (InstrProfMCDCBitmapInstBase *Inc) {
1294
1294
GlobalVariable *NamePtr = Inc->getName ();
1295
1295
auto &PD = ProfileDataMap[NamePtr];
1296
1296
if (PD.RegionBitmaps )
@@ -1305,8 +1305,8 @@ InstrProfiling::getOrCreateRegionBitmaps(InstrProfMCDCBitmapInstBase *Inc) {
1305
1305
}
1306
1306
1307
1307
GlobalVariable *
1308
- InstrProfiling ::createRegionCounters (InstrProfCntrInstBase *Inc, StringRef Name,
1309
- GlobalValue::LinkageTypes Linkage) {
1308
+ InstrLowerer ::createRegionCounters (InstrProfCntrInstBase *Inc, StringRef Name,
1309
+ GlobalValue::LinkageTypes Linkage) {
1310
1310
uint64_t NumCounters = Inc->getNumCounters ()->getZExtValue ();
1311
1311
auto &Ctx = M.getContext ();
1312
1312
GlobalVariable *GV;
@@ -1330,7 +1330,7 @@ InstrProfiling::createRegionCounters(InstrProfCntrInstBase *Inc, StringRef Name,
1330
1330
}
1331
1331
1332
1332
GlobalVariable *
1333
- InstrProfiling ::getOrCreateRegionCounters (InstrProfCntrInstBase *Inc) {
1333
+ InstrLowerer ::getOrCreateRegionCounters (InstrProfCntrInstBase *Inc) {
1334
1334
GlobalVariable *NamePtr = Inc->getName ();
1335
1335
auto &PD = ProfileDataMap[NamePtr];
1336
1336
if (PD.RegionCounters )
@@ -1383,7 +1383,7 @@ InstrProfiling::getOrCreateRegionCounters(InstrProfCntrInstBase *Inc) {
1383
1383
return PD.RegionCounters ;
1384
1384
}
1385
1385
1386
- void InstrProfiling ::createDataVariable (InstrProfCntrInstBase *Inc) {
1386
+ void InstrLowerer ::createDataVariable (InstrProfCntrInstBase *Inc) {
1387
1387
// When debug information is correlated to profile data, a data variable
1388
1388
// is not needed.
1389
1389
if (DebugInfoCorrelate)
@@ -1523,7 +1523,7 @@ void InstrProfiling::createDataVariable(InstrProfCntrInstBase *Inc) {
1523
1523
ReferencedNames.push_back (NamePtr);
1524
1524
}
1525
1525
1526
- void InstrProfiling ::emitVNodes () {
1526
+ void InstrLowerer ::emitVNodes () {
1527
1527
if (!ValueProfileStaticAlloc)
1528
1528
return ;
1529
1529
@@ -1574,7 +1574,7 @@ void InstrProfiling::emitVNodes() {
1574
1574
UsedVars.push_back (VNodesVar);
1575
1575
}
1576
1576
1577
- void InstrProfiling ::emitNameData () {
1577
+ void InstrLowerer ::emitNameData () {
1578
1578
std::string UncompressedData;
1579
1579
1580
1580
if (ReferencedNames.empty ())
@@ -1608,7 +1608,7 @@ void InstrProfiling::emitNameData() {
1608
1608
NamePtr->eraseFromParent ();
1609
1609
}
1610
1610
1611
- void InstrProfiling ::emitRegistration () {
1611
+ void InstrLowerer ::emitRegistration () {
1612
1612
if (!needsRuntimeRegistrationOfSectionRange (TT))
1613
1613
return ;
1614
1614
@@ -1649,7 +1649,7 @@ void InstrProfiling::emitRegistration() {
1649
1649
IRB.CreateRetVoid ();
1650
1650
}
1651
1651
1652
- bool InstrProfiling ::emitRuntimeHook () {
1652
+ bool InstrLowerer ::emitRuntimeHook () {
1653
1653
// We expect the linker to be invoked with -u<hook_var> flag for Linux
1654
1654
// in which case there is no need to emit the external variable.
1655
1655
if (TT.isOSLinux () || TT.isOSAIX ())
@@ -1691,7 +1691,7 @@ bool InstrProfiling::emitRuntimeHook() {
1691
1691
return true ;
1692
1692
}
1693
1693
1694
- void InstrProfiling ::emitUses () {
1694
+ void InstrLowerer ::emitUses () {
1695
1695
// The metadata sections are parallel arrays. Optimizers (e.g.
1696
1696
// GlobalOpt/ConstantMerge) may not discard associated sections as a unit, so
1697
1697
// we conservatively retain all unconditionally in the compiler.
@@ -1713,7 +1713,7 @@ void InstrProfiling::emitUses() {
1713
1713
appendToUsed (M, UsedVars);
1714
1714
}
1715
1715
1716
- void InstrProfiling ::emitInitialization () {
1716
+ void InstrLowerer ::emitInitialization () {
1717
1717
// Create ProfileFileName variable. Don't don't this for the
1718
1718
// context-sensitive instrumentation lowering: This lowering is after
1719
1719
// LTO/ThinLTO linking. Pass PGOInstrumentationGenCreateVar should
0 commit comments