[ORC] Filter out self-dependencies in VSO::addDependencies.

llvm-svn: 334724
This commit is contained in:
Lang Hames 2018-06-14 15:32:59 +00:00
parent bd49fb83aa
commit b7788ebb4a
2 changed files with 8 additions and 1 deletions

View 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);
}

View 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";