[llvm] r279892 - [ORC] Fix typo in LogicalDylib, add unit test.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 26 17:19:05 PDT 2016
Author: lhames
Date: Fri Aug 26 19:19:05 2016
New Revision: 279892
URL: http://llvm.org/viewvc/llvm-project?rev=279892&view=rev
Log:
[ORC] Fix typo in LogicalDylib, add unit test.
Added:
llvm/trunk/unittests/ExecutionEngine/Orc/LogicalDylibTest.cpp
Modified:
llvm/trunk/include/llvm/ExecutionEngine/Orc/LogicalDylib.h
llvm/trunk/unittests/ExecutionEngine/Orc/CMakeLists.txt
Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/LogicalDylib.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/LogicalDylib.h?rev=279892&r1=279891&r2=279892&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/LogicalDylib.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/LogicalDylib.h Fri Aug 26 19:19:05 2016
@@ -130,7 +130,7 @@ public:
for (typename LogicalModuleList::size_type I = 0, E = LogicalModules.size();
I != E; ++I)
if (auto Sym = LogicalModules[I].Resources.findSymbol(Name, ExportedSymbolsOnly))
- return &LogicalModules[I]->Resources;
+ return &LogicalModules[I].Resources;
return nullptr;
}
Modified: llvm/trunk/unittests/ExecutionEngine/Orc/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/Orc/CMakeLists.txt?rev=279892&r1=279891&r2=279892&view=diff
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/Orc/CMakeLists.txt (original)
+++ llvm/trunk/unittests/ExecutionEngine/Orc/CMakeLists.txt Fri Aug 26 19:19:05 2016
@@ -14,6 +14,7 @@ add_llvm_unittest(OrcJITTests
IndirectionUtilsTest.cpp
GlobalMappingLayerTest.cpp
LazyEmittingLayerTest.cpp
+ LogicalDylibTest.cpp
ObjectLinkingLayerTest.cpp
ObjectTransformLayerTest.cpp
OrcCAPITest.cpp
Added: llvm/trunk/unittests/ExecutionEngine/Orc/LogicalDylibTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/Orc/LogicalDylibTest.cpp?rev=279892&view=auto
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/Orc/LogicalDylibTest.cpp (added)
+++ llvm/trunk/unittests/ExecutionEngine/Orc/LogicalDylibTest.cpp Fri Aug 26 19:19:05 2016
@@ -0,0 +1,76 @@
+//===----- CompileOnDemandLayerTest.cpp - Unit tests for the COD layer ----===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "OrcTestCommon.h"
+#include "llvm/ExecutionEngine/Orc/LogicalDylib.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace llvm::orc;
+
+namespace {
+
+
+TEST(LogicalDylibTest, getLogicalModuleResourcesForSymbol) {
+
+ std::map<int, std::set<std::string>> ModuleSymbols;
+
+ ModuleSymbols[0] = { "foo", "dummy" };
+ ModuleSymbols[1] = { "bar" };
+ ModuleSymbols[2] = { "baz", "dummy" };
+
+ auto MockBaseLayer = createMockBaseLayer<int>(
+ DoNothingAndReturn<int>(0),
+ DoNothingAndReturn<void>(),
+ [&](const std::string &Name, bool) {
+ for (auto &S : ModuleSymbols)
+ if (S.second.count(Name))
+ return JITSymbol(1, JITSymbolFlags::Exported);
+ return JITSymbol(nullptr);
+ },
+ [&](int H, const std::string &Name, bool) {
+ if (ModuleSymbols[H].count(Name))
+ return JITSymbol(1, JITSymbolFlags::Exported);
+ return JITSymbol(nullptr);
+ });
+
+ struct LDResources { };
+ struct LMResources {
+ public:
+ int ID;
+ std::set<std::string> *Symbols;
+
+ LMResources() : ID(0), Symbols(nullptr) {}
+ LMResources(int ID, std::set<std::string> &Symbols)
+ : ID(ID), Symbols(&Symbols) {}
+
+ JITSymbol findSymbol(const std::string &Name, bool) {
+ assert(Symbols);
+ if (Symbols->count(Name))
+ return JITSymbol(ID, JITSymbolFlags::Exported);
+ return JITSymbol(nullptr);
+ }
+ };
+
+ LogicalDylib<decltype(MockBaseLayer), LMResources, LDResources>
+ LD(MockBaseLayer);
+
+ // Add logical module resources for each of our dummy modules.
+ for (int I = 0; I < 3; ++I) {
+ auto H = LD.createLogicalModule();
+ LD.addToLogicalModule(H, I);
+ LD.getLogicalModuleResources(H) = LMResources(I, ModuleSymbols[I]);
+ }
+
+ {
+ auto LMR = LD.getLogicalModuleResourcesForSymbol("bar", true);
+ EXPECT_TRUE(LMR->ID == 1) << "getLogicalModuleResourcesForSymbol failed";
+ }
+}
+}
More information about the llvm-commits
mailing list