Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NRVO doesn't happen when return type contains an array #137

Open
timotheecour opened this issue Apr 27, 2020 · 0 comments
Open

NRVO doesn't happen when return type contains an array #137

timotheecour opened this issue Apr 27, 2020 · 0 comments

Comments

@timotheecour
Copy link
Owner

NRVO doesn't happen when return type contains an array

Example

when defined case7: # D20200427T030626
  type X1 = object
    a1: array[10,int] # no NRVO
  type X2 = object
    a2: seq[int] # NRVO
  proc fun1(): X1 = discard
  proc fun2(): X2 = discard
  proc main =
    var x1 = fun1()
    var x2 = fun2()
  main()

Current Output

cgen'd file shows:

N_LIB_PRIVATE N_NIMCALL(void, main__Txk9aMBuTQfWSxCVsnz9cpLw)(void) {
	tyObject_X1__8Rt52S9caw66JoaF6ps17vQ x1;
	tyObject_X2__HENPt9b0VcoiqRd762A4dqg x2;
	x1 = fun1__Mn2tcNiI7WmB3YthDb2xNA();
	nimZeroMem((void*)(&x2), sizeof(tyObject_X2__HENPt9b0VcoiqRd762A4dqg));
	fun2__opw8oBRugVywaf9af9cJzLnA((&x2));
}

Expected Output

x1 = fun1__Mn2tcNiI7WmB3YthDb2xNA();
should be:
fun1__Mn2tcNiI7WmB3YthDb2xNA(&1);

Possible Solution

Additional Information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant