mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-04-28 22:21:31 +03:00
Let special __result variable be an alias for sret
So for functions using sret and featuring an out contract, we save an additional alloca + memcpy by using the sret pointer as storage.
This commit is contained in:
parent
1760e261db
commit
12ff7ef803
2 changed files with 22 additions and 2 deletions
|
@ -884,8 +884,9 @@ void DtoVarDeclaration(VarDeclaration *vd) {
|
|||
|
||||
if (isIrLocalCreated(vd)) {
|
||||
// Nothing to do if it has already been allocated.
|
||||
} else if (gIR->func()->sretArg && gIR->func()->decl->nrvo_can &&
|
||||
gIR->func()->decl->nrvo_var == vd) {
|
||||
} else if (gIR->func()->sretArg && ((gIR->func()->decl->nrvo_can &&
|
||||
gIR->func()->decl->nrvo_var == vd) ||
|
||||
vd->isResult())) {
|
||||
// Named Return Value Optimization (NRVO):
|
||||
// T f() {
|
||||
// T ret; // &ret == hidden pointer
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue