From: Lang Hames Date: Sun, 17 Jun 2018 16:59:53 +0000 (+0000) Subject: [ORC] Erase empty dependence sets when adding new symbol dependencies. X-Git-Tag: android-x86-8.1-r1~2015 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=05afd8a0292dcfb4fcec57df0dd9ee074376a872;p=android-x86%2Fexternal-llvm.git [ORC] Erase empty dependence sets when adding new symbol dependencies. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334910 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/ExecutionEngine/Orc/Core.cpp b/lib/ExecutionEngine/Orc/Core.cpp index 96baf624caa..c5730378fa6 100644 --- a/lib/ExecutionEngine/Orc/Core.cpp +++ b/lib/ExecutionEngine/Orc/Core.cpp @@ -467,6 +467,9 @@ void VSO::addDependencies(const SymbolFlagsMap &Dependants, DepsOnOtherVSO.insert(OtherSymbol); } } + + if (DepsOnOtherVSO.empty()) + MI.UnfinalizedDependencies.erase(&OtherVSO); } } }); diff --git a/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp b/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp index 589cdb4d745..b809f34a37f 100644 --- a/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp +++ b/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp @@ -205,6 +205,44 @@ TEST(CoreAPIsTest, LookupFlagsTest) { EXPECT_EQ(SymbolFlags[Bar], BarFlags) << "Incorrect flags returned for Bar"; } +TEST(CoreAPIsTest, TestTrivialCircularDependency) { + ExecutionSession ES; + + auto &V = ES.createVSO("V"); + + auto Foo = ES.getSymbolStringPool().intern("foo"); + auto FooFlags = JITSymbolFlags::Exported; + auto FooSym = JITEvaluatedSymbol(1U, FooFlags); + + Optional FooR; + auto FooMU = llvm::make_unique( + SymbolFlagsMap({{Foo, FooFlags}}), + [&](MaterializationResponsibility R) { FooR.emplace(std::move(R)); }); + + cantFail(V.define(FooMU)); + + bool FooReady = false; + auto Q = + std::make_shared( + SymbolNameSet({ Foo }), + [](Expected R) { + cantFail(std::move(R)); + }, + [&](Error Err) { + cantFail(std::move(Err)); + FooReady = true; + }); + + V.lookup(std::move(Q), { Foo }); + + FooR->addDependencies({{&V, {Foo}}}); + FooR->resolve({{Foo, FooSym}}); + FooR->finalize(); + + EXPECT_TRUE(FooReady) + << "Self-dependency prevented symbol from being marked ready"; +} + TEST(CoreAPIsTest, TestCircularDependenceInOneVSO) { ExecutionSession ES;