[llvm] 35c9072 - [JITLink] Fix access of moved-from argument in 265d6bda95b.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 26 19:15:50 PDT 2023


Author: Lang Hames
Date: 2023-08-26T19:13:55-07:00
New Revision: 35c9072c908fac5f10704f1b3912011c67be549c

URL: https://github.com/llvm/llvm-project/commit/35c9072c908fac5f10704f1b3912011c67be549c
DIFF: https://github.com/llvm/llvm-project/commit/35c9072c908fac5f10704f1b3912011c67be549c.diff

LOG: [JITLink] Fix access of moved-from argument in 265d6bda95b.

The LinkGraph that is passed into the ELFJITLinker_x86_64 constructor is handed
off to the JITLinker base class, so can't be used in the constructor body. This
commit adds a getGraph method to JITLinker, and updates ELFJITLinker_x86_64 to
use that.

Added: 
    

Modified: 
    llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
    llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.h

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
index 4af2dff57399a4..3dc2636a447bed 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
@@ -243,7 +243,7 @@ class ELFJITLinker_x86_64 : public JITLinker<ELFJITLinker_x86_64> {
                       PassConfiguration PassConfig)
       : JITLinker(std::move(Ctx), std::move(G), std::move(PassConfig)) {
 
-    if (shouldAddDefaultTargetPasses(G->getTargetTriple()))
+    if (shouldAddDefaultTargetPasses(getGraph().getTargetTriple()))
       getPassConfig().PostAllocationPasses.push_back(
           [this](LinkGraph &G) { return getOrCreateGOTSymbol(G); });
   }

diff  --git a/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.h b/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.h
index 2dd6d5747f424b..25c533a5103be5 100644
--- a/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.h
+++ b/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.h
@@ -43,6 +43,9 @@ class JITLinkerBase {
   using AllocResult = Expected<std::unique_ptr<InFlightAlloc>>;
   using FinalizeResult = Expected<JITLinkMemoryManager::FinalizedAlloc>;
 
+  // Returns a reference to the graph being linked.
+  LinkGraph &getGraph() { return *G; }
+
   // Returns true if the context says that the linker should add default
   // passes. This can be used by JITLinkerBase implementations when deciding
   // whether they should add default passes.


        


More information about the llvm-commits mailing list