[PATCH] D16513: [Unittest] Clean up formatting, NFC
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 3 10:01:22 PST 2016
dblaikie added inline comments.
================
Comment at: unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp:282
@@ -281,56 +281,3 @@
volatile bool RunStaticChecks = false;
- if (RunStaticChecks) {
- // 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 *) override { return false; }
- };
-
- // Construct the jit layers.
- ObjectLinkingLayer<> BaseLayer;
- auto IdentityTransform = [](
- std::unique_ptr<llvm::object::OwningBinary<llvm::object::ObjectFile>>
- Obj) { return 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;
-
- // Make sure that the calls from IRCompileLayer to ObjectTransformLayer
- // compile.
- NullResolver Resolver;
- NullManager Manager;
- CompileLayer.addModuleSet(std::vector<llvm::Module *>(), &Manager,
- &Resolver);
-
- // 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);
- }
+ if (!RunStaticChecks)
+ return;
----------------
Also, it might be simpler to a separate function, attributed with LLVM_UNUSED (so no warnings fire on it) rather than the volatile approach.
(also, I worry about API testing like this - if we have a formal layer concept we want to implement - we should be able to (& we should) check that independently of any particular implementation (& it should check the semantics as well - as we are testing above, presumably). To keep the tests isolated, to avoid slipping API boundaries, narrow tests, etc)
http://reviews.llvm.org/D16513
More information about the llvm-commits
mailing list