[llvm] r258630 - [ORC] Update ObjectTransformLayer signature
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 23 11:14:54 PST 2016
On Sat, Jan 23, 2016 at 10:36 AM, Joseph Tremoulet via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: josepht
> Date: Sat Jan 23 12:36:01 2016
> New Revision: 258630
>
> URL: http://llvm.org/viewvc/llvm-project?rev=258630&view=rev
> Log:
> [ORC] Update ObjectTransformLayer signature
>
> Summary:
> Update ObjectTransformLayer::addObjectSet to take the object set by
> value rather than reference and pass it to the base layer with move
> semantics rather than copy, to match r258185's changes to
> ObjectLinkingLayer.
>
> Update the unit test to verify that ObjectTransformLayer's signature stays
> in sync with ObjectLinkingLayer's.
>
>
> Reviewers: lhames
>
> Subscribers: llvm-commits
>
> Differential Revision: http://reviews.llvm.org/D16414
>
> Modified:
> llvm/trunk/include/llvm/ExecutionEngine/Orc/ObjectTransformLayer.h
> llvm/trunk/unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp
>
> Modified:
> llvm/trunk/include/llvm/ExecutionEngine/Orc/ObjectTransformLayer.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/ObjectTransformLayer.h?rev=258630&r1=258629&r2=258630&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/ExecutionEngine/Orc/ObjectTransformLayer.h
> (original)
> +++ llvm/trunk/include/llvm/ExecutionEngine/Orc/ObjectTransformLayer.h Sat
> Jan 23 12:36:01 2016
> @@ -42,13 +42,13 @@ public:
> /// @return A handle for the added objects.
> template <typename ObjSetT, typename MemoryManagerPtrT,
> typename SymbolResolverPtrT>
> - ObjSetHandleT addObjectSet(ObjSetT &Objects, MemoryManagerPtrT MemMgr,
> + ObjSetHandleT addObjectSet(ObjSetT Objects, MemoryManagerPtrT MemMgr,
> SymbolResolverPtrT Resolver) {
>
> for (auto I = Objects.begin(), E = Objects.end(); I != E; ++I)
> *I = Transform(std::move(*I));
>
> - return BaseLayer.addObjectSet(Objects, std::move(MemMgr),
> + return BaseLayer.addObjectSet(std::move(Objects), std::move(MemMgr),
> std::move(Resolver));
> }
>
>
> Modified:
> llvm/trunk/unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp?rev=258630&r1=258629&r2=258630&view=diff
>
> ==============================================================================
> --- llvm/trunk/unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp
> (original)
> +++ llvm/trunk/unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp
> Sat Jan 23 12:36:01 2016
> @@ -7,9 +7,14 @@
> //
>
> //===----------------------------------------------------------------------===//
>
> -#include "llvm/ExecutionEngine/Orc/ObjectTransformLayer.h"
> #include "llvm/ADT/STLExtras.h"
> #include "llvm/ADT/SmallVector.h"
> +#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
> +#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
> +#include "llvm/ExecutionEngine/Orc/NullResolver.h"
> +#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
> +#include "llvm/ExecutionEngine/Orc/ObjectTransformLayer.h"
> +#include "llvm/Object/ObjectFile.h"
> #include "gtest/gtest.h"
>
> using namespace llvm::orc;
> @@ -51,7 +56,7 @@ public:
>
> template <typename ObjSetT, typename MemoryManagerPtrT,
> typename SymbolResolverPtrT>
> - ObjSetHandleT addObjectSet(ObjSetT &Objects, MemoryManagerPtrT MemMgr,
> + ObjSetHandleT addObjectSet(ObjSetT Objects, MemoryManagerPtrT MemMgr,
> SymbolResolverPtrT Resolver) {
> EXPECT_EQ(MockManager, *MemMgr) << "MM should pass through";
> EXPECT_EQ(MockResolver, *Resolver) << "Resolver should pass through";
> @@ -216,13 +221,14 @@ TEST(ObjectTransformLayerTest, Main) {
> auto MM = llvm::make_unique<MockMemoryManager>(MockManager);
> auto SR = llvm::make_unique<MockSymbolResolver>(MockResolver);
> M.expectAddObjectSet(Objs1, MM.get(), SR.get());
> - auto H = T1.addObjectSet(Objs1, std::move(MM), std::move(SR));
> + auto H = T1.addObjectSet(std::move(Objs1), std::move(MM),
> std::move(SR));
> M.verifyAddObjectSet(H);
>
> // Test addObjectSet with T2 (mutating, naked pointers)
> - llvm::SmallVector<MockObjectFile *, 2> Objs2;
> - Objs2.push_back(&MockObject1);
> - Objs2.push_back(&MockObject2);
> + llvm::SmallVector<MockObjectFile *, 2> Objs2Vec;
> + Objs2Vec.push_back(&MockObject1);
> + Objs2Vec.push_back(&MockObject2);
> + llvm::MutableArrayRef<MockObjectFile *> Objs2(Objs2Vec);
> M.expectAddObjectSet(Objs2, &MockManager, &MockResolver);
> H = T2.addObjectSet(Objs2, &MockManager, &MockResolver);
> M.verifyAddObjectSet(H);
> @@ -271,5 +277,62 @@ TEST(ObjectTransformLayerTest, Main) {
> const auto &T1C = T1;
> OwnedObj = T1C.getTransform()(std::move(OwnedObj));
> EXPECT_EQ(289, *OwnedObj) << "Expected incrementing transform";
> +
> + volatile bool RunStaticChecks = false;
> + if (RunStaticChecks) {
>
Looks like you could reduce indentation by switching this condition ("If
(!RunStaticChecks) return").
> + // Make sure that ObjectTransformLayer implements the object layer
> concept
> + // correctly by sandwitching one between an ObjectLinkingLayer and an
> + // IRCompileLayer, verifying that it compiles if we have a call to the
> + // IRComileLayer's addModuleSet that should call the transform layer's
> + // addObjectSet, and also calling the other public transform layer
> methods
> + // directly to make sure the methods they intend to forward to exist
> on
> + // the ObjectLinkingLayer.
> +
> + // We'll need a concrete MemoryManager class.
> + class NullManager : public llvm::RuntimeDyld::MemoryManager {
> + public:
> + uint8_t *allocateCodeSection(uintptr_t, unsigned, unsigned,
> + llvm::StringRef) override {
> + return nullptr;
> + }
> + uint8_t *allocateDataSection(uintptr_t, unsigned, unsigned,
> + llvm::StringRef, bool) override {
> + return nullptr;
> + }
> + void registerEHFrames(uint8_t *, uint64_t, size_t) override {}
> + void deregisterEHFrames(uint8_t *, uint64_t, size_t) override {}
> + bool finalizeMemory(std::string *) { return false; }
> + };
> +
> + // Construct the jit layers.
> + ObjectLinkingLayer<> BaseLayer;
> + auto IdentityTransform = [](
> +
> std::unique_ptr<llvm::object::OwningBinary<llvm::object::ObjectFile>>
> + Obj) { return std::move(Obj); };
> + ObjectTransformLayer<decltype(BaseLayer), decltype(IdentityTransform)>
> + TransformLayer(BaseLayer, IdentityTransform);
> + auto NullCompiler = [](llvm::Module &) {
> + return llvm::object::OwningBinary<llvm::object::ObjectFile>();
> + };
> + IRCompileLayer<decltype(TransformLayer)> CompileLayer(TransformLayer,
> + NullCompiler);
> + std::vector<llvm::Module *> Modules;
>
Is this variable ^ unused?
> +
> + // Make sure that the calls from IRCompileLayer to
> ObjectTransformLayer
> + // compile.
> + NullResolver Resolver;
> + NullManager Manager;
> + CompileLayer.addModuleSet(std::vector<llvm::Module *>(), &Manager,
> + &Resolver);
You might be able to use "{}" for the empty vector, but not sure how that's
all templated, etc.
> +
> + // Make sure that the calls from ObjectTransformLayer to
> ObjectLinkingLayer
> + // compile.
> + decltype(TransformLayer)::ObjSetHandleT ObjSet;
> + TransformLayer.emitAndFinalize(ObjSet);
> + TransformLayer.findSymbolIn(ObjSet, Name, false);
> + TransformLayer.findSymbol(Name, true);
> + TransformLayer.mapSectionAddress(ObjSet, nullptr, 0);
> + TransformLayer.removeObjectSet(ObjSet);
> + }
> }
> }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160123/237b2fe6/attachment.html>
More information about the llvm-commits
mailing list