[PATCH] D154023: [BOLT][NFCI] Move ProbeDecoder to PseudoProbeRewriter
Maksim Panchenko via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 28 17:09:02 PDT 2023
maksfb created this revision.
maksfb added reviewers: Elvina, treapster, jobnoorman, yota9, Amir, ayermolo, rafauler.
Herald added a project: All.
maksfb requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
ProbeDecoder is used only by PseudoProbeRewriter. Move it out of the
BinaryContext.
Depends on D154022 <https://reviews.llvm.org/D154022>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D154023
Files:
bolt/include/bolt/Core/BinaryContext.h
bolt/lib/Rewrite/PseudoProbeRewriter.cpp
Index: bolt/lib/Rewrite/PseudoProbeRewriter.cpp
===================================================================
--- bolt/lib/Rewrite/PseudoProbeRewriter.cpp
+++ bolt/lib/Rewrite/PseudoProbeRewriter.cpp
@@ -15,6 +15,7 @@
#include "bolt/Rewrite/Rewriters.h"
#include "bolt/Utils/CommandLineOpts.h"
#include "llvm/IR/Function.h"
+#include "llvm/MC/MCPseudoProbe.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/LEB128.h"
@@ -70,6 +71,9 @@
/// Setup Pseudo probe decoder
void parsePseudoProbe();
+ /// PseudoProbe decoder
+ MCPseudoProbeDecoder ProbeDecoder;
+
public:
PseudoProbeRewriter() : RewriterBase("pseudo-probe-rewriter") {}
@@ -102,7 +106,7 @@
}
StringRef Contents = PseudoProbeDescSection->getContents();
- if (!BC->ProbeDecoder.buildGUID2FuncDescMap(
+ if (!ProbeDecoder.buildGUID2FuncDescMap(
reinterpret_cast<const uint8_t *>(Contents.data()),
Contents.size())) {
errs() << "BOLT-WARNING: fail in building GUID2FuncDescMap\n";
@@ -118,10 +122,10 @@
}
}
Contents = PseudoProbeSection->getContents();
- if (!BC->ProbeDecoder.buildAddress2ProbeMap(
+ if (!ProbeDecoder.buildAddress2ProbeMap(
reinterpret_cast<const uint8_t *>(Contents.data()), Contents.size(),
GuidFilter, FuncStartAddrs)) {
- BC->ProbeDecoder.getAddress2ProbesMap().clear();
+ ProbeDecoder.getAddress2ProbesMap().clear();
errs() << "BOLT-WARNING: fail in building Address2ProbeMap\n";
return;
}
@@ -130,19 +134,18 @@
opts::PrintPseudoProbes ==
opts::PrintPseudoProbesOptions::PPP_Probes_Section_Decode) {
outs() << "Report of decoding input pseudo probe binaries \n";
- BC->ProbeDecoder.printGUID2FuncDescMap(outs());
- BC->ProbeDecoder.printProbesForAllAddresses(outs());
+ ProbeDecoder.printGUID2FuncDescMap(outs());
+ ProbeDecoder.printProbesForAllAddresses(outs());
}
}
void PseudoProbeRewriter::updatePseudoProbes() {
// check if there is pseudo probe section decoded
- if (BC->ProbeDecoder.getAddress2ProbesMap().empty())
+ if (ProbeDecoder.getAddress2ProbesMap().empty())
return;
// input address converted to output
- AddressProbesMap &Address2ProbesMap = BC->ProbeDecoder.getAddress2ProbesMap();
- const GUIDProbeFunctionMap &GUID2Func =
- BC->ProbeDecoder.getGUID2FuncDescMap();
+ AddressProbesMap &Address2ProbesMap = ProbeDecoder.getAddress2ProbesMap();
+ const GUIDProbeFunctionMap &GUID2Func = ProbeDecoder.getGUID2FuncDescMap();
for (auto &AP : Address2ProbesMap) {
BinaryFunction *F = BC->getBinaryFunctionContainingAddress(AP.first);
@@ -300,7 +303,7 @@
// encoded to binaries. It's a "wrapper" of inline trees of each function.
std::list<std::pair<uint64_t, MCDecodedPseudoProbeInlineTree *>> NextNodes;
const MCDecodedPseudoProbeInlineTree &Root =
- BC->ProbeDecoder.getDummyInlineRoot();
+ ProbeDecoder.getDummyInlineRoot();
for (auto Child = Root.getChildren().begin();
Child != Root.getChildren().end(); ++Child)
Inlinees[Child->first] = Child->second.get();
Index: bolt/include/bolt/Core/BinaryContext.h
===================================================================
--- bolt/include/bolt/Core/BinaryContext.h
+++ bolt/include/bolt/Core/BinaryContext.h
@@ -29,7 +29,6 @@
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/MC/MCObjectWriter.h"
-#include "llvm/MC/MCPseudoProbe.h"
#include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCStreamer.h"
@@ -681,9 +680,6 @@
/// and are referenced from BinaryFunction.
std::list<std::pair<BinaryFunction *, uint64_t>> InterproceduralReferences;
- /// PseudoProbe decoder
- MCPseudoProbeDecoder ProbeDecoder;
-
/// DWARF encoding. Available encoding types defined in BinaryFormat/Dwarf.h
/// enum Constants, e.g. DW_EH_PE_omit.
unsigned LSDAEncoding = dwarf::DW_EH_PE_omit;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154023.535571.patch
Type: text/x-patch
Size: 3983 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230629/019bae14/attachment.bin>
More information about the llvm-commits
mailing list