[ORC] Re-apply r345077 with fixes to remove ambiguity in lookup calls.

llvm-svn: 345098
diff --git a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
index 1ccc475..22be76a 100644
--- a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
@@ -48,7 +48,8 @@
         FooMR = std::make_shared<MaterializationResponsibility>(std::move(R));
       })));
 
-  ES.lookup({&JD}, {Foo}, OnResolution, OnReady, NoDependenciesToRegister);
+  ES.lookup(JITDylibSearchList({{&JD, false}}), {Foo}, OnResolution, OnReady,
+            NoDependenciesToRegister);
 
   EXPECT_FALSE(OnResolutionRun) << "Should not have been resolved yet";
   EXPECT_FALSE(OnReadyRun) << "Should not have been marked ready yet";
@@ -101,7 +102,8 @@
     OnReadyRun = true;
   };
 
-  ES.lookup({&JD}, {}, OnResolution, OnReady, NoDependenciesToRegister);
+  ES.lookup(JITDylibSearchList({{&JD, false}}), {}, OnResolution, OnReady,
+            NoDependenciesToRegister);
 
   EXPECT_TRUE(OnResolvedRun) << "OnResolved was not run for empty query";
   EXPECT_TRUE(OnReadyRun) << "OnReady was not run for empty query";
@@ -148,7 +150,7 @@
 
   bool OnResolvedRun = false;
   bool OnReadyRun = false;
-  ES.lookup({&JD}, {Foo, Baz},
+  ES.lookup(JITDylibSearchList({{&JD, false}}), {Foo, Baz},
             [&](Expected<SymbolMap> Result) {
               EXPECT_TRUE(!!Result) << "OnResolved failed unexpectedly";
               consumeError(Result.takeError());
@@ -229,7 +231,9 @@
   auto &JD2 = ES.createJITDylib("JD2");
   cantFail(JD2.define(absoluteSymbols({{Bar, QuxSym}})));
 
-  auto Result = cantFail(ES.lookup({&JD, &JD2}, {Foo, Bar}));
+  /// Try a blocking lookup.
+  auto Result = cantFail(
+      ES.lookup(JITDylibSearchList({{&JD, false}, {&JD2, false}}), {Foo, Bar}));
 
   EXPECT_EQ(Result.size(), 2U) << "Unexpected number of results";
   EXPECT_EQ(Result.count(Foo), 1U) << "Missing result for \"Foo\"";
@@ -275,7 +279,7 @@
                                     {Qux, {Bar, JITSymbolFlags::Weak}}})));
   cantFail(JD.define(absoluteSymbols({{Qux, QuxSym}})));
 
-  auto Result = ES.lookup({&JD}, {Baz, Qux});
+  auto Result = ES.lookup(JITDylibSearchList({{&JD, false}}), {Baz, Qux});
   EXPECT_TRUE(!!Result) << "Unexpected lookup failure";
   EXPECT_EQ(Result->count(Baz), 1U) << "No result for \"baz\"";
   EXPECT_EQ(Result->count(Qux), 1U) << "No result for \"qux\"";
@@ -290,7 +294,7 @@
   cantFail(JD.define(symbolAliases(
       {{Baz, {Bar, BazSym.getFlags()}}, {Bar, {Foo, BarSym.getFlags()}}})));
 
-  auto Result = ES.lookup({&JD}, {Bar, Baz});
+  auto Result = ES.lookup(JITDylibSearchList({{&JD, false}}), {Bar, Baz});
   EXPECT_TRUE(!!Result) << "Unexpected lookup failure";
   EXPECT_EQ(Result->count(Bar), 1U) << "No result for \"bar\"";
   EXPECT_EQ(Result->count(Baz), 1U) << "No result for \"baz\"";
@@ -309,7 +313,7 @@
 
   cantFail(JD2.define(reexports(JD, {{Bar, {Foo, BarSym.getFlags()}}})));
 
-  auto Result = cantFail(ES.lookup({&JD2}, Bar));
+  auto Result = cantFail(ES.lookup(JITDylibSearchList({{&JD2, false}}), Bar));
   EXPECT_EQ(Result.getAddress(), FooSym.getAddress())
       << "Re-export Bar for symbol Foo should match FooSym's address";
 }
@@ -335,7 +339,7 @@
   cantFail(JD2.define(reexports(
       JD, {{Baz, {Foo, BazSym.getFlags()}}, {Qux, {Bar, QuxSym.getFlags()}}})));
 
-  auto Result = cantFail(ES.lookup({&JD2}, Baz));
+  auto Result = cantFail(ES.lookup(JITDylibSearchList({{&JD2, false}}), Baz));
   EXPECT_EQ(Result.getAddress(), FooSym.getAddress())
       << "Re-export Baz for symbol Foo should match FooSym's address";
 
@@ -350,13 +354,13 @@
 
   auto Filter = [this](SymbolStringPtr Name) { return Name != Bar; };
 
-  JD.setGenerator(ReexportsGenerator(JD2, Filter));
+  JD.setGenerator(ReexportsGenerator(JD2, false, Filter));
 
   auto Flags = JD.lookupFlags({Foo, Bar, Baz});
   EXPECT_EQ(Flags.size(), 1U) << "Unexpected number of results";
   EXPECT_EQ(Flags[Foo], FooSym.getFlags()) << "Unexpected flags for Foo";
 
-  auto Result = cantFail(ES.lookup({&JD}, Foo));
+  auto Result = cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), Foo));
 
   EXPECT_EQ(Result.getAddress(), FooSym.getAddress())
       << "Incorrect reexported symbol address";
@@ -377,8 +381,8 @@
     FooReady = true;
   };
 
-  ES.lookup({&JD}, {Foo}, std::move(OnResolution), std::move(OnReady),
-            NoDependenciesToRegister);
+  ES.lookup(JITDylibSearchList({{&JD, false}}), {Foo}, std::move(OnResolution),
+            std::move(OnReady), NoDependenciesToRegister);
 
   FooR->resolve({{Foo, FooSym}});
   FooR->emit();
@@ -434,7 +438,8 @@
 
   // Issue a lookup for Foo. Use NoDependenciesToRegister: We're going to add
   // the dependencies manually below.
-  ES.lookup({&JD}, {Foo}, std::move(OnFooResolution), std::move(OnFooReady),
+  ES.lookup(JITDylibSearchList({{&JD, false}}), {Foo},
+            std::move(OnFooResolution), std::move(OnFooReady),
             NoDependenciesToRegister);
 
   bool BarResolved = false;
@@ -449,7 +454,8 @@
     BarReady = true;
   };
 
-  ES.lookup({&JD}, {Bar}, std::move(OnBarResolution), std::move(OnBarReady),
+  ES.lookup(JITDylibSearchList({{&JD, false}}), {Bar},
+            std::move(OnBarResolution), std::move(OnBarReady),
             NoDependenciesToRegister);
 
   bool BazResolved = false;
@@ -465,7 +471,8 @@
     BazReady = true;
   };
 
-  ES.lookup({&JD}, {Baz}, std::move(OnBazResolution), std::move(OnBazReady),
+  ES.lookup(JITDylibSearchList({{&JD, false}}), {Baz},
+            std::move(OnBazResolution), std::move(OnBazReady),
             NoDependenciesToRegister);
 
   // Add a circular dependency: Foo -> Bar, Bar -> Baz, Baz -> Foo.
@@ -588,8 +595,8 @@
     OnReadyRun = true;
   };
 
-  ES.lookup({&JD}, Names, std::move(OnResolution), std::move(OnReady),
-            NoDependenciesToRegister);
+  ES.lookup(JITDylibSearchList({{&JD, false}}), Names, std::move(OnResolution),
+            std::move(OnReady), NoDependenciesToRegister);
 
   EXPECT_TRUE(FooMaterialized) << "Foo was not materialized";
   EXPECT_TRUE(BarDiscarded) << "Bar was not discarded";
@@ -637,8 +644,8 @@
     OnReadyRun = true;
   };
 
-  ES.lookup({&JD}, {Bar}, std::move(OnResolution), std::move(OnReady),
-            NoDependenciesToRegister);
+  ES.lookup(JITDylibSearchList({{&JD, false}}), {Bar}, std::move(OnResolution),
+            std::move(OnReady), NoDependenciesToRegister);
 
   EXPECT_TRUE(OnResolvedRun) << "OnResolved not run";
   EXPECT_TRUE(OnReadyRun) << "OnReady not run";
@@ -666,13 +673,13 @@
       });
 
   cantFail(JD.define(MU));
-  cantFail(ES.lookup({&JD}, Foo));
+  cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), Foo));
 
   // Assert that materialization is complete by now.
   ExpectNoMoreMaterialization = true;
 
   // Look up bar to verify that no further materialization happens.
-  auto BarResult = cantFail(ES.lookup({&JD}, Bar));
+  auto BarResult = cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), Bar));
   EXPECT_EQ(BarResult.getAddress(), BarSym.getAddress())
       << "Expected Bar == BarSym";
 }
@@ -685,7 +692,8 @@
     return SymbolNameSet({Bar});
   });
 
-  auto Result = cantFail(ES.lookup({&JD}, {Foo, Bar}));
+  auto Result =
+      cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), {Foo, Bar}));
 
   EXPECT_EQ(Result.count(Bar), 1U) << "Expected to find fallback def for 'bar'";
   EXPECT_EQ(Result[Bar].getAddress(), BarSym.getAddress())
@@ -701,7 +709,7 @@
   cantFail(JD.define(MU));
 
   SymbolNameSet Names({Foo, Bar});
-  auto Result = ES.lookup({&JD}, Names);
+  auto Result = ES.lookup(JITDylibSearchList({{&JD, false}}), Names);
 
   EXPECT_FALSE(!!Result) << "Expected failure";
   if (!Result) {
@@ -733,7 +741,8 @@
 
   cantFail(JD.define(MU));
 
-  auto FooLookupResult = cantFail(ES.lookup({&JD}, Foo));
+  auto FooLookupResult =
+      cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), Foo));
 
   EXPECT_EQ(FooLookupResult.getAddress(), FooSym.getAddress())
       << "lookup returned an incorrect address";
@@ -754,7 +763,8 @@
 
   cantFail(JD.define(absoluteSymbols({{Foo, FooSym}})));
 
-  auto FooLookupResult = cantFail(ES.lookup({&JD}, Foo));
+  auto FooLookupResult =
+      cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), Foo));
 
   EXPECT_EQ(FooLookupResult.getAddress(), FooSym.getAddress())
       << "lookup returned an incorrect address";
@@ -802,14 +812,16 @@
   EXPECT_FALSE(FooMaterialized) << "Foo should not be materialized yet";
   EXPECT_FALSE(BarMaterialized) << "Bar should not be materialized yet";
 
-  auto FooSymResult = cantFail(ES.lookup({&JD}, Foo));
+  auto FooSymResult =
+      cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), Foo));
   EXPECT_EQ(FooSymResult.getAddress(), FooSym.getAddress())
       << "Address mismatch for Foo";
 
   EXPECT_TRUE(FooMaterialized) << "Foo should be materialized now";
   EXPECT_FALSE(BarMaterialized) << "Bar still should not be materialized";
 
-  auto BarSymResult = cantFail(ES.lookup({&JD}, Bar));
+  auto BarSymResult =
+      cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), Bar));
   EXPECT_EQ(BarSymResult.getAddress(), BarSym.getAddress())
       << "Address mismatch for Bar";
   EXPECT_TRUE(BarMaterialized) << "Bar should be materialized now";
@@ -829,7 +841,7 @@
 
   cantFail(JD.define(MU));
 
-  auto Result = ES.lookup({&JD}, {Foo, Bar});
+  auto Result = ES.lookup(JITDylibSearchList({{&JD, false}}), {Foo, Bar});
 
   EXPECT_TRUE(!!Result) << "Result should be a success value";
   EXPECT_EQ(Result->count(Foo), 1U) << "\"Foo\" entry missing";
@@ -861,8 +873,8 @@
 
   auto OnReady = [](Error Err) { cantFail(std::move(Err)); };
 
-  ES.lookup({&JD}, {Foo}, std::move(OnResolution), std::move(OnReady),
-            NoDependenciesToRegister);
+  ES.lookup(JITDylibSearchList({{&JD, false}}), {Foo}, std::move(OnResolution),
+            std::move(OnReady), NoDependenciesToRegister);
 
   auto MU2 = llvm::make_unique<SimpleMaterializationUnit>(
       SymbolFlagsMap({{Foo, JITSymbolFlags::Exported}}),
diff --git a/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
index 1660670..6b1dbe9 100644
--- a/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
@@ -66,8 +66,8 @@
 
   ObjLayer.setProcessAllSections(ProcessAllSections);
   cantFail(ObjLayer.add(JD, std::move(Obj), ES.allocateVModule()));
-  ES.lookup({&JD}, {Foo}, OnResolveDoNothing, OnReadyDoNothing,
-            NoDependenciesToRegister);
+  ES.lookup(JITDylibSearchList({{&JD, false}}), {Foo}, OnResolveDoNothing,
+            OnReadyDoNothing, NoDependenciesToRegister);
   return DebugSectionSeen;
 }
 
@@ -157,7 +157,8 @@
   ObjLayer.setOverrideObjectFlagsWithResponsibilityFlags(true);
 
   cantFail(CompileLayer.add(JD, std::move(M), ES.allocateVModule()));
-  ES.lookup({&JD}, {Foo}, [](Expected<SymbolMap> R) { cantFail(std::move(R)); },
+  ES.lookup(JITDylibSearchList({{&JD, false}}), {Foo},
+            [](Expected<SymbolMap> R) { cantFail(std::move(R)); },
             [](Error Err) { cantFail(std::move(Err)); },
             NoDependenciesToRegister);
 }
@@ -219,7 +220,8 @@
   ObjLayer.setAutoClaimResponsibilityForObjectSymbols(true);
 
   cantFail(CompileLayer.add(JD, std::move(M), ES.allocateVModule()));
-  ES.lookup({&JD}, {Foo}, [](Expected<SymbolMap> R) { cantFail(std::move(R)); },
+  ES.lookup(JITDylibSearchList({{&JD, false}}), {Foo},
+            [](Expected<SymbolMap> R) { cantFail(std::move(R)); },
             [](Error Err) { cantFail(std::move(Err)); },
             NoDependenciesToRegister);
 }