From a5247cc5c7a73f3e00c483e0ed36a683889d0ff2 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Sun, 17 Jun 2018 18:59:01 +0000 Subject: [ORC] Only notify queries that they are resolved/ready when the query state changes. This guards against redundant notifications. llvm-svn: 334916 --- .../unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'llvm/unittests/ExecutionEngine') diff --git a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp index b809f34a37f..6e6c7371e1d 100644 --- a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp @@ -163,6 +163,60 @@ TEST(CoreAPIsTest, SimpleAsynchronousSymbolQueryAgainstVSO) { EXPECT_TRUE(OnReadyRun) << "OnReady was not run"; } +TEST(CoreAPIsTest, EmptyVSOAndQueryLookup) { + ExecutionSession ES; + auto &V = ES.createVSO("V"); + + bool OnResolvedRun = false; + bool OnReadyRun = false; + + auto Q = std::make_shared( + SymbolNameSet(), + [&](Expected RR) { + cantFail(std::move(RR)); + OnResolvedRun = true; + }, + [&](Error Err) { + cantFail(std::move(Err)); + OnReadyRun = true; + }); + + V.lookup(std::move(Q), {}); + + EXPECT_TRUE(OnResolvedRun) << "OnResolved was not run for empty query"; + EXPECT_TRUE(OnReadyRun) << "OnReady was not run for empty query"; +} + +TEST(CoreAPIsTest, ChainedVSOLookup) { + ExecutionSession ES; + auto Foo = ES.getSymbolStringPool().intern("foo"); + auto FooSym = JITEvaluatedSymbol(1U, JITSymbolFlags::Exported); + + auto &V1 = ES.createVSO("V1"); + cantFail(V1.define(absoluteSymbols({{Foo, FooSym}}))); + + auto &V2 = ES.createVSO("V2"); + + bool OnResolvedRun = false; + bool OnReadyRun = false; + + auto Q = std::make_shared( + SymbolNameSet({Foo}), + [&](Expected RR) { + cantFail(std::move(RR)); + OnResolvedRun = true; + }, + [&](Error Err) { + cantFail(std::move(Err)); + OnReadyRun = true; + }); + + V2.lookup(Q, V1.lookup(Q, {Foo})); + + EXPECT_TRUE(OnResolvedRun) << "OnResolved was not run for empty query"; + EXPECT_TRUE(OnReadyRun) << "OnReady was not run for empty query"; +} + TEST(CoreAPIsTest, LookupFlagsTest) { // Test that lookupFlags works on a predefined symbol, and does not trigger -- cgit v1.2.3