[PATCH] D107529: [llvm-profgen] Fix bug of loop scope mismatch
Lei Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 5 16:53:38 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa8a38ef3d99c: [llvm-profgen] Fix bug of loop scope mismatch (authored by wlei).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D107529/new/
https://reviews.llvm.org/D107529
Files:
llvm/tools/llvm-profgen/ProfileGenerator.cpp
Index: llvm/tools/llvm-profgen/ProfileGenerator.cpp
===================================================================
--- llvm/tools/llvm-profgen/ProfileGenerator.cpp
+++ llvm/tools/llvm-profgen/ProfileGenerator.cpp
@@ -8,6 +8,7 @@
#include "ProfileGenerator.h"
#include "llvm/ProfileData/ProfileCommon.h"
+#include <unordered_set>
static cl::opt<std::string> OutputFilename("output", cl::value_desc("output"),
cl::Required,
@@ -520,7 +521,8 @@
// Extract the top frame probes by looking up each address among the range in
// the Address2ProbeMap
extractProbesFromRange(RangeCounter, ProbeCounter, Binary);
- std::unordered_map<MCDecodedPseudoProbeInlineTree *, FunctionSamples *>
+ std::unordered_map<MCDecodedPseudoProbeInlineTree *,
+ std::unordered_set<FunctionSamples *>>
FrameSamples;
for (auto PI : ProbeCounter) {
const MCDecodedPseudoProbe *Probe = PI.first;
@@ -530,7 +532,7 @@
// Record the current frame and FunctionProfile whenever samples are
// collected for non-danglie probes. This is for reporting all of the
// zero count probes of the frame later.
- FrameSamples[Probe->getInlineTreeNode()] = &FunctionProfile;
+ FrameSamples[Probe->getInlineTreeNode()].insert(&FunctionProfile);
FunctionProfile.addBodySamplesForProbe(Probe->getIndex(), Count);
FunctionProfile.addTotalSamples(Count);
if (Probe->isEntry()) {
@@ -559,12 +561,13 @@
FunctionProfile.getContext().getNameWithoutContext(), Count);
}
}
+ }
- // Assign zero count for remaining probes without sample hits to
- // differentiate from probes optimized away, of which the counts are unknown
- // and will be inferred by the compiler.
- for (auto &I : FrameSamples) {
- auto *FunctionProfile = I.second;
+ // Assign zero count for remaining probes without sample hits to
+ // differentiate from probes optimized away, of which the counts are unknown
+ // and will be inferred by the compiler.
+ for (auto &I : FrameSamples) {
+ for (auto *FunctionProfile : I.second) {
for (auto *Probe : I.first->getProbes()) {
FunctionProfile->addBodySamplesForProbe(Probe->getIndex(), 0);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107529.364655.patch
Type: text/x-patch
Size: 2263 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210805/821c440b/attachment.bin>
More information about the llvm-commits
mailing list