October 20, 2024 [Issue 24822] New: When passing a non-POD argument to an rvalue parameter, an unnecessary blit is done | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24822 Issue ID: 24822 Summary: When passing a non-POD argument to an rvalue parameter, an unnecessary blit is done Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: bugzilla@digitalmars.com Consider: struct S { int i; this(ref S); void opAssign(S s) { i = s.i + 1; } } void test() { S s; S t; t = s; // call to opAssign } The generated code for test() is: 0000: 55 push RBP 0001: 48 8B EC mov RBP,RSP 0004: 48 83 EC 10 sub RSP,010h 0008: 31 C0 xor EAX,EAX 000a: 89 45 F0 mov -010h[RBP],EAX 000d: 89 45 F4 mov -0Ch[RBP],EAX 0010: 89 45 F8 mov -8[RBP],EAX 0013: 48 8D 75 F0 lea RSI,-010h[RBP] 0017: 48 8D 7D F8 lea RDI,-8[RBP] 001b: E8 00 00 00 00 call __ctor 0020: 48 8D 75 F8 lea RSI,-8[RBP] 0024: 48 8D 7D FC lea RDI,-4[RBP] 0028: A5 movsd // blit copy, should not be here 0029: 48 8D 75 FC lea RSI,-4[RBP] 002d: 48 8D 7D F4 lea RDI,-0Ch[RBP] 0031: E8 00 00 00 00 call L0 0036: C9 leave 0037: C3 ret The blit copy is redundant and should not be generated. -- |
Copyright © 1999-2021 by the D Language Foundation