[PATCH] D120295: [SampleProfile] [ICP] Handle the case when the option `MaxNumPromotions` is zero.
Mingming Liu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 22 21:45:04 PST 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf415d74d1df3: [SampleProfile] Handle the case when the option `MaxNumPromotions` is zero. (authored by luna).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120295/new/
https://reviews.llvm.org/D120295
Files:
llvm/lib/Transforms/IPO/SampleProfile.cpp
Index: llvm/lib/Transforms/IPO/SampleProfile.cpp
===================================================================
--- llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -841,6 +841,13 @@
updateIDTMetaData(Instruction &Inst,
const SmallVectorImpl<InstrProfValueData> &CallTargets,
uint64_t Sum) {
+ // Bail out early if MaxNumPromotions is zero.
+ // This prevents allocating an array of zero length below.
+ //
+ // Note `updateIDTMetaData` is called in two places so check
+ // `MaxNumPromotions` inside it.
+ if (MaxNumPromotions == 0)
+ return;
uint32_t NumVals = 0;
// OldSum is the existing total count in the value profile data.
uint64_t OldSum = 0;
@@ -924,6 +931,10 @@
bool SampleProfileLoader::tryPromoteAndInlineCandidate(
Function &F, InlineCandidate &Candidate, uint64_t SumOrigin, uint64_t &Sum,
SmallVector<CallBase *, 8> *InlinedCallSite) {
+ // Bail out early if MaxNumPromotions is zero.
+ // This prevents allocating an array of zero length in callees below.
+ if (MaxNumPromotions == 0)
+ return false;
auto CalleeFunctionName = Candidate.CalleeSamples->getFuncName();
auto R = SymbolMap.find(CalleeFunctionName);
if (R == SymbolMap.end() || !R->getValue())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120295.410705.patch
Type: text/x-patch
Size: 1303 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220223/f5f37fe0/attachment.bin>
More information about the llvm-commits
mailing list