[Issue 6904] New: Skip Setting up Stack Frame if No Stack is Used
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Nov 7 10:06:16 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6904
Summary: Skip Setting up Stack Frame if No Stack is Used
Product: D
Version: D2
Platform: Other
OS/Version: Windows
Status: NEW
Keywords: performance
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: dsimcha at yahoo.com
--- Comment #0 from David Simcha <dsimcha at yahoo.com> 2011-11-07 10:05:40 PST ---
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
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list