[llvm] 1e60ab0 - [JITLink][RISCV] Move relax to PostAllocationPasses

Job Noorman via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 6 00:35:27 PDT 2023


Author: Job Noorman
Date: 2023-07-06T09:35:17+02:00
New Revision: 1e60ab0fbe1961074c3673070be0e3c2211c8084

URL: https://github.com/llvm/llvm-project/commit/1e60ab0fbe1961074c3673070be0e3c2211c8084
DIFF: https://github.com/llvm/llvm-project/commit/1e60ab0fbe1961074c3673070be0e3c2211c8084.diff

LOG: [JITLink][RISCV] Move relax to PostAllocationPasses

`JITLinkContext` is notified (using `notifyResolved`) of the final
symbol addresses after allocating memory and running the post-allocation
passes. However, linker relaxation, which can cause symbol addresses to
change, was run during the pre-fixup passes. This causes users of
JITLink (e.g., ORC) to pick-up wrong symbol addresses when linker
relaxation was enabled.

This patch fixes this by running relaxation during the post-allocation
passes.

Fixes #63671

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D154501

Added: 
    

Modified: 
    llvm/include/llvm/ExecutionEngine/JITLink/ELF_riscv.h
    llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ExecutionEngine/JITLink/ELF_riscv.h b/llvm/include/llvm/ExecutionEngine/JITLink/ELF_riscv.h
index 590ccbf5717229..a0e573baca066f 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/ELF_riscv.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/ELF_riscv.h
@@ -33,7 +33,7 @@ void link_ELF_riscv(std::unique_ptr<LinkGraph> G,
                     std::unique_ptr<JITLinkContext> Ctx);
 
 /// Returns a pass that performs linker relaxation. Should be added to
-/// PreFixupPasses.
+/// PostAllocationPasses.
 LinkGraphPassFunction createRelaxationPass_ELF_riscv();
 
 } // end namespace jitlink

diff  --git a/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
index 77dd68a848588a..a64176df7ba621 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
@@ -967,7 +967,7 @@ void link_ELF_riscv(std::unique_ptr<LinkGraph> G,
       Config.PrePrunePasses.push_back(markAllSymbolsLive);
     Config.PostPrunePasses.push_back(
         PerGraphGOTAndPLTStubsBuilder_ELF_riscv::asPass);
-    Config.PreFixupPasses.push_back(relax);
+    Config.PostAllocationPasses.push_back(relax);
   }
   if (auto Err = Ctx->modifyPassConfig(*G, Config))
     return Ctx->notifyFailed(std::move(Err));


        


More information about the llvm-commits mailing list