Bug 6904 – Skip Setting up Stack Frame if No Stack is Used

Status
RESOLVED
Resolution
WORKSFORME
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-11-07T10:05:00Z
Last change time
2017-06-25T12:14:14Z
Keywords
bootcamp, performance
Assigned to
nobody
Creator
dsimcha
See also
https://issues.dlang.org/show_bug.cgi?id=15121

Comments

Comment #0 by dsimcha — 2011-11-07T10:05:40Z
This could affect performance slightly in real-world code if virtual functions are used to return constants in some overrides. test.d: int main() { return 0; } dmd -c -O -inline -release test.d Disassembly of _Dmain in test.o: _Dmain PROC push rbp ; 0000 _ 55 mov rbp, rsp ; 0001 _ 48: 8B. EC xor eax, eax ; 0004 _ 31. C0 pop rbp ; 0006 _ 5D ret ; 0007 _ C3 _Dmain ENDP Do we really need to do the push rbp; mov rbp, rsp; pop rbp when the function doesn't actually use any stack and just sets eax to zero and returns? GDC elides these extra instructions. In GDC, compiled with -O1 or higher, _Dmain's body is: _Dmain PROC xor eax, eax ; 0000 _ 31. C0 ret ; 0002 _ C3 _Dmain ENDP
Comment #1 by dlang-bugzilla — 2017-06-25T12:14:14Z
I believe this was fixed by this pull request: https://github.com/dlang/dmd/pull/5040