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