@@ -35,14 +35,16 @@ using namespace llvm;
3535#define DEBUG_TYPE " insert-code-prefetch"
3636
3737namespace llvm {
38- SmallString<128 > getPrefetchTargetSymbolName (StringRef FunctionName, const UniqueBBID &BBID, unsigned SubblockIndex) {
39- SmallString<128 > R (" __llvm_prefetch_target_" );
40- R += FunctionName;
41- R += " _" ;
42- R += utostr (BBID.BaseID );
43- R += " _" ;
44- R += utostr (SubblockIndex);
45- return R;
38+ SmallString<128 > getPrefetchTargetSymbolName (StringRef FunctionName,
39+ const UniqueBBID &BBID,
40+ unsigned SubblockIndex) {
41+ SmallString<128 > R (" __llvm_prefetch_target_" );
42+ R += FunctionName;
43+ R += " _" ;
44+ R += utostr (BBID.BaseID );
45+ R += " _" ;
46+ R += utostr (SubblockIndex);
47+ return R;
4648}
4749} // namespace llvm
4850
@@ -105,16 +107,16 @@ bool InsertCodePrefetch::runOnMachineFunction(MachineFunction &MF) {
105107 SmallVector<PrefetchHint> PrefetchHints =
106108 getAnalysis<BasicBlockSectionsProfileReaderWrapperPass>()
107109 .getPrefetchHintsForFunction (MF.getName ());
108- DenseMap<UniqueBBID, SmallVector<PrefetchHint>>
109- PrefetchHintsBySiteBBID;
110+ DenseMap<UniqueBBID, SmallVector<PrefetchHint>> PrefetchHintsBySiteBBID;
110111 for (const auto &H : PrefetchHints)
111112 PrefetchHintsBySiteBBID[H.SiteID .BBID ].push_back (H);
112- for (auto &[SiteBBID, H]: PrefetchHintsBySiteBBID) {
113+ for (auto &[SiteBBID, H] : PrefetchHintsBySiteBBID) {
113114 llvm::sort (H, [](const PrefetchHint &H1, const PrefetchHint &H2) {
114115 return H1.SiteID .SubblockIndex < H2.SiteID .SubblockIndex ;
115116 });
116117 }
117- auto PtrTy = PointerType::getUnqual (MF.getFunction ().getParent ()->getContext ());
118+ auto PtrTy =
119+ PointerType::getUnqual (MF.getFunction ().getParent ()->getContext ());
118120 const TargetInstrInfo *TII = MF.getSubtarget ().getInstrInfo ();
119121 for (auto &BB : MF) {
120122 auto It = PrefetchHintsBySiteBBID.find (*BB.getBBID ());
@@ -123,15 +125,21 @@ bool InsertCodePrefetch::runOnMachineFunction(MachineFunction &MF) {
123125 const auto &PrefetchHints = It->second ;
124126 unsigned NumCallsInBB = 0 ;
125127 auto InstrIt = BB.begin ();
126- for (auto HintIt = PrefetchHints.begin () ; HintIt != PrefetchHints.end ();) {
128+ for (auto HintIt = PrefetchHints.begin (); HintIt != PrefetchHints.end ();) {
127129 auto NextInstrIt = InstrIt == BB.end () ? BB.end () : std::next (InstrIt);
128130 while (NumCallsInBB >= HintIt->SiteID .SubblockIndex ) {
129- auto *GV = MF.getFunction ().getParent ()->getOrInsertGlobal (getPrefetchTargetSymbolName (HintIt->TargetFunction , HintIt->TargetID .BBID , HintIt->TargetID .SubblockIndex ), PtrTy);
131+ auto *GV = MF.getFunction ().getParent ()->getOrInsertGlobal (
132+ getPrefetchTargetSymbolName (HintIt->TargetFunction ,
133+ HintIt->TargetID .BBID ,
134+ HintIt->TargetID .SubblockIndex ),
135+ PtrTy);
130136 TII->insertCodePrefetchInstr (BB, NextInstrIt, GV);
131137 ++HintIt;
132138 }
133- if (InstrIt == BB.end ()) break ;
134- if (InstrIt->isCall ()) ++NumCallsInBB;
139+ if (InstrIt == BB.end ())
140+ break ;
141+ if (InstrIt->isCall ())
142+ ++NumCallsInBB;
135143 InstrIt = NextInstrIt;
136144 }
137145 }
0 commit comments