summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2016-08-27 00:19:05 +0000
committerLang Hames <lhames@gmail.com>2016-08-27 00:19:05 +0000
commit28fa3c519c311f247257d8f28f20687d0e27d9e5 (patch)
treef4a11ec2cb7c6d2b66b9c55d1da62a9972c78e10
parent374796d67853db94589da4aec48443e28e1a1590 (diff)
downloadbcm5719-llvm-28fa3c519c311f247257d8f28f20687d0e27d9e5.tar.gz
bcm5719-llvm-28fa3c519c311f247257d8f28f20687d0e27d9e5.zip
[ORC] Fix typo in LogicalDylib, add unit test.
llvm-svn: 279892
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/LogicalDylib.h2
-rw-r--r--llvm/unittests/ExecutionEngine/Orc/CMakeLists.txt1
-rw-r--r--llvm/unittests/ExecutionEngine/Orc/LogicalDylibTest.cpp76
3 files changed, 78 insertions, 1 deletions
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/LogicalDylib.h b/llvm/include/llvm/ExecutionEngine/Orc/LogicalDylib.h
index 7939b80386c..b45c6b3871e 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/LogicalDylib.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/LogicalDylib.h
@@ -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;
}
diff --git a/llvm/unittests/ExecutionEngine/Orc/CMakeLists.txt b/llvm/unittests/ExecutionEngine/Orc/CMakeLists.txt
index 68f6d0c28d7..3f155d3549c 100644
--- a/llvm/unittests/ExecutionEngine/Orc/CMakeLists.txt
+++ b/llvm/unittests/ExecutionEngine/Orc/CMakeLists.txt
@@ -14,6 +14,7 @@ add_llvm_unittest(OrcJITTests
IndirectionUtilsTest.cpp
GlobalMappingLayerTest.cpp
LazyEmittingLayerTest.cpp
+ LogicalDylibTest.cpp
ObjectLinkingLayerTest.cpp
ObjectTransformLayerTest.cpp
OrcCAPITest.cpp
diff --git a/llvm/unittests/ExecutionEngine/Orc/LogicalDylibTest.cpp b/llvm/unittests/ExecutionEngine/Orc/LogicalDylibTest.cpp
new file mode 100644
index 00000000000..4f0e83d0ac4
--- /dev/null
+++ b/llvm/unittests/ExecutionEngine/Orc/LogicalDylibTest.cpp
@@ -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";
+ }
+}
+}
OpenPOWER on IntegriCloud