[llvm] r280016 - [ORC][RPC] Make the future type of an Orc RPC call Error/Expected rather than

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 29 23:10:58 PDT 2016


Hi Douglas,

Hopefully this should be fixed by r280058 and r280059.

Cheers,
Lang.

On Mon, Aug 29, 2016 at 7:40 PM, Lang Hames <lhames at gmail.com> wrote:

> Hi Yung,
>
> Bummer.
>
> At first glance this looks like a failure to construct a future for a type
> with no default constructor - is that your read? Do you know if MSVC 2013's
> futures library supports that?
>
> I'm on the road, but will be back in ~3 hours - when I get back I can try
> some workarounds for this. If that's too long for the builders, feel free
> to revert for now.
>
> - Lang.
>
>
> On Mon, Aug 29, 2016 at 5:44 PM, Yung, Douglas <douglas.yung at sony.com>
> wrote:
>
>> Hi Lang,
>>
>> I believe your checkin caused the Windows build to break when compiling
>> with Visual Studio 2013. When building your change, I am seeing the
>> following errors:
>>
>> C:\Program Files (x86)\Microsoft Visual Studio
>> 12.0\VC\include\future(294): error C2512: 'llvm::Expected<int>' : no
>> appropriate default constructor available [C:\src\build\tools\lli\lli.vc
>> xproj]
>>           C:\Program Files (x86)\Microsoft Visual Studio
>> 12.0\VC\include\future(286) : while compiling class template member
>> function 'std::_Associated_state<_Ty>::_Associated_state(std::_Deleter_base<_Ty>
>> *)'
>>           with
>>           [
>>               _Ty=llvm::Expected<int>
>>           ]
>>           C:\Program Files (x86)\Microsoft Visual Studio
>> 12.0\VC\include\future(1481) : see reference to function template
>> instantiation 'std::_Associated_state<_Ty>::
>> _Associated_state(std::_Deleter_base<_Ty> *)' being compiled
>>           with
>>           [
>>               _Ty=llvm::Expected<int>
>>           ]
>>           C:\Program Files (x86)\Microsoft Visual Studio
>> 12.0\VC\include\future(1018) : see reference to class template
>> instantiation 'std::_Associated_state<_Ty>' being compiled
>>           with
>>           [
>>               _Ty=llvm::Expected<int>
>>           ]
>>           C:\Program Files (x86)\Microsoft Visual Studio
>> 12.0\VC\include\future(1014) : while compiling class template member
>> function 'llvm::Expected<int> &std::_State_manager<_Ty>::_Get_value(void)
>> const'
>>           with
>>           [
>>               _Ty=llvm::Expected<int>
>>           ]
>>           C:\Program Files (x86)\Microsoft Visual Studio
>> 12.0\VC\include\future(1132) : see reference to function template
>> instantiation 'llvm::Expected<int> &std::_State_manager<_Ty>::_Get_value(void)
>> const' being compiled
>>           with
>>           [
>>               _Ty=llvm::Expected<int>
>>           ]
>>           C:\Program Files (x86)\Microsoft Visual Studio
>> 12.0\VC\include\future(1101) : see reference to class template
>> instantiation 'std::_State_manager<_Ty>' being compiled
>>           with
>>           [
>>               _Ty=llvm::Expected<int>
>>           ]
>>           C:\Program Files (x86)\Microsoft Visual Studio
>> 12.0\VC\include\utility(198) : see reference to class template
>> instantiation 'std::future<llvm::Expected<int>>' being compiled
>>           C:\src\llvm\include\llvm/Support/AlignOf.h(224) : see
>> reference to class template instantiation 'std::pair<std::future<llvm::E
>> xpected<int>>,SequenceNumberT>' being compiled
>>           with
>>           [
>>               SequenceNumberT=uint16_t
>>           ]
>>           C:\Program Files (x86)\Microsoft Visual Studio
>> 12.0\VC\include\type_traits(584) : see reference to class template
>> instantiation 'llvm::detail::AlignerImpl<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>'
>> being compiled
>>           with
>>           [
>>               T1=std::pair<std::future<llvm::Expected<int>>,uint16_t>
>>   ,            T2=char
>>   ,            T3=char
>>   ,            T4=char
>>   ,            T5=char
>>   ,            T6=char
>>   ,            T7=char
>>   ,            T8=char
>>   ,            T9=char
>>   ,            T10=char
>>           ]
>>           C:\src\llvm\include\llvm/Support/AlignOf.h(83) : see reference
>> to class template instantiation 'std::is_abstract<T>' being compiled
>>           with
>>           [
>>               T=llvm::detail::AlignerImpl<st
>> d::pair<std::future<llvm::Expected<int>>,uint16_t>,char,char
>> ,char,char,char,char,char,char,char>
>>           ]
>>           C:\src\llvm\include\llvm/Support/AlignOf.h(253) : see
>> reference to class template instantiation 'llvm::AlignOf<llvm::detail::A
>> lignerImpl<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>>' being compiled
>>   Building Custom Rule C:/src/llvm/tools/clang/tools/
>> arcmt-test/CMakeLists.txt
>>           with
>>           [
>>               T1=std::pair<std::future<llvm::Expected<int>>,uint16_t>
>>   ,            T2=char
>>   ,            T3=char
>>   ,            T4=char
>>   ,            T5=char
>>   ,            T6=char
>>   ,            T7=char
>>   ,            T8=char
>>   ,            T9=char
>>   ,            T10=char
>>           ]
>>           C:\src\llvm\include\llvm/Support/Error.h(831) : see reference
>> to class template instantiation 'llvm::AlignedCharArrayUnion<s
>> td::pair<std::future<llvm::Expected<int>>,SequenceNumberT>,
>> char,char,char,char,char,char,char,char,char>' being compiled
>>           with
>>           [
>>   CMake does not need to re-run because C:\src\build\tools\clang\tools
>> \arcmt-test\CMakeFiles\generate.stamp is up-to-date.
>>               SequenceNumberT=uint16_t
>>           ]
>>           c:\src\llvm\include\llvm\executionengine\orc\RPCUtils.h(447) :
>> see reference to class template instantiation 'llvm::Expected<std::pair<std:
>> :future<llvm::Expected<int>>,SequenceNumberT>>' being compiled
>>           with
>>           [
>>               SequenceNumberT=uint16_t
>>           ]
>>           C:\src\llvm\include\llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h(606)
>> : see reference to function template instantiation 'llvm::Expected<int>
>> llvm::orc::remote::RPC<llvm::orc::remote::RPCChannel,uint32_
>> t,uint16_t>::callSTHandling<llvm::orc::remote::OrcRemoteTargetRPCAPI::
>> CallIntVoid,llvm::orc::remote::OrcRemoteTargetClient<llvm::
>> orc::remote::RPCChannel>::callIntVoid::<lambda_1e43ba3f7
>> 6d819646569b43fe46505bc>,llvm::JITTargetAddress>(ChannelT &,HandleFtor
>> &,const llvm::JITTargetAddress &)' being compiled
>>           with
>>           [
>>               ChannelT=llvm::orc::remote::RPCChannel
>>   ,            HandleFtor=llvm::orc::remote::
>> OrcRemoteTargetClient<llvm::orc::remote::RPCChannel>::callIn
>> tVoid::<lambda_1e43ba3f76d819646569b43fe46505bc>
>>           ]
>>           C:\src\llvm\include\llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h(606)
>> : see reference to function template instantiation 'llvm::Expected<int>
>> llvm::orc::remote::RPC<llvm::orc::remote::RPCChannel,uint32_
>> t,uint16_t>::callSTHandling<llvm::orc::remote::OrcRemoteTargetRPCAPI::
>> CallIntVoid,llvm::orc::remote::OrcRemoteTargetClient<llvm::
>> orc::remote::RPCChannel>::callIntVoid::<lambda_1e43ba3f7
>> 6d819646569b43fe46505bc>,llvm::JITTargetAddress>(ChannelT &,HandleFtor
>> &,const llvm::JITTargetAddress &)' being compiled
>>           with
>>           [
>>               ChannelT=llvm::orc::remote::RPCChannel
>>   ,            HandleFtor=llvm::orc::remote::
>> OrcRemoteTargetClient<llvm::orc::remote::RPCChannel>::callIn
>> tVoid::<lambda_1e43ba3f76d819646569b43fe46505bc>
>>           ]
>>           C:\src\llvm\include\llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h(600)
>> : while compiling class template member function 'llvm::Expected<int>
>> llvm::orc::remote::OrcRemoteTargetClient<llvm::orc::remote::
>> RPCChannel>::callIntVoid(llvm::JITTargetAddress)'
>>           C:\src\llvm\tools\lli\lli.cpp(694) : see reference to function
>> template instantiation 'llvm::Expected<int> llvm::orc::remote::OrcRemoteTa
>> rgetClient<llvm::orc::remote::RPCChannel>::callIntVoid(llvm::JITTargetAddress)'
>> being compiled
>>           C:\src\llvm\tools\lli\lli.cpp(666) : see reference to class
>> template instantiation 'llvm::orc::remote::OrcRemoteT
>> argetClient<llvm::orc::remote::RPCChannel>' being compiled
>>   OrcLazyJIT.cpp
>>
>>
>> Can you take a look into this?
>>
>> Douglas Yung
>>
>> > -----Original Message-----
>> > From: llvm-commits [mailto:llvm-commits-bounces at lists.llvm.org] On
>> > Behalf Of Lang Hames via llvm-commits
>> > Sent: Monday, August 29, 2016 14:57
>> > To: llvm-commits at lists.llvm.org
>> > Subject: [llvm] r280016 - [ORC][RPC] Make the future type of an Orc RPC
>> > call Error/Expected rather than
>> >
>> > Author: lhames
>> > Date: Mon Aug 29 16:56:30 2016
>> > New Revision: 280016
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=280016&view=rev
>> > Log:
>> > [ORC][RPC] Make the future type of an Orc RPC call Error/Expected
>> > rather than Optional.
>> >
>> > For void functions the return type of a nonblocking call changes from
>> > Expected<future<Optional<bool>>> to Expected<future<Error>>, and for
>> > functions returning T the return type changes from
>> > Expected<future<Optional<T>>> to Expected<future<Expected<T>>>.
>> >
>> > Inner results need to be checked (since the RPC connection may have
>> > dropped out before a result came back) and Error/Expected provide
>> > stronger checking requirements. It also allows us drop the crufty
>> > 'optionalToError' function and just collapse Errors in the single-
>> > threaded call primitives.
>> >
>> >
>> > Modified:
>> >     llvm/trunk/include/llvm/ExecutionEngine/Orc/RPCUtils.h
>> >     llvm/trunk/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp
>> >
>> > Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/RPCUtils.h
>> > URL: http://llvm.org/viewvc/llvm-
>> > project/llvm/trunk/include/llvm/ExecutionEngine/Orc/RPCUtils.h?rev=2800
>> > 16&r1=280015&r2=280016&view=diff
>> > =======================================================================
>> > =======
>> > --- llvm/trunk/include/llvm/ExecutionEngine/Orc/RPCUtils.h (original)
>> > +++ llvm/trunk/include/llvm/ExecutionEngine/Orc/RPCUtils.h Mon Aug 29
>> > +++ 16:56:30 2016
>> > @@ -17,7 +17,6 @@
>> >  #include <map>
>> >  #include <vector>
>> >
>> > -#include "llvm/ADT/Optional.h"
>> >  #include "llvm/ADT/STLExtras.h"
>> >  #include "llvm/ExecutionEngine/Orc/OrcError.h"
>> >
>> > @@ -61,6 +60,7 @@ public:
>> >  // partially specialized.
>> >  class RPCBase {
>> >  protected:
>> > +
>> >    // RPC Function description type.
>> >    //
>> >    // This class provides the information and operations needed to
>> > support the @@ -69,10 +69,7 @@ protected:
>> >    // betwen the two. Both specializations have the same interface:
>> >    //
>> >    // Id - The function's unique identifier.
>> > -  // OptionalReturn - The return type for asyncronous calls.
>> > -  // ErrorReturn - The return type for synchronous calls.
>> > -  // optionalToErrorReturn - Conversion from a valid OptionalReturn to
>> > an
>> > -  //                         ErrorReturn.
>> > +  // ErrorReturn - The return type for blocking calls.
>> >    // readResult - Deserialize a result from a channel.
>> >    // abandon - Abandon a promised (asynchronous) result.
>> >    // respond - Retun a result on the channel.
>> > @@ -91,32 +88,25 @@ protected:
>> >
>> >      static const FunctionIdT Id = FuncId;
>> >
>> > -    typedef Optional<RetT> OptionalReturn;
>> > -
>> >      typedef Expected<RetT> ErrorReturn;
>> >
>> > -    static ErrorReturn optionalToErrorReturn(OptionalReturn &&V) {
>> > -      assert(V && "Return value not available");
>> > -      return std::move(*V);
>> > -    }
>> > -
>> >      template <typename ChannelT>
>> > -    static Error readResult(ChannelT &C, std::promise<OptionalReturn>
>> > &P) {
>> > +    static Error readResult(ChannelT &C, std::promise<ErrorReturn> &P)
>> > + {
>> >        RetT Val;
>> >        auto Err = deserialize(C, Val);
>> >        auto Err2 = endReceiveMessage(C);
>> >        Err = joinErrors(std::move(Err), std::move(Err2));
>> > -
>> > -      if (Err) {
>> > -        P.set_value(OptionalReturn());
>> > +      if (Err)
>> >          return Err;
>> > -      }
>> > +
>> >        P.set_value(std::move(Val));
>> >        return Error::success();
>> >      }
>> >
>> > -    static void abandon(std::promise<OptionalReturn> &P) {
>> > -      P.set_value(OptionalReturn());
>> > +    static void abandon(std::promise<ErrorReturn> &P) {
>> > +      P.set_value(
>> > +        make_error<StringError>("RPC function call failed to return",
>> > +                                inconvertibleErrorCode()));
>> >      }
>> >
>> >      template <typename ChannelT, typename SequenceNumberT> @@ -148,22
>> > +138,20 @@ protected:
>> >
>> >      static const FunctionIdT Id = FuncId;
>> >
>> > -    typedef bool OptionalReturn;
>> >      typedef Error ErrorReturn;
>> >
>> > -    static ErrorReturn optionalToErrorReturn(OptionalReturn &&V) {
>> > -      assert(V && "Return value not available");
>> > -      return Error::success();
>> > -    }
>> > -
>> >      template <typename ChannelT>
>> > -    static Error readResult(ChannelT &C, std::promise<OptionalReturn>
>> > &P) {
>> > +    static Error readResult(ChannelT &C, std::promise<ErrorReturn> &P)
>> > + {
>> >        // Void functions don't have anything to deserialize, so we're
>> > good.
>> > -      P.set_value(true);
>> > +      P.set_value(Error::success());
>> >        return endReceiveMessage(C);
>> >      }
>> >
>> > -    static void abandon(std::promise<OptionalReturn> &P) {
>> > P.set_value(false); }
>> > +    static void abandon(std::promise<ErrorReturn> &P) {
>> > +      P.set_value(
>> > +        make_error<StringError>("RPC function call failed to return",
>> > +                                inconvertibleErrorCode()));
>> > +    }
>> >
>> >      template <typename ChannelT, typename SequenceNumberT>
>> >      static Error respond(ChannelT &C, SequenceNumberT SeqNo, @@ -
>> > 380,17 +368,17 @@ public:
>> >
>> >    /// Return type for asynchronous call primitives.
>> >    template <typename Func>
>> > -  using AsyncCallResult = std::future<typename Func::OptionalReturn>;
>> > +  using AsyncCallResult = std::future<typename Func::ErrorReturn>;
>> >
>> >    /// Return type for asynchronous call-with-seq primitives.
>> >    template <typename Func>
>> >    using AsyncCallWithSeqResult =
>> > -      std::pair<std::future<typename Func::OptionalReturn>,
>> > SequenceNumberT>;
>> > +      std::pair<AsyncCallResult<Func>, SequenceNumberT>;
>> >
>> >    /// Serialize Args... to channel C, but do not call C.send().
>> >    ///
>> >    /// Returns an error (on serialization failure) or a pair of:
>> > -  /// (1) A future Optional<T> (or future<bool> for void functions),
>> > and
>> > +  /// (1) A future Expected<T> (or future<bool> for void functions),
>> > + and
>> >    /// (2) A sequence number.
>> >    ///
>> >    /// This utility function is primarily used for single-threaded mode
>> > support, @@ -401,7 +389,7 @@ public:
>> >    Expected<AsyncCallWithSeqResult<Func>>
>> >    appendCallAsyncWithSeq(ChannelT &C, const ArgTs &... Args) {
>> >      auto SeqNo = SequenceNumberMgr.getSequenceNumber();
>> > -    std::promise<typename Func::OptionalReturn> Promise;
>> > +    std::promise<typename Func::ErrorReturn> Promise;
>> >      auto Result = Promise.get_future();
>> >      OutstandingResults[SeqNo] =
>> >          createOutstandingResult<Func>(std::move(Promise));
>> > @@ -431,7 +419,7 @@ public:
>> >
>> >    /// Serialize Args... to channel C, but do not call send.
>> >    /// Returns an error if serialization fails, otherwise returns a
>> > -  /// std::future<Optional<T>> (or a future<bool> for void functions).
>> > +  /// std::future<Expected<T>> (or a future<bool> for void functions).
>> >    template <typename Func, typename... ArgTs>
>> >    Expected<AsyncCallResult<Func>> appendCallAsync(ChannelT &C,
>> >                                                    const ArgTs &...
>> > Args) { @@ -460,7 +448,7 @@ public:
>> >        auto &ResultAndSeqNo = *ResultAndSeqNoOrErr;
>> >        if (auto Err = waitForResult(C, ResultAndSeqNo.second,
>> > HandleOther))
>> >          return std::move(Err);
>> > -      return Func::optionalToErrorReturn(ResultAndSeqNo.first.get());
>> > +      return ResultAndSeqNo.first.get();
>> >      } else
>> >        return ResultAndSeqNoOrErr.takeError();
>> >    }
>> > @@ -656,7 +644,7 @@ private:
>> >    class OutstandingResultImpl : public OutstandingResult {
>> >    private:
>> >    public:
>> > -    OutstandingResultImpl(std::promise<typename Func::OptionalReturn>
>> > &&P)
>> > +    OutstandingResultImpl(std::promise<typename Func::ErrorReturn>
>> > &&P)
>> >          : P(std::move(P)) {}
>> >
>> >      Error readResult(ChannelT &C) override { return
>> > Func::readResult(C, P); } @@ -664,13 +652,13 @@ private:
>> >      void abandon() override { Func::abandon(P); }
>> >
>> >    private:
>> > -    std::promise<typename Func::OptionalReturn> P;
>> > +    std::promise<typename Func::ErrorReturn> P;
>> >    };
>> >
>> >    // Create an outstanding result for the given function.
>> >    template <typename Func>
>> >    std::unique_ptr<OutstandingResult>
>> > -  createOutstandingResult(std::promise<typename Func::OptionalReturn>
>> > &&P) {
>> > +  createOutstandingResult(std::promise<typename Func::ErrorReturn>
>> > &&P)
>> > + {
>> >      return
>> > llvm::make_unique<OutstandingResultImpl<Func>>(std::move(P));
>> >    }
>> >
>> >
>> > Modified: llvm/trunk/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp
>> > URL: http://llvm.org/viewvc/llvm-
>> > project/llvm/trunk/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp?rev=2
>> > 80016&r1=280015&r2=280016&view=diff
>> > =======================================================================
>> > =======
>> > --- llvm/trunk/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp
>> > (original)
>> > +++ llvm/trunk/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp Mon Aug
>> > 29
>> > +++ 16:56:30 2016
>> > @@ -102,8 +102,8 @@ TEST_F(DummyRPC, TestAsyncVoidBool) {
>> >    }
>> >
>> >    // Verify that the function returned ok.
>> > -  auto Val = ResOrErr->first.get();
>> > -  EXPECT_TRUE(Val) << "Remote void function failed to execute.";
>> > +  auto Err = ResOrErr->first.get();
>> > +  EXPECT_TRUE(!!Err) << "Remote void function failed to execute.";
>> >  }
>> >
>> >  TEST_F(DummyRPC, TestAsyncIntInt) {
>> > @@ -179,8 +179,8 @@ TEST_F(DummyRPC, TestSerialization) {
>> >    }
>> >
>> >    // Verify that the function returned ok.
>> > -  auto Val = ResOrErr->first.get();
>> > -  EXPECT_TRUE(Val) << "Remote void function failed to execute.";
>> > +  auto Err = ResOrErr->first.get();
>> > +  EXPECT_TRUE(!!Err) << "Remote void function failed to execute.";
>> >  }
>> >
>> >  // Test the synchronous call API.
>> >
>> >
>> > _______________________________________________
>> > llvm-commits mailing list
>> > llvm-commits at lists.llvm.org
>> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160829/62b5aa12/attachment.html>


More information about the llvm-commits mailing list