[llvm] r312584 - [ORC] Convert null remote symbols to null JITSymbols.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 5 15:24:40 PDT 2017
Author: lhames
Date: Tue Sep 5 15:24:40 2017
New Revision: 312584
URL: http://llvm.org/viewvc/llvm-project?rev=312584&view=rev
Log:
[ORC] Convert null remote symbols to null JITSymbols.
The existing code created a JITSymbol with an invalid materializer instead,
guaranteeing a 'missing symbol' error when someone tried to materialize the
symbol.
Modified:
llvm/trunk/include/llvm/ExecutionEngine/Orc/RemoteObjectLayer.h
llvm/trunk/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp
Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/RemoteObjectLayer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/RemoteObjectLayer.h?rev=312584&r1=312583&r2=312584&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/RemoteObjectLayer.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/RemoteObjectLayer.h Tue Sep 5 15:24:40 2017
@@ -214,6 +214,9 @@ protected:
JITSymbol remoteToJITSymbol(Expected<RemoteSymbol> RemoteSymOrErr) {
if (RemoteSymOrErr) {
auto &RemoteSym = *RemoteSymOrErr;
+ if (RemoteSym == nullRemoteSymbol())
+ return nullptr;
+ // else...
RemoteSymbolMaterializer RSM(*this, RemoteSym.first);
auto Sym =
JITSymbol([RSM]() mutable { return RSM.materialize(); },
Modified: llvm/trunk/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp?rev=312584&r1=312583&r2=312584&view=diff
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp (original)
+++ llvm/trunk/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp Tue Sep 5 15:24:40 2017
@@ -334,7 +334,7 @@ TEST(RemoteObjectLayer, FindSymbol) {
auto ReportError =
[](Error Err) {
auto ErrMsg = toString(std::move(Err));
- EXPECT_EQ(ErrMsg, "Could not find symbol 'barbaz'")
+ EXPECT_EQ(ErrMsg, "Could not find symbol 'badsymbol'")
<< "Expected error string to be \"Object handle 42 not found\"";
};
@@ -352,7 +352,9 @@ TEST(RemoteObjectLayer, FindSymbol) {
[](StringRef Name, bool ExportedSymbolsOnly) -> JITSymbol {
if (Name == "foobar")
return JITSymbol(0x12348765, JITSymbolFlags::Exported);
- return make_error<JITSymbolNotFound>(Name);
+ if (Name == "badsymbol")
+ return make_error<JITSymbolNotFound>(Name);
+ return nullptr;
};
return 42;
});
@@ -374,19 +376,30 @@ TEST(RemoteObjectLayer, FindSymbol) {
cantFail(Client.addObject(std::move(TestObject),
std::make_shared<NullResolver>()));
+ // Check that we can find and materialize a valid symbol.
auto Sym1 = Client.findSymbol("foobar", true);
-
EXPECT_TRUE(!!Sym1) << "Symbol 'foobar' should be findable";
EXPECT_EQ(cantFail(Sym1.getAddress()), 0x12348765ULL)
<< "Symbol 'foobar' does not return the correct address";
- auto Sym2 = Client.findSymbol("barbaz", true);
- EXPECT_FALSE(!!Sym2) << "Symbol 'barbaz' should not be findable";
- auto Err = Sym2.takeError();
- EXPECT_TRUE(!!Err) << "Sym2 should contain an error value";
- auto ErrMsg = toString(std::move(Err));
- EXPECT_EQ(ErrMsg, "Could not find symbol 'barbaz'")
- << "Expected symbol-not-found error for Sym2";
+ {
+ // Check that we can return a symbol containing an error.
+ auto Sym2 = Client.findSymbol("badsymbol", true);
+ EXPECT_FALSE(!!Sym2) << "Symbol 'badsymbol' should not be findable";
+ auto Err = Sym2.takeError();
+ EXPECT_TRUE(!!Err) << "Sym2 should contain an error value";
+ auto ErrMsg = toString(std::move(Err));
+ EXPECT_EQ(ErrMsg, "Could not find symbol 'badsymbol'")
+ << "Expected symbol-not-found error for Sym2";
+ }
+
+ {
+ // Check that we can return a 'null' symbol.
+ auto Sym3 = Client.findSymbol("baz", true);
+ EXPECT_FALSE(!!Sym3) << "Symbol 'baz' should convert to false";
+ auto Err = Sym3.takeError();
+ EXPECT_FALSE(!!Err) << "Symbol 'baz' should not contain an error";
+ }
cantFail(ClientEP.callB<remote::utils::TerminateSession>());
ServerThread.join();
More information about the llvm-commits
mailing list