OSDN Git Service

[ORC] Filter out self-dependencies in VSO::addDependencies.
authorLang Hames <lhames@gmail.com>
Thu, 14 Jun 2018 15:32:59 +0000 (15:32 +0000)
committerLang Hames <lhames@gmail.com>
Thu, 14 Jun 2018 15:32:59 +0000 (15:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334724 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/Orc/Core.cpp
unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp

index aeb10a5..82be344 100644 (file)
@@ -452,7 +452,7 @@ void VSO::addDependencies(const SymbolFlagsMap &Dependants,
 
           if (OtherMI.IsFinalized)
             transferFinalizedNodeDependencies(MI, Name, OtherMI);
-          else {
+          else if (&OtherVSO != this || OtherSymbol != Name) {
             OtherMI.Dependants[this].insert(Name);
             DepsOnOtherVSO.insert(OtherSymbol);
           }
index 01f81d9..c8f30db 100644 (file)
@@ -301,10 +301,17 @@ TEST(CoreAPIsTest, TestCircularDependenceInOneVSO) {
     EXPECT_TRUE(Unresolved.empty()) << "Failed to resolve \"Baz\"";
   }
 
+  // Add a circular dependency: Foo -> Bar, Bar -> Baz, Baz -> Foo.
   FooR->addDependencies({{&V, SymbolNameSet({Bar})}});
   BarR->addDependencies({{&V, SymbolNameSet({Baz})}});
   BazR->addDependencies({{&V, SymbolNameSet({Foo})}});
 
+  // Add self-dependencies for good measure. This tests that the implementation
+  // of addDependencies filters these out.
+  FooR->addDependencies({{&V, SymbolNameSet({Foo})}});
+  BarR->addDependencies({{&V, SymbolNameSet({Bar})}});
+  BazR->addDependencies({{&V, SymbolNameSet({Baz})}});
+
   EXPECT_FALSE(FooResolved) << "\"Foo\" should not be resolved yet";
   EXPECT_FALSE(BarResolved) << "\"Bar\" should not be resolved yet";
   EXPECT_FALSE(BazResolved) << "\"Baz\" should not be resolved yet";