Skip to content

Commit aff2c87

Browse files
committed
Don't place NRVO variables with nested refs in registers
1 parent af4bae4 commit aff2c87

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

compiler/src/dmd/glue/tocsym.d

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Symbol* toSymbol(Dsymbol s)
141141

142142
import dmd.common.outbuffer : OutBuffer;
143143
OutBuffer buf;
144-
bool isNRVO = false;
144+
bool isNRVO = vd.nrvo;
145145
const(char)[] id = vd.ident.toString();
146146
if (vd.isDataseg())
147147
{
@@ -277,7 +277,16 @@ Symbol* toSymbol(Dsymbol s)
277277
* dereferences.
278278
*/
279279
//printf("\tnested ref, not register\n");
280-
type_setcv(&t, t.Tty | mTYvolatile);
280+
FuncDeclaration fd = vd.toParent2().isFuncDeclaration();
281+
if (fd && vd.nrvo)
282+
{
283+
Symbol* shidden = cast(Symbol*)fd.shidden;
284+
type_setcv(&shidden.Stype, shidden.Stype.Tty | mTYvolatile);
285+
}
286+
else
287+
{
288+
type_setcv(&t, t.Tty | mTYvolatile);
289+
}
281290
}
282291
}
283292

0 commit comments

Comments
 (0)