[llvm] 811832a - [Orc] Refactor debug section requirements into a more flexible flags field (NFC)
Stefan Gränitz via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 31 01:54:05 PDT 2023
Author: Stefan Gränitz
Date: 2023-03-31T10:43:58+02:00
New Revision: 811832a938090458bd4be7ce1872485a4ce99d57
URL: https://github.com/llvm/llvm-project/commit/811832a938090458bd4be7ce1872485a4ce99d57
DIFF: https://github.com/llvm/llvm-project/commit/811832a938090458bd4be7ce1872485a4ce99d57.diff
LOG: [Orc] Refactor debug section requirements into a more flexible flags field (NFC)
When the initial DebugObjectManagerPlugin landed, it was not clear whether we will have more patching requirements for debug section. Also, there were no other use-cases for debug object flags.
Adding options to the plugin gives us a use-case and we can re-use the field for it. This commit only refactors the infrastructure in preparation for two more patches to come.
Added:
Modified:
llvm/lib/ExecutionEngine/Orc/DebugObjectManagerPlugin.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ExecutionEngine/Orc/DebugObjectManagerPlugin.cpp b/llvm/lib/ExecutionEngine/Orc/DebugObjectManagerPlugin.cpp
index b2c4c27ce2aa..678a2315e18a 100644
--- a/llvm/lib/ExecutionEngine/Orc/DebugObjectManagerPlugin.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/DebugObjectManagerPlugin.cpp
@@ -102,9 +102,9 @@ void ELFDebugObjectSection<ELFT>::dump(raw_ostream &OS, StringRef Name) {
}
}
-enum class Requirement {
+enum DebugObjectFlags : int {
// Request final target memory load-addresses for all sections.
- ReportFinalSectionLoadAddresses,
+ ReportFinalSectionLoadAddresses = 1 << 0,
};
/// The plugin creates a debug object from when JITLink starts processing the
@@ -118,8 +118,13 @@ class DebugObject {
ExecutionSession &ES)
: MemMgr(MemMgr), JD(JD), ES(ES) {}
- void set(Requirement Req) { Reqs.insert(Req); }
- bool has(Requirement Req) const { return Reqs.count(Req) > 0; }
+ bool hasFlags(DebugObjectFlags F) const { return Flags & F; }
+ void setFlags(DebugObjectFlags F) {
+ Flags = static_cast<DebugObjectFlags>(Flags | F);
+ }
+ void clearFlags(DebugObjectFlags F) {
+ Flags = static_cast<DebugObjectFlags>(Flags & ~F);
+ }
using FinalizeContinuation = std::function<void(Expected<ExecutorAddrRange>)>;
@@ -148,7 +153,7 @@ class DebugObject {
private:
ExecutionSession &ES;
- std::set<Requirement> Reqs;
+ DebugObjectFlags Flags;
FinalizedAlloc Alloc;
};
@@ -211,7 +216,7 @@ class ELFDebugObject : public DebugObject {
JITLinkMemoryManager &MemMgr, const JITLinkDylib *JD,
ExecutionSession &ES)
: DebugObject(MemMgr, JD, ES), Buffer(std::move(Buffer)) {
- set(Requirement::ReportFinalSectionLoadAddresses);
+ setFlags(ReportFinalSectionLoadAddresses);
}
std::unique_ptr<WritableMemoryBuffer> Buffer;
@@ -429,7 +434,7 @@ void DebugObjectManagerPlugin::modifyPassConfig(
return;
DebugObject &DebugObj = *It->second;
- if (DebugObj.has(Requirement::ReportFinalSectionLoadAddresses)) {
+ if (DebugObj.hasFlags(ReportFinalSectionLoadAddresses)) {
PassConfig.PostAllocationPasses.push_back(
[&DebugObj](LinkGraph &Graph) -> Error {
for (const Section &GraphSection : Graph.sections())
More information about the llvm-commits
mailing list