From 6780b3c29d17c84ecac4626ea0f94a0850bad38b Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Sat, 6 Oct 2018 23:02:06 +0000 Subject: [PATCH] [ORC] Pass symbol name to discard by const reference. This saves some unnecessary atomic ref-counting operations. llvm-svn: 343927 --- include/llvm/ExecutionEngine/Orc/Core.h | 8 ++++---- include/llvm/ExecutionEngine/Orc/Layer.h | 4 ++-- include/llvm/ExecutionEngine/Orc/LazyReexports.h | 2 +- lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp | 2 +- lib/ExecutionEngine/Orc/Core.cpp | 4 ++-- lib/ExecutionEngine/Orc/IndirectionUtils.cpp | 2 +- lib/ExecutionEngine/Orc/Layer.cpp | 5 +++-- lib/ExecutionEngine/Orc/LazyReexports.cpp | 2 +- unittests/ExecutionEngine/Orc/OrcTestCommon.h | 3 ++- 9 files changed, 17 insertions(+), 15 deletions(-) diff --git a/include/llvm/ExecutionEngine/Orc/Core.h b/include/llvm/ExecutionEngine/Orc/Core.h index 24742b10920..f154a713711 100644 --- a/include/llvm/ExecutionEngine/Orc/Core.h +++ b/include/llvm/ExecutionEngine/Orc/Core.h @@ -255,7 +255,7 @@ public: /// Called by JITDylibs to notify MaterializationUnits that the given symbol /// has been overridden. - void doDiscard(const JITDylib &JD, SymbolStringPtr Name) { + void doDiscard(const JITDylib &JD, const SymbolStringPtr &Name) { SymbolFlags.erase(Name); discard(JD, std::move(Name)); } @@ -275,7 +275,7 @@ private: /// from the source (e.g. if the source is an LLVM IR Module and the /// symbol is a function, delete the function body or mark it available /// externally). - virtual void discard(const JITDylib &JD, SymbolStringPtr Name) = 0; + virtual void discard(const JITDylib &JD, const SymbolStringPtr &Name) = 0; }; using MaterializationUnitList = @@ -293,7 +293,7 @@ public: private: void materialize(MaterializationResponsibility R) override; - void discard(const JITDylib &JD, SymbolStringPtr Name) override; + void discard(const JITDylib &JD, const SymbolStringPtr &Name) override; static SymbolFlagsMap extractFlags(const SymbolMap &Symbols); SymbolMap Symbols; @@ -344,7 +344,7 @@ public: private: void materialize(MaterializationResponsibility R) override; - void discard(const JITDylib &JD, SymbolStringPtr Name) override; + void discard(const JITDylib &JD, const SymbolStringPtr &Name) override; static SymbolFlagsMap extractFlags(const SymbolAliasMap &Aliases); JITDylib *SourceJD = nullptr; diff --git a/include/llvm/ExecutionEngine/Orc/Layer.h b/include/llvm/ExecutionEngine/Orc/Layer.h index 0d3de74093e..3bd23ae5416 100644 --- a/include/llvm/ExecutionEngine/Orc/Layer.h +++ b/include/llvm/ExecutionEngine/Orc/Layer.h @@ -96,7 +96,7 @@ protected: SymbolNameToDefinitionMap SymbolToDefinition; private: - void discard(const JITDylib &JD, SymbolStringPtr Name) override; + void discard(const JITDylib &JD, const SymbolStringPtr &Name) override; }; /// MaterializationUnit that materializes modules by calling the 'emit' method @@ -158,7 +158,7 @@ public: private: void materialize(MaterializationResponsibility R) override; - void discard(const JITDylib &JD, SymbolStringPtr Name) override; + void discard(const JITDylib &JD, const SymbolStringPtr &Name) override; ObjectLayer &L; VModuleKey K; diff --git a/include/llvm/ExecutionEngine/Orc/LazyReexports.h b/include/llvm/ExecutionEngine/Orc/LazyReexports.h index 4efbdffc219..8f897009ac2 100644 --- a/include/llvm/ExecutionEngine/Orc/LazyReexports.h +++ b/include/llvm/ExecutionEngine/Orc/LazyReexports.h @@ -165,7 +165,7 @@ public: private: void materialize(MaterializationResponsibility R) override; - void discard(const JITDylib &JD, SymbolStringPtr Name) override; + void discard(const JITDylib &JD, const SymbolStringPtr &Name) override; static SymbolFlagsMap extractFlags(const SymbolAliasMap &Aliases); LazyCallThroughManager &LCTManager; diff --git a/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp b/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp index 78ee0e73cfa..368969b7a57 100644 --- a/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp +++ b/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp @@ -85,7 +85,7 @@ private: std::move(SymbolToDefinition)); } - void discard(const JITDylib &V, SymbolStringPtr Name) override { + void discard(const JITDylib &V, const SymbolStringPtr &Name) override { // All original symbols were materialized by the CODLayer and should be // final. The function bodies provided by M should never be overridden. llvm_unreachable("Discard should never be called on an " diff --git a/lib/ExecutionEngine/Orc/Core.cpp b/lib/ExecutionEngine/Orc/Core.cpp index b44427d9d03..2e70c5caa9b 100644 --- a/lib/ExecutionEngine/Orc/Core.cpp +++ b/lib/ExecutionEngine/Orc/Core.cpp @@ -489,7 +489,7 @@ void AbsoluteSymbolsMaterializationUnit::materialize( } void AbsoluteSymbolsMaterializationUnit::discard(const JITDylib &JD, - SymbolStringPtr Name) { + const SymbolStringPtr &Name) { assert(Symbols.count(Name) && "Symbol is not part of this MU"); Symbols.erase(Name); } @@ -637,7 +637,7 @@ void ReExportsMaterializationUnit::materialize( } void ReExportsMaterializationUnit::discard(const JITDylib &JD, - SymbolStringPtr Name) { + const SymbolStringPtr &Name) { assert(Aliases.count(Name) && "Symbol not covered by this MaterializationUnit"); Aliases.erase(Name); diff --git a/lib/ExecutionEngine/Orc/IndirectionUtils.cpp b/lib/ExecutionEngine/Orc/IndirectionUtils.cpp index 962ae3306fe..0acc5db76f4 100644 --- a/lib/ExecutionEngine/Orc/IndirectionUtils.cpp +++ b/lib/ExecutionEngine/Orc/IndirectionUtils.cpp @@ -41,7 +41,7 @@ private: R.emit(); } - void discard(const JITDylib &JD, SymbolStringPtr Name) override { + void discard(const JITDylib &JD, const SymbolStringPtr &Name) override { llvm_unreachable("Discard should never occur on a LMU?"); } diff --git a/lib/ExecutionEngine/Orc/Layer.cpp b/lib/ExecutionEngine/Orc/Layer.cpp index 323e1d2214b..22dbf5c26d1 100644 --- a/lib/ExecutionEngine/Orc/Layer.cpp +++ b/lib/ExecutionEngine/Orc/Layer.cpp @@ -53,7 +53,8 @@ StringRef IRMaterializationUnit::getName() const { return ""; } -void IRMaterializationUnit::discard(const JITDylib &JD, SymbolStringPtr Name) { +void IRMaterializationUnit::discard(const JITDylib &JD, + const SymbolStringPtr &Name) { LLVM_DEBUG(JD.getExecutionSession().runSessionLocked([&]() { dbgs() << "In " << JD.getName() << " discarding " << *Name << " from MU@" << this << " (" << getName() << ")\n"; @@ -145,7 +146,7 @@ void BasicObjectLayerMaterializationUnit::materialize( } void BasicObjectLayerMaterializationUnit::discard(const JITDylib &JD, - SymbolStringPtr Name) { + const SymbolStringPtr &Name) { // FIXME: Support object file level discard. This could be done by building a // filter to pass to the object layer along with the object itself. } diff --git a/lib/ExecutionEngine/Orc/LazyReexports.cpp b/lib/ExecutionEngine/Orc/LazyReexports.cpp index 72db80bea87..0d8049178b5 100644 --- a/lib/ExecutionEngine/Orc/LazyReexports.cpp +++ b/lib/ExecutionEngine/Orc/LazyReexports.cpp @@ -187,7 +187,7 @@ void LazyReexportsMaterializationUnit::materialize( } void LazyReexportsMaterializationUnit::discard(const JITDylib &JD, - SymbolStringPtr Name) { + const SymbolStringPtr &Name) { assert(CallableAliases.count(Name) && "Symbol not covered by this MaterializationUnit"); CallableAliases.erase(Name); diff --git a/unittests/ExecutionEngine/Orc/OrcTestCommon.h b/unittests/ExecutionEngine/Orc/OrcTestCommon.h index ae6dce6b9c8..284a1e37f10 100644 --- a/unittests/ExecutionEngine/Orc/OrcTestCommon.h +++ b/unittests/ExecutionEngine/Orc/OrcTestCommon.h @@ -112,7 +112,8 @@ public: Materialize(std::move(R)); } - void discard(const orc::JITDylib &JD, orc::SymbolStringPtr Name) override { + void discard(const orc::JITDylib &JD, + const orc::SymbolStringPtr &Name) override { if (Discard) Discard(JD, std::move(Name)); else