Bug 14133 – change in struct ctor lowering generates excessive init code

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-02-06T13:54:27Z
Last change time
2024-12-13T18:40:05Z
Keywords
backend, performance
Assigned to
No Owner
Creator
Kenji Hara
Moved to GitHub: dmd#18943 →

Comments

Comment #0 by k.hara.pg — 2015-02-06T13:54:27Z
Spin-off issue from: https://issues.dlang.org/show_bug.cgi?id=13952 > The amount of code generated for the constructor is still worrisome. > Especially the part that initializes X86Reg, because it initializes every field individually, it constructs a temporary on the stack only to end up loading zero into edx.
Comment #1 by code — 2015-03-20T01:20:23Z
cat > bug.d << CODE struct Bug { size_t[16 * 1024] data; } void test() { auto b = Bug(); } CODE ---- dmd -c bug ---- It looks like related to issue 11233, but is most likely due to the change struct literal code, that not performs field assignment instead of copying the init array.
Comment #2 by code — 2015-03-20T01:24:52Z
mov %eax,-0x20000(%rbp) mov %eax,-0x1fffc(%rbp) mov %eax,-0x1fff8(%rbp) ... mov %ecx,-0x1f804(%rbp) xor %edx,%edx // Why edx all of a sudden? mov %edx,-0x1f800(%rbp) ... mov %edx,-0xc(%rbp) mov %edx,-0x8(%rbp) mov %edx,-0x4(%rbp) In total 32768 4-byte assignments to initialize the struct.
Comment #3 by code — 2015-03-20T01:27:11Z
Comment #4 by code — 2015-03-20T14:59:36Z
There is a 2nd variation of this bug. Even when assigning an better sinit symbol, it is deleted for assignments. This was added with a fix for issue 7502. No clue why https://github.com/D-Programming-Language/dmd/commit/3f88f156879841ef79162916b2dbbf28e2a1fcc3?diff=unified#diff-6e3ab8a500e476994f345ede433811bbR3538. cat > bug.d << CODE struct Bug { size_t[16 * 1024] data; } void test() { Bug b; b = Bug(); } CODE ---- dmd -c bug ----
Comment #5 by code — 2015-03-20T15:08:54Z
Comment #6 by github-bugzilla — 2015-03-22T04:56:58Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/99dab7d640db15b8ee8ade1ad1430298884e013f Partial fix for issue 14133 - generate precise fillHoles code for struct literal expression https://github.com/D-Programming-Language/dmd/commit/ce11286e21f54b07675ce4abe116a83c931f94c6 Merge pull request #4508 from 9rnsr/fix14133 [REG2.067a] Partial fix for issue 14133 - generate precise fillHoles code for struct literal expression
Comment #7 by github-bugzilla — 2015-03-22T05:03:13Z
Commit pushed to 2.067 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/9d8ebb2f3a146b1e4fb4d125e36c7514cde420cb Merge pull request #4508 from 9rnsr/fix14133 [REG2.067a] Partial fix for issue 14133 - generate precise fillHoles code for struct literal expression
Comment #8 by k.hara.pg — 2015-03-22T05:14:46Z
The issue case in comment #4 will be fixed in 2.067 release, so change back the importance to "normal".
Comment #9 by github-bugzilla — 2015-04-11T12:25:13Z
Comment #10 by github-bugzilla — 2015-06-17T21:02:37Z
Commits pushed to stable at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/99dab7d640db15b8ee8ade1ad1430298884e013f Partial fix for issue 14133 - generate precise fillHoles code for struct literal expression https://github.com/D-Programming-Language/dmd/commit/ce11286e21f54b07675ce4abe116a83c931f94c6 Merge pull request #4508 from 9rnsr/fix14133
Comment #11 by robert.schadek — 2024-12-13T18:40:05Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18943 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB