[ORC] Add findSymbolIn() wrapper to C bindings, take #2.

Re-appply r333147, reverted in r333152 due to a pre-existing bug. As
D47308 has been merged in r333206, the OSX issue should now be
resolved.

In many cases JIT users will know in which module a symbol
resides. Avoiding to search other modules can be more efficient. It
also allows to handle duplicate symbol names between modules.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D44889

llvm-svn: 333215
diff --git a/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp b/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp
index fe3f694..b288b6b 100644
--- a/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp
@@ -98,12 +98,26 @@
 
   LLVMOrcModuleHandle H;
   LLVMOrcAddEagerlyCompiledIR(JIT, &H, wrap(M.release()), myResolver, nullptr);
-  LLVMOrcTargetAddress MainAddr;
-  LLVMOrcGetSymbolAddress(JIT, &MainAddr, "main");
-  MainFnTy MainFn = (MainFnTy)MainAddr;
-  int Result = MainFn();
-  EXPECT_EQ(Result, 42)
-    << "Eagerly JIT'd code did not return expected result";
+
+  // get symbol address searching the entire stack
+  {
+    LLVMOrcTargetAddress MainAddr;
+    LLVMOrcGetSymbolAddress(JIT, &MainAddr, "main");
+    MainFnTy MainFn = (MainFnTy)MainAddr;
+    int Result = MainFn();
+    EXPECT_EQ(Result, 42)
+      << "Eagerly JIT'd code did not return expected result";
+  }
+
+  // and then just searching a single handle
+  {
+    LLVMOrcTargetAddress MainAddr;
+    LLVMOrcGetSymbolAddressIn(JIT, &MainAddr, H, "main");
+    MainFnTy MainFn = (MainFnTy)MainAddr;
+    int Result = MainFn();
+    EXPECT_EQ(Result, 42)
+      << "Eagerly JIT'd code did not return expected result";
+  }
 
   LLVMOrcRemoveModule(JIT, H);