From: Stefan Gränitz Date: Fri, 31 Mar 2023 08:43:29 +0000 (+0200) Subject: [Orc] Refactor debug section requirements into a more flexible flags field (NFC) X-Git-Tag: upstream/17.0.6~13097 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=811832a938090458bd4be7ce1872485a4ce99d57;p=platform%2Fupstream%2Fllvm.git [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. --- diff --git a/llvm/lib/ExecutionEngine/Orc/DebugObjectManagerPlugin.cpp b/llvm/lib/ExecutionEngine/Orc/DebugObjectManagerPlugin.cpp index b2c4c27..678a231 100644 --- a/llvm/lib/ExecutionEngine/Orc/DebugObjectManagerPlugin.cpp +++ b/llvm/lib/ExecutionEngine/Orc/DebugObjectManagerPlugin.cpp @@ -102,9 +102,9 @@ void ELFDebugObjectSection::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 @@ public: 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(Flags | F); + } + void clearFlags(DebugObjectFlags F) { + Flags = static_cast(Flags & ~F); + } using FinalizeContinuation = std::function)>; @@ -148,7 +153,7 @@ protected: private: ExecutionSession &ES; - std::set Reqs; + DebugObjectFlags Flags; FinalizedAlloc Alloc; }; @@ -211,7 +216,7 @@ private: JITLinkMemoryManager &MemMgr, const JITLinkDylib *JD, ExecutionSession &ES) : DebugObject(MemMgr, JD, ES), Buffer(std::move(Buffer)) { - set(Requirement::ReportFinalSectionLoadAddresses); + setFlags(ReportFinalSectionLoadAddresses); } std::unique_ptr 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())