@@ -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
@@ -100,16 +102,16 @@ bool InsertCodePrefetch::runOnMachineFunction(MachineFunction &MF) {
100102 SmallVector<PrefetchHint> PrefetchHints =
101103 getAnalysis<BasicBlockSectionsProfileReaderWrapperPass>()
102104 .getPrefetchHintsForFunction (MF.getName ());
103- DenseMap<UniqueBBID, SmallVector<PrefetchHint>>
104- PrefetchHintsBySiteBBID;
105+ DenseMap<UniqueBBID, SmallVector<PrefetchHint>> PrefetchHintsBySiteBBID;
105106 for (const auto &H : PrefetchHints)
106107 PrefetchHintsBySiteBBID[H.SiteID .BBID ].push_back (H);
107- for (auto &[SiteBBID, H]: PrefetchHintsBySiteBBID) {
108+ for (auto &[SiteBBID, H] : PrefetchHintsBySiteBBID) {
108109 llvm::sort (H, [](const PrefetchHint &H1, const PrefetchHint &H2) {
109110 return H1.SiteID .SubblockIndex < H2.SiteID .SubblockIndex ;
110111 });
111112 }
112- auto PtrTy = PointerType::getUnqual (MF.getFunction ().getParent ()->getContext ());
113+ auto PtrTy =
114+ PointerType::getUnqual (MF.getFunction ().getParent ()->getContext ());
113115 const TargetInstrInfo *TII = MF.getSubtarget ().getInstrInfo ();
114116 for (auto &BB : MF) {
115117 auto It = PrefetchHintsBySiteBBID.find (*BB.getBBID ());
@@ -118,15 +120,21 @@ bool InsertCodePrefetch::runOnMachineFunction(MachineFunction &MF) {
118120 const auto &PrefetchHints = It->second ;
119121 unsigned NumCallsInBB = 0 ;
120122 auto InstrIt = BB.begin ();
121- for (auto HintIt = PrefetchHints.begin () ; HintIt != PrefetchHints.end ();) {
123+ for (auto HintIt = PrefetchHints.begin (); HintIt != PrefetchHints.end ();) {
122124 auto NextInstrIt = InstrIt == BB.end () ? BB.end () : std::next (InstrIt);
123125 while (NumCallsInBB >= HintIt->SiteID .SubblockIndex ) {
124- auto *GV = MF.getFunction ().getParent ()->getOrInsertGlobal (getPrefetchTargetSymbolName (HintIt->TargetFunction , HintIt->TargetID .BBID , HintIt->TargetID .SubblockIndex ), PtrTy);
126+ auto *GV = MF.getFunction ().getParent ()->getOrInsertGlobal (
127+ getPrefetchTargetSymbolName (HintIt->TargetFunction ,
128+ HintIt->TargetID .BBID ,
129+ HintIt->TargetID .SubblockIndex ),
130+ PtrTy);
125131 TII->insertCodePrefetchInstr (BB, NextInstrIt, GV);
126132 ++HintIt;
127133 }
128- if (InstrIt == BB.end ()) break ;
129- if (InstrIt->isCall ()) ++NumCallsInBB;
134+ if (InstrIt == BB.end ())
135+ break ;
136+ if (InstrIt->isCall ())
137+ ++NumCallsInBB;
130138 InstrIt = NextInstrIt;
131139 }
132140 }
0 commit comments