[PATCH] D102007: [CSSPGO] Fix return value of getProbeWeight
Lei Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 6 10:16:24 PDT 2021
wlei created this revision.
Herald added subscribers: hoy, wenlei, lxfind, hiraditya.
wlei requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D102007
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
@@ -540,21 +540,30 @@
return getInstWeightImpl(Inst);
}
+// Here use error_code to represent: 1) The dangling probe. 2) Ignore the weight
+// of non-probe instruction. So if all instructions of the BB give error_code,
+// tell the inference algorithm to infer the BB weight.
ErrorOr<uint64_t> SampleProfileLoader::getProbeWeight(const Instruction &Inst) {
assert(FunctionSamples::ProfileIsProbeBased &&
"Profile is not pseudo probe based");
Optional<PseudoProbe> Probe = extractProbe(Inst);
+ // Ignore the non-probe instruction. If none of the instruction in the BB is
+ // probe, we choose to infer the BB's weight.
if (!Probe)
return std::error_code();
- // Ignore danling probes since they are logically deleted and should not
- // consume any profile samples.
+ // This is not the dangling probe from the training pass but generated by the
+ // current compilation. Ignore this since they are logically deleted and
+ // should not consume any profile samples.
if (Probe->isDangling())
return std::error_code();
const FunctionSamples *FS = findFunctionSamples(Inst);
+ // If none of the instruction has FunctionSample and this happens when the
+ // instruction is from inliner and no profile data found. We choose to return
+ // zero value sample to indicate the BB is cold.
if (!FS)
- return std::error_code();
+ return 0;
// For non-CS profile, If a direct call/invoke instruction is inlined in
// profile (findCalleeFunctionSamples returns non-empty result), but not
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102007.343450.patch
Type: text/x-patch
Size: 1756 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210506/923fdf48/attachment.bin>
More information about the llvm-commits
mailing list