DIP 1014:Hooking D's struct move semantics--Community Review Round 1

Shachar Shemesh shachar at weka.io
Thu May 17 19:11:27 UTC 2018


On 17/05/18 18:47, kinke wrote:
> On Thursday, 17 May 2018 at 15:23:50 UTC, kinke wrote:
>> See IR for https://run.dlang.io/is/1JIsk7.
> 
> I should probably emphasize that the LLVM `byval` attribute is strange 
> at first sight. Pseudo-IR `void foo(S* byval param); ... foo(S* byarg 
> arg);` doesn't mean that the IR callee gets the S* pointer from the IR 
> callsite; it means 'memcpy(param, arg, S.sizeof)', with `param` being an 
> *implicit* address in foo's parameters stack (calculated by LLVM and so 
> exposed to the callee only). That's the difficulty for LDC I mentioned 
> earlier.

I understand there might be difficulty, but I strongly protest the idea 
that it is not possible, for one very simple reason: C++.

class Movable {
   int member;

public:
   Movable();

   Movable( const Movable &rhs ); // Copy constructor
   Movable( Movable &&rhs ); // Move constructor
}

Since clang is able to compile this struct and do everything with it, 
and since the existence of the move constructor requires the precise 
same type of hooking as is needed in this case, I tend to believe that 
an IR representation of DIP 1014 is possible.

Shachar


More information about the Digitalmars-d mailing list