LLVM: include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef LLVM_TRANSFORMS_UTILS_SAMPLEPROFILELOADERBASEIMPL_H
16#define LLVM_TRANSFORMS_UTILS_SAMPLEPROFILELOADERBASEIMPL_H
17
46
47namespace llvm {
51
52namespace vfs {
53class FileSystem;
54}
55
56#define DEBUG_TYPE "sample-profile-impl"
57
59
77 return &F->getEntryBlock();
78 }
81};
82
83}
84
85
86
87
90
91public:
95 for (const auto *Operand : FuncInfo->operands()) {
98 ->getZExtValue();
100 ->getZExtValue();
102 }
103 }
104 }
105
107 auto I = GUIDToProbeDescMap.find(GUID);
108 return I == GUIDToProbeDescMap.end() ? nullptr : &I->second;
109 }
110
114
119
124
128
131 bool IsAvailableExternallyLinkage =
133
134
135
136
137
138
139
140
141
142
143
144
145 if (IsAvailableExternallyLinkage || )
146 return .hasFnAttribute("profile-checksum-mismatch");
147
149 }
150};
151
152
153
155
157 return F.isDeclaration() || .hasFnAttribute("use-sample-profile");
158}
159
160static inline void
162 std::vector<Function *> &FunctionOrderList) {
169 FunctionOrderList.push_back(&F);
170 }
171 }
172 }
173 std::reverse(FunctionOrderList.begin(), FunctionOrderList.end());
174}
175
177public:
182
184 using BT = std::remove_pointer_t;
204
208 using Edge = std::pair<const BasicBlockT *, const BasicBlockT *>;
212
213protected:
216
229
256 bool
261 void
265
266
267
268
269
271
272
273
274
275
277
278
280
281
283
284
285
286
287
288
289
291
292
296
297
299
300
302
303
305
306
308
309
310
311
313
314
316
317
319
320
322
323
325
326
328
329
331
332
334};
335
336
337template
344 if (ResetDT) {
345 DT = nullptr;
346 PDT = nullptr;
347 LI = nullptr;
348 }
352}
353
354#ifndef NDEBUG
355
356
357
358
359template
361 OS << "weight[" << E.first->getName() << "->" << E.second->getName()
363}
364
365
366
367
368
369template
373 OS << "equivalence[" << BB->getName()
374 << "]: " << ((Equiv) ? EquivalenceClass[BB]->getName() : "NONE") << "\n";
375}
376
377
378
379
380
381template
386 OS << "weight[" << BB->getName() << "]: " << W << "\n";
387}
388#endif
389
390
391
392
393
394
395
396
397
398
399
400
401template
408
409template
413 if ()
414 return std::error_code();
415
416 const DebugLoc &DLoc = Inst.getDebugLoc();
417 if (!DLoc)
418 return std::error_code();
419
424 Discriminator = DIL->getDiscriminator();
425 else
427
429 if (R) {
430 bool FirstMark =
431 CoverageTracker.markSamplesUsed(FS, LineOffset, Discriminator, R.get());
432 if (FirstMark) {
433 ORE->emit([&]() {
435 Remark << "Applied " << ore::NV("NumSamples", *R);
436 Remark << " samples from profile (offset: ";
438 if (Discriminator) {
440 Remark << ore::NV("Discriminator", Discriminator);
441 }
444 });
445 }
447 << Inst << " (line offset: " << LineOffset << "."
448 << Discriminator << " - weight: " << R.get() << ")\n");
449 }
450 return R;
451}
452
453template
457 "Profile is not pseudo probe based");
458 std::optional Probe = extractProbe(Inst);
459
460
461 if (!Probe)
462 return std::error_code();
463
465 if () {
466
467
468
469
470 return std::error_code();
471 }
472
473 auto R = FS->findSamplesAt(Probe->Id, Probe->Discriminator);
474 if (R) {
477 if (FirstMark) {
478 ORE->emit([&]() {
481 Remark << " samples from profile (ProbeId=";
483 if (Probe->Discriminator) {
485 Remark << ore::NV("Discriminator", Probe->Discriminator);
486 }
487 Remark << ", Factor=";
489 Remark << ", OriginalSamples=";
493 });
494 }
496 if (Probe->Discriminator)
497 dbgs() << "." << Probe->Discriminator;
498 dbgs() << ":" << Inst << " - weight: " << R.get()
499 << " - factor: " << format("%0.2f", Probe->Factor) << ")\n";});
501 }
502 return R;
503}
504
505
506
507
508
509
510
511
512
513template
517 bool HasWeight = false;
518 for (auto &I : *BB) {
520 if (R) {
521 Max = std::max(Max, R.get());
522 HasWeight = true;
523 }
524 }
526}
527
528
529
530
531
532
533
534template
538 for (const auto &BB : F) {
540 if (Weight) {
544 }
546 }
547
549}
550
551
552
553
554
555
556
557
558
559
560template
563 const DILocation *DIL = Inst.getDebugLoc();
564 if (!DIL)
566
568 if (it.second) {
569 it.first->second = Samples->findFunctionSamples(DIL, Reader->getRemapper());
570 }
571 return it.first->second;
572}
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597template
603 for (const auto *BB2 : Descendants) {
604 bool IsDomParent = DomTree->dominates(BB2, BB1);
605 bool IsInSameLoop = LI->getLoopFor(BB1) == LI->getLoopFor(BB2);
606 if (BB1 != BB2 && IsDomParent && IsInSameLoop) {
608
611 }
612
613
614
615
616
617
618
619
620
621 Weight = std::max(Weight, BlockWeights[BB2]);
622 }
623 }
625 if (EC == EntryBB) {
627 } else {
629 }
630}
631
632
633
634
635
636
637
638
639
640
641template
644 LLVM_DEBUG(dbgs() << "\nBlock equivalence classes\n");
645
646 for (auto &BB : F) {
648
649
650
651 auto [It, Inserted] = EquivalenceClass.try_emplace(BB1, BB1);
652 if (!Inserted) {
654 continue;
655 }
656
657
658
659
660
661
662
663
664
665
666
667 DominatedBBs.clear();
668 DT->getDescendants(BB1, DominatedBBs);
670
672 }
673
674
675
676
677
678
679
681 dbgs() << "\nAssign the same weight to all blocks in the same class\n");
682 for (auto &BI : F) {
685 if (BB != EquivBB)
688 }
689}
690
691
692
693
694
695
696
697
698
699
700
701template
703 unsigned *NumUnknownEdges,
704 Edge *UnknownEdge) {
706 (*NumUnknownEdges)++;
707 *UnknownEdge = E;
708 return 0;
709 }
710
712}
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727template
729 FunctionT &F, bool UpdateBlockCount) {
731 LLVM_DEBUG(dbgs() << "\nPropagation through edges\n");
732 for (const auto &BI : F) {
735
736
737
738
739
740
741 for (unsigned i = 0; i < 2; i++) {
743 unsigned NumUnknownEdges = 0, NumTotalEdges = 0;
744 Edge UnknownEdge, SelfReferentialEdge, SingleEdge;
745
746 if (i == 0) {
747
749 NumTotalEdges = Preds.size();
750 for (auto *Pred : Preds) {
751 Edge E = std::make_pair(Pred, BB);
752 TotalWeight += visitEdge(E, &NumUnknownEdges, &UnknownEdge);
754 SelfReferentialEdge = E;
755 }
756 if (NumTotalEdges == 1) {
757 SingleEdge = std::make_pair(Predecessors[BB][0], BB);
758 }
759 } else {
760
762 NumTotalEdges = Succs.size();
763 for (auto *Succ : Succs) {
764 Edge E = std::make_pair(BB, Succ);
765 TotalWeight += visitEdge(E, &NumUnknownEdges, &UnknownEdge);
766 }
767 if (NumTotalEdges == 1) {
768 SingleEdge = std::make_pair(BB, Successors[BB][0]);
769 }
770 }
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795 if (NumUnknownEdges <= 1) {
797 if (NumUnknownEdges == 0) {
799
800
801
802 if (TotalWeight > BBWeight) {
803 BBWeight = TotalWeight;
805 LLVM_DEBUG(dbgs() << "All edge weights for " << BB->getName()
806 << " known. Set weight for block: ";
808 }
809 } else if (NumTotalEdges == 1 &&
811
812
815 }
816 } else if (NumUnknownEdges == 1 && VisitedBlocks.count(EC)) {
817
818
819 if (BBWeight >= TotalWeight)
820 EdgeWeights[UnknownEdge] = BBWeight - TotalWeight;
821 else
824 if (i == 0)
826 else
828
836 }
838
839 if (i == 0) {
841 Edge E = std::make_pair(Pred, BB);
844 }
845 } else {
847 Edge E = std::make_pair(BB, Succ);
850 }
851 }
852 } else if (SelfReferentialEdge.first && VisitedBlocks.count(EC)) {
854
855 if (BBWeight >= TotalWeight)
856 EdgeWeights[SelfReferentialEdge] = BBWeight - TotalWeight;
857 else
861 LLVM_DEBUG(dbgs() << "Set self-referential edge weight to: ";
863 }
864 if (UpdateBlockCount && TotalWeight > 0 &&
868 }
869 }
870 }
871
873}
874
875
876
877
878
879template
881 for (auto &BI : F) {
883
884
887 if (!Preds.empty())
888 llvm_unreachable("Found a stale predecessors list in a basic block.");
890 if (Visited.insert(B2).second)
891 Preds.push_back(B2);
892
893
896 if (!Succs.empty())
897 llvm_unreachable("Found a stale successors list in a basic block.");
899 if (Visited.insert(B2).second)
900 Succs.push_back(B2);
901 }
902}
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921template
923
924
926
928 for (const auto &BI : F) {
930 if (Weight)
931 SampleBlockWeights[&BI] = Weight.get();
932 }
933
935 } else {
937 unsigned I = 0;
938
939
940
941 for (auto &BI : F) {
943 LoopT *L = LI->getLoopFor(BB);
944 if (!L) {
945 continue;
946 }
950 }
951 }
952
953
956 }
957
958
959
960
965 }
966
967
968
972 }
973 }
974}
975
976template
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030template
1033 bool Changed = (InlinedGUIDs.size() != 0);
1034
1035
1037
1039
1041
1042
1044
1045
1047 }
1048
1050}
1051
1052template
1055
1056
1057
1058
1059
1062 &InlinedGUIDs);
1063
1065
1067
1068
1070 }
1071
1072
1073
1074
1075
1076
1078}
1079
1080template
1083
1084
1085
1086
1087
1088
1095 &InlinedGUIDs);
1096 }
1097 }
1098}
1099
1100template
1102
1111 Twine(Used) + " of " + Twine(Total) + " available profile records (" +
1112 Twine(Coverage) + "%) were applied",
1114 }
1115 }
1116
1124 Twine(Used) + " of " + Twine(Total) + " available profile samples (" +
1125 Twine(Coverage) + "%) were applied",
1127 }
1128 }
1129}
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142template
1146 return S->getLine();
1147
1149 return 0;
1150
1151
1152
1154 "No debug information found in function " + Func.getName() +
1155 ": Function profile not used",
1157 return 0;
1158}
1159
1160#undef DEBUG_TYPE
1161
1162}
1163#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
This file defines a set of templates that efficiently compute a dominator tree over a generic graph.
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
Module.h This file contains the declarations for the Module class.
This file defines the RefCountedBase, ThreadSafeRefCountedBase, and IntrusiveRefCntPtr classes.
Implements a lazy call graph analysis and related passes for the new pass manager.
This file provides the interface for the profile inference algorithm, profi.
This file provides the utility functions for the sampled PGO loader base implementation.
This file defines the SmallPtrSet class.
This file defines the SmallSet class.
This file defines the SmallVector class.
static Function * getFunction(FunctionType *Ty, const Twine &Name, Module *M)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
unsigned getBaseDiscriminator() const
Returns the base discriminator stored in the discriminator.
Subprogram description. Uses SubclassData1.
LLVM_ABI unsigned getLine() const
Implements a dense probed hash-table based set.
Diagnostic information for the sample profiler.
Represents either an error or a value T.
Class to represent profile counts.
void setEntryCount(ProfileCount Count, const DenseSet< GlobalValue::GUID > *Imports=nullptr)
Set the entry count for this function.
static LLVM_ABI GUID getGUIDAssumingExternalLinkage(StringRef GlobalName)
Return a 64-bit global unique ID constructed from the name of a global symbol.
static bool isAvailableExternallyLinkage(LinkageTypes Linkage)
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
A node in the call graph.
A RefSCC of the call graph.
An SCC of the call graph.
A lazily constructed view of the call graph of a module.
LLVM_ABI void buildRefSCCs()
iterator_range< postorder_ref_scc_iterator > postorder_ref_sccs()
Represents a single loop in the control flow graph.
A Module instance is used to store all the information related to an LLVM module.
PostDominatorTree Class - Concrete subclass of DominatorTree that is used to compute the post-dominat...
Analysis providing profile information.
uint64_t getFunctionHash() const
const PseudoProbeDescriptor * getDesc(StringRef FProfileName) const
Definition SampleProfileLoaderBaseImpl.h:111
bool profileIsHashMismatched(const PseudoProbeDescriptor &FuncDesc, const FunctionSamples &Samples) const
Definition SampleProfileLoaderBaseImpl.h:120
const PseudoProbeDescriptor * getDesc(const Function &F) const
Definition SampleProfileLoaderBaseImpl.h:115
bool moduleIsProbed(const Module &M) const
Definition SampleProfileLoaderBaseImpl.h:125
bool profileIsValid(const Function &F, const FunctionSamples &Samples) const
Definition SampleProfileLoaderBaseImpl.h:129
PseudoProbeManager(const Module &M)
Definition SampleProfileLoaderBaseImpl.h:92
const PseudoProbeDescriptor * getDesc(uint64_t GUID) const
Definition SampleProfileLoaderBaseImpl.h:106
Sample profile inference pass.
bool computeAndPropagateWeights(FunctionT &F, const DenseSet< GlobalValue::GUID > &InlinedGUIDs)
Generate branch weight metadata for all branches in F.
Definition SampleProfileLoaderBaseImpl.h:1031
void computeDominanceAndLoopInfo(FunctionT &F)
typename afdo_detail::IRTraits< BT >::BasicBlockT BasicBlockT
Definition SampleProfileLoaderBaseImpl.h:186
IntrusiveRefCntPtr< vfs::FileSystem > FS
VirtualFileSystem to load profile files from.
Definition SampleProfileLoaderBaseImpl.h:327
void dump()
Definition SampleProfileLoaderBaseImpl.h:181
typename afdo_detail::IRTraits< BT >::SuccRangeT SuccRangeT
Definition SampleProfileLoaderBaseImpl.h:203
DenseMap< const BasicBlockT *, uint64_t > BlockWeightMap
Definition SampleProfileLoaderBaseImpl.h:205
EdgeWeightMap EdgeWeights
Definition SampleProfileLoaderBaseImpl.h:276
Function & getFunction(FunctionT &F)
Definition SampleProfileLoaderBaseImpl.h:217
SmallSet< Edge, 32 > VisitedEdges
Set of visited edges during propagation.
Definition SampleProfileLoaderBaseImpl.h:282
std::map< SampleContext, FunctionSamples > OutlineFunctionSamples
Synthetic samples created by duplicating the samples of inlined functions from the original profile a...
Definition SampleProfileLoaderBaseImpl.h:312
OptRemarkEmitterT * ORE
Optimization Remark Emitter used to emit diagnostic remarks.
Definition SampleProfileLoaderBaseImpl.h:333
const BasicBlockT * getEntryBB(const FunctionT *F)
Definition SampleProfileLoaderBaseImpl.h:220
ErrorOr< uint64_t > getBlockWeight(const BasicBlockT *BB)
Compute the weight of a basic block.
Definition SampleProfileLoaderBaseImpl.h:515
unsigned getFunctionLoc(FunctionT &Func)
Get the line number for the function header.
Definition SampleProfileLoaderBaseImpl.h:1143
PredRangeT getPredecessors(BasicBlockT *BB)
Definition SampleProfileLoaderBaseImpl.h:223
ErrorOr< uint64_t > getInstWeightImpl(const InstructionT &Inst)
Definition SampleProfileLoaderBaseImpl.h:411
virtual ErrorOr< uint64_t > getInstWeight(const InstructionT &Inst)
Get the weight for an instruction.
Definition SampleProfileLoaderBaseImpl.h:403
SmallPtrSet< const BasicBlockT *, 32 > VisitedBlocks
Set of visited blocks during propagation.
Definition SampleProfileLoaderBaseImpl.h:279
EquivalenceClassMap EquivalenceClass
Equivalence classes for block weights.
Definition SampleProfileLoaderBaseImpl.h:290
typename afdo_detail::IRTraits< BT >::PostDominatorTreePtrT PostDominatorTreePtrT
Definition SampleProfileLoaderBaseImpl.h:194
SampleCoverageTracker CoverageTracker
Profile coverage tracker.
Definition SampleProfileLoaderBaseImpl.h:304
typename afdo_detail::IRTraits< BT >::LoopT LoopT
Definition SampleProfileLoaderBaseImpl.h:190
typename GraphTraits< FT * >::NodeRef NodeRef
Definition SampleProfileLoaderBaseImpl.h:183
std::unique_ptr< SampleProfileReader > Reader
Profile reader object.
Definition SampleProfileLoaderBaseImpl.h:307
void printBlockWeight(raw_ostream &OS, const BasicBlockT *BB) const
Print the weight of block BB on stream OS.
Definition SampleProfileLoaderBaseImpl.h:382
DominatorTreePtrT DT
Dominance, post-dominance and loop information.
Definition SampleProfileLoaderBaseImpl.h:293
void printBlockEquivalence(raw_ostream &OS, const BasicBlockT *BB)
Print the equivalence class of block BB on stream OS.
Definition SampleProfileLoaderBaseImpl.h:370
DenseMap< const BasicBlockT *, SmallVector< const BasicBlockT *, 8 > > BlockEdgeMap
Definition SampleProfileLoaderBaseImpl.h:210
std::remove_pointer_t< NodeRef > BT
Definition SampleProfileLoaderBaseImpl.h:184
SampleProfileLoaderBaseImpl(std::string Name, std::string RemapName, IntrusiveRefCntPtr< vfs::FileSystem > FS)
Definition SampleProfileLoaderBaseImpl.h:178
std::unique_ptr< PseudoProbeManager > ProbeManager
Definition SampleProfileLoaderBaseImpl.h:315
typename afdo_detail::IRTraits< BT >::OptRemarkAnalysisT OptRemarkAnalysisT
Definition SampleProfileLoaderBaseImpl.h:200
~SampleProfileLoaderBaseImpl()=default
DenseMap< Edge, uint64_t > EdgeWeightMap
Definition SampleProfileLoaderBaseImpl.h:209
typename afdo_detail::IRTraits< BT >::DominatorTreePtrT DominatorTreePtrT
Definition SampleProfileLoaderBaseImpl.h:192
typename afdo_detail::IRTraits< BT >::LoopInfoPtrT LoopInfoPtrT
Definition SampleProfileLoaderBaseImpl.h:191
void emitCoverageRemarks(FunctionT &F)
Definition SampleProfileLoaderBaseImpl.h:1101
SuccRangeT getSuccessors(BasicBlockT *BB)
Definition SampleProfileLoaderBaseImpl.h:226
std::string Filename
Name of the profile file to load.
Definition SampleProfileLoaderBaseImpl.h:321
bool propagateThroughEdges(FunctionT &F, bool UpdateBlockCount)
Propagate weights through incoming/outgoing edges.
Definition SampleProfileLoaderBaseImpl.h:728
PostDominatorTreePtrT PDT
Definition SampleProfileLoaderBaseImpl.h:294
typename afdo_detail::IRTraits< BT >::InstructionT InstructionT
Definition SampleProfileLoaderBaseImpl.h:185
uint64_t visitEdge(Edge E, unsigned *NumUnknownEdges, Edge *UnknownEdge)
Visit the given edge to decide if it has a valid weight.
Definition SampleProfileLoaderBaseImpl.h:702
void initWeightPropagation(FunctionT &F, const DenseSet< GlobalValue::GUID > &InlinedGUIDs)
Definition SampleProfileLoaderBaseImpl.h:1053
BlockEdgeMap Predecessors
Predecessors for each basic block in the CFG.
Definition SampleProfileLoaderBaseImpl.h:298
void finalizeWeightPropagation(FunctionT &F, const DenseSet< GlobalValue::GUID > &InlinedGUIDs)
Definition SampleProfileLoaderBaseImpl.h:1081
typename afdo_detail::IRTraits< BT >::BlockFrequencyInfoT BlockFrequencyInfoT
Definition SampleProfileLoaderBaseImpl.h:187
bool computeBlockWeights(FunctionT &F)
Compute and store the weights of every basic block.
Definition SampleProfileLoaderBaseImpl.h:535
virtual const FunctionSamples * findFunctionSamples(const InstructionT &I) const
Get the FunctionSamples for an instruction.
Definition SampleProfileLoaderBaseImpl.h:561
friend class SampleCoverageTracker
Definition SampleProfileLoaderBaseImpl.h:215
DenseMap< const BasicBlockT *, const BasicBlockT * > EquivalenceClassMap
Definition SampleProfileLoaderBaseImpl.h:206
typename afdo_detail::IRTraits< BT >::PostDominatorTreeT PostDominatorTreeT
Definition SampleProfileLoaderBaseImpl.h:196
virtual ErrorOr< uint64_t > getProbeWeight(const InstructionT &Inst)
Definition SampleProfileLoaderBaseImpl.h:455
std::string RemappingFilename
Name of the profile remapping file to load.
Definition SampleProfileLoaderBaseImpl.h:324
typename afdo_detail::IRTraits< BT >::PredRangeT PredRangeT
Definition SampleProfileLoaderBaseImpl.h:202
void applyProfi(FunctionT &F, BlockEdgeMap &Successors, BlockWeightMap &SampleBlockWeights, BlockWeightMap &BlockWeights, EdgeWeightMap &EdgeWeights)
Definition SampleProfileLoaderBaseImpl.h:977
BlockEdgeMap Successors
Definition SampleProfileLoaderBaseImpl.h:301
FunctionSamples * Samples
Samples collected for the body of this function.
Definition SampleProfileLoaderBaseImpl.h:318
void findEquivalenceClasses(FunctionT &F)
Find equivalence classes.
Definition SampleProfileLoaderBaseImpl.h:642
std::pair< const BasicBlockT *, const BasicBlockT * > Edge
Definition SampleProfileLoaderBaseImpl.h:208
ProfileSummaryInfo * PSI
Profile Summary Info computed from sample profile.
Definition SampleProfileLoaderBaseImpl.h:330
LoopInfoPtrT LI
Definition SampleProfileLoaderBaseImpl.h:295
typename afdo_detail::IRTraits< BT >::OptRemarkEmitterT OptRemarkEmitterT
Definition SampleProfileLoaderBaseImpl.h:198
void clearFunctionData(bool ResetDT=true)
Clear all the per-function data used to load samples and propagate weights.
Definition SampleProfileLoaderBaseImpl.h:338
DenseMap< const DILocation *, const FunctionSamples * > DILocation2SampleMap
Definition SampleProfileLoaderBaseImpl.h:236
void buildEdges(FunctionT &F)
Build in/out edge lists for each basic block in the CFG.
Definition SampleProfileLoaderBaseImpl.h:880
void findEquivalencesFor(BasicBlockT *BB1, ArrayRef< BasicBlockT * > Descendants, PostDominatorTreeT *DomTree)
Find equivalence classes for the given block.
Definition SampleProfileLoaderBaseImpl.h:598
void printEdgeWeight(raw_ostream &OS, Edge E)
Print the weight of edge E on stream OS.
Definition SampleProfileLoaderBaseImpl.h:360
typename afdo_detail::IRTraits< BT >::FunctionT FunctionT
Definition SampleProfileLoaderBaseImpl.h:189
BlockWeightMap BlockWeights
Definition SampleProfileLoaderBaseImpl.h:270
void propagateWeights(FunctionT &F)
Propagate weights into edges.
Definition SampleProfileLoaderBaseImpl.h:922
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
This class implements an extremely fast bulk output stream that can only output to a stream.
Representation of the samples collected for a function.
uint64_t getFunctionHash() const
static LLVM_ABI bool ProfileIsProbeBased
static StringRef getCanonicalFnName(const Function &F)
Return the canonical name for a function, taking into account suffix elision policy attributes.
static LLVM_ABI unsigned getOffset(const DILocation *DIL)
Returns the line offset to the start line of the subprogram.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
template class LLVM_TEMPLATE_ABI opt< bool >
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > dyn_extract(Y &&MD)
Extract a Value from Metadata, if any.
DiagnosticInfoOptimizationBase::Argument NV
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< pred_iterator > pred_range
iterator_range< succ_iterator > succ_range
auto successors(const MachineBasicBlock *BB)
LLVM_ABI cl::opt< bool > EnableFSDiscriminator
cl::opt< unsigned > SampleProfileSampleCoverage
static void buildTopDownFuncOrder(LazyCallGraph &CG, std::vector< Function * > &FunctionOrderList)
Definition SampleProfileLoaderBaseImpl.h:161
cl::opt< unsigned > SampleProfileRecordCoverage
cl::opt< unsigned > SampleProfileMaxPropagateIterations
cl::opt< bool > SampleProfileUseProfi
LLVM_ABI std::optional< PseudoProbe > extractProbe(const Instruction &Inst)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Function::ProfileCount ProfileCount
Definition SampleProfileLoaderBaseImpl.h:50
cl::opt< bool > NoWarnSampleUnused
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
decltype(auto) cast(const From &Val)
cast - Return the argument parameter cast to the specified type.
static bool skipProfileForFunction(const Function &F)
Definition SampleProfileLoaderBaseImpl.h:156
auto predecessors(const MachineBasicBlock *BB)
constexpr const char * PseudoProbeDescMetadataName
Implement std::hash so that hash_code can be used in STL containers.
typename GraphType::UnknownGraphTypeError NodeRef
Function FunctionT
Definition SampleProfileLoaderBaseImpl.h:64
BasicBlock BasicBlockT
Definition SampleProfileLoaderBaseImpl.h:63
OptimizationRemarkEmitter OptRemarkEmitterT
Definition SampleProfileLoaderBaseImpl.h:71
pred_range PredRangeT
Definition SampleProfileLoaderBaseImpl.h:73
Loop LoopT
Definition SampleProfileLoaderBaseImpl.h:66
std::unique_ptr< LoopInfo > LoopInfoPtrT
Definition SampleProfileLoaderBaseImpl.h:67
std::unique_ptr< PostDominatorTree > PostDominatorTreePtrT
Definition SampleProfileLoaderBaseImpl.h:70
static Function & getFunction(Function &F)
Definition SampleProfileLoaderBaseImpl.h:75
succ_range SuccRangeT
Definition SampleProfileLoaderBaseImpl.h:74
static pred_range getPredecessors(BasicBlock *BB)
Definition SampleProfileLoaderBaseImpl.h:79
static succ_range getSuccessors(BasicBlock *BB)
Definition SampleProfileLoaderBaseImpl.h:80
PostDominatorTree PostDominatorTreeT
Definition SampleProfileLoaderBaseImpl.h:69
BlockFrequencyInfo BlockFrequencyInfoT
Definition SampleProfileLoaderBaseImpl.h:65
OptimizationRemarkAnalysis OptRemarkAnalysisT
Definition SampleProfileLoaderBaseImpl.h:72
std::unique_ptr< DominatorTree > DominatorTreePtrT
Definition SampleProfileLoaderBaseImpl.h:68
Instruction InstructionT
Definition SampleProfileLoaderBaseImpl.h:62
static const BasicBlock * getEntryBB(const Function *F)
Definition SampleProfileLoaderBaseImpl.h:76