[PATCH] D42842: [MCJIT] Eliminate overhead in case of multiple subsequent calls to llvm::MCJIT::getFunctionAddress
Mariya Podchishchaeva via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 2 06:36:51 PST 2018
Fznamznon created this revision.
Herald added a subscriber: llvm-commits.
llvm::MCJIT::finalizeLoadedModules introduces significant overhead per each
call to llvm::MCJIT::getFunctionAddress because it runs symbol relocations,
EH frames registering, and memory page permissions handling every time
although this has to be done only once.
Patch by: Andrey Lizunov.
Repository:
rL LLVM
https://reviews.llvm.org/D42842
Files:
lib/ExecutionEngine/MCJIT/MCJIT.cpp
lib/ExecutionEngine/MCJIT/MCJIT.h
Index: lib/ExecutionEngine/MCJIT/MCJIT.h
===================================================================
--- lib/ExecutionEngine/MCJIT/MCJIT.h
+++ lib/ExecutionEngine/MCJIT/MCJIT.h
@@ -121,6 +121,10 @@
(FinalizedModules.count(M) != 0);
}
+ bool allModulesAreFinalized() {
+ return (AddedModules.size() == 0) && (LoadedModules.size() == 0);
+ }
+
void markModuleAsLoaded(Module *M) {
// This checks against logic errors in the MCJIT implementation.
// This function should never be called with either a Module that MCJIT
Index: lib/ExecutionEngine/MCJIT/MCJIT.cpp
===================================================================
--- lib/ExecutionEngine/MCJIT/MCJIT.cpp
+++ lib/ExecutionEngine/MCJIT/MCJIT.cpp
@@ -231,6 +231,9 @@
void MCJIT::finalizeLoadedModules() {
MutexGuard locked(lock);
+ if (OwnedModules.allModulesAreFinalized())
+ return;
+
// Resolve any outstanding relocations.
Dyld.resolveRelocations();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42842.132579.patch
Type: text/x-patch
Size: 991 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180202/5cd26dec/attachment.bin>
More information about the llvm-commits
mailing list