[llvm] 9c607e7 - [JITLink][AArch32] Refactor StubsManager (NFC)
Stefan Gränitz via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 16 15:37:56 PST 2024
Author: Stefan Gränitz
Date: 2024-01-17T00:36:30+01:00
New Revision: 9c607e77eae75f0f9152eb3e6ba2a69616aba4fa
URL: https://github.com/llvm/llvm-project/commit/9c607e77eae75f0f9152eb3e6ba2a69616aba4fa
DIFF: https://github.com/llvm/llvm-project/commit/9c607e77eae75f0f9152eb3e6ba2a69616aba4fa.diff
LOG: [JITLink][AArch32] Refactor StubsManager (NFC)
Added:
Modified:
llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h
llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp
llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h b/llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h
index 53c9ef2fdf395e..7765208b5e3dfe 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h
@@ -318,7 +318,7 @@ inline Error applyFixup(LinkGraph &G, Block &B, const Edge &E,
llvm_unreachable("Relocation must be of class Data, Arm or Thumb");
}
-/// Stubs builder for a specific StubsFlavor
+/// Stubs builder for v7 emits non-position-independent Thumb stubs.
///
/// Right now we only have one default stub kind, but we want to extend this
/// and allow creation of specific kinds in the future (e.g. branch range
@@ -326,13 +326,14 @@ inline Error applyFixup(LinkGraph &G, Block &B, const Edge &E,
///
/// Let's keep it simple for the moment and not wire this through a GOT.
///
-template <StubsFlavor Flavor>
-class StubsManager : public TableManager<StubsManager<Flavor>> {
+class StubsManager_v7 : public TableManager<StubsManager_v7> {
public:
- StubsManager() = default;
+ StubsManager_v7() = default;
/// Name of the object file section that will contain all our stubs.
- static StringRef getSectionName();
+ static StringRef getSectionName() {
+ return "__llvm_jitlink_aarch32_STUBS_Thumbv7";
+ }
/// Implements link-graph traversal via visitExistingEdges().
bool visitEdge(LinkGraph &G, Block *B, Edge &E) {
@@ -354,7 +355,7 @@ class StubsManager : public TableManager<StubsManager<Flavor>> {
return false;
}
- /// Create a branch range extension stub for the class's flavor.
+ /// Create a branch range extension stub with Thumb encoding for v7 CPUs.
Symbol &createEntry(LinkGraph &G, Symbol &Target);
private:
@@ -378,14 +379,6 @@ class StubsManager : public TableManager<StubsManager<Flavor>> {
Section *StubsSection = nullptr;
};
-/// Create a branch range extension stub with Thumb encoding for v7 CPUs.
-template <>
-Symbol &StubsManager<StubsFlavor::v7>::createEntry(LinkGraph &G, Symbol &Target);
-
-template <> inline StringRef StubsManager<StubsFlavor::v7>::getSectionName() {
- return "__llvm_jitlink_aarch32_STUBS_Thumbv7";
-}
-
} // namespace aarch32
} // namespace jitlink
} // namespace llvm
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp
index 3c596a414363e4..b862a7ba2acc92 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp
@@ -216,12 +216,12 @@ class ELFLinkGraphBuilder_aarch32
ArmCfg(std::move(ArmCfg)) {}
};
-template <aarch32::StubsFlavor Flavor>
+template <typename StubsManagerType>
Error buildTables_ELF_aarch32(LinkGraph &G) {
LLVM_DEBUG(dbgs() << "Visiting edges in graph:\n");
- aarch32::StubsManager<Flavor> PLT;
- visitExistingEdges(G, PLT);
+ StubsManagerType StubsManager;
+ visitExistingEdges(G, StubsManager);
return Error::success();
}
@@ -311,7 +311,7 @@ void link_ELF_aarch32(std::unique_ptr<LinkGraph> G,
switch (ArmCfg.Stubs) {
case aarch32::StubsFlavor::v7:
PassCfg.PostPrunePasses.push_back(
- buildTables_ELF_aarch32<aarch32::StubsFlavor::v7>);
+ buildTables_ELF_aarch32<aarch32::StubsManager_v7>);
break;
case aarch32::StubsFlavor::Unsupported:
llvm_unreachable("Check before building graph");
diff --git a/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp b/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
index 4e75bb4882a28a..8153c97deff628 100644
--- a/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
@@ -684,8 +684,7 @@ const uint8_t Thumbv7ABS[] = {
0x60, 0x47 // bx r12
};
-template <>
-Symbol &StubsManager<StubsFlavor::v7>::createEntry(LinkGraph &G, Symbol &Target) {
+Symbol &StubsManager_v7::createEntry(LinkGraph &G, Symbol &Target) {
constexpr uint64_t Alignment = 4;
Block &B = addStub(G, Thumbv7ABS, Alignment);
LLVM_DEBUG({
More information about the llvm-commits
mailing list