Skip to content

Commit 6408bd7

Browse files
committed
Add optimization remarks for when prefetch targets cannot be mapped.
1 parent 3605b0d commit 6408bd7

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2168,6 +2168,14 @@ void AsmPrinter::emitFunctionBody() {
21682168
// If the block ends with a call, we may need to emit a prefetch target
21692169
// at the end.
21702170
EmitPrefetchTargetSymbolIfNeeded();
2171+
if (PrefetchTargetIt != PrefetchTargets.end()) {
2172+
MachineOptimizationRemarkMissed R(
2173+
"insert-code-prefetch", "MissingPrefetchTarget",
2174+
MF->getFunction().getSubprogram(), &MBB);
2175+
R << "failed to map "
2176+
<< ore::NV("NumMissedTargets", PrefetchTargets.end() - PrefetchTargetIt)
2177+
<< " prefetch targets";
2178+
}
21712179

21722180
// We must emit temporary symbol for the end of this basic block, if either
21732181
// we have BBLabels enabled or if this basic blocks marks the end of a

llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ uint64_t BasicBlockSectionsProfileReader::getEdgeCount(
9393
return EdgeIt->second;
9494
}
9595

96-
SmallVector<BBPosition>
96+
SmallVector<SubblockID>
9797
BasicBlockSectionsProfileReader::getPrefetchTargetsForFunction(
9898
StringRef FuncName) const {
9999
return ProgramPathAndClusterInfo.lookup(getAliasName(FuncName))
@@ -332,7 +332,7 @@ Error BasicBlockSectionsProfileReader::ReadV1Profile() {
332332
return createProfileParseError(Twine("unsigned integer expected: '") +
333333
PrefetchTargetStr[1]);
334334
FI->second.PrefetchTargets.push_back(
335-
BBPosition{*TargetBBID, static_cast<unsigned>(TargetCallsiteIndex)});
335+
SubblockID{*TargetBBID, static_cast<unsigned>(TargetCallsiteIndex)});
336336
continue;
337337
}
338338
default:
@@ -541,7 +541,7 @@ uint64_t BasicBlockSectionsProfileReaderWrapperPass::getEdgeCount(
541541
return BBSPR.getEdgeCount(FuncName, SrcBBID, SinkBBID);
542542
}
543543

544-
SmallVector<BBPosition>
544+
SmallVector<SubblockID>
545545
BasicBlockSectionsProfileReaderWrapperPass::getPrefetchTargetsForFunction(
546546
StringRef FuncName) const {
547547
return BBSPR.getPrefetchTargetsForFunction(FuncName);

llvm/lib/CodeGen/InsertCodePrefetch.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ bool InsertCodePrefetch::runOnMachineFunction(MachineFunction &MF) {
7070
return false;
7171
// Set each block's prefetch targets so AsmPrinter can emit a special symbol
7272
// there.
73-
SmallVector<BBPosition> PrefetchTargets =
73+
SmallVector<SubblockID> PrefetchTargets =
7474
getAnalysis<BasicBlockSectionsProfileReaderWrapperPass>()
7575
.getPrefetchTargetsForFunction(MF.getName());
7676
DenseMap<UniqueBBID, SmallVector<unsigned>> PrefetchTargetsByBBID;
7777
for (const auto &Target : PrefetchTargets)
78-
PrefetchTargetsByBBID[Target.BBID].push_back(Target.CallsiteIndex);
78+
PrefetchTargetsByBBID[Target.BBID].push_back(Target.SubblockIndex);
7979
for (auto &MBB : MF) {
8080
auto R = PrefetchTargetsByBBID.find(*MBB.getBBID());
8181
if (R == PrefetchTargetsByBBID.end())

0 commit comments

Comments
 (0)