Issue 8615 - Unused lazy arguments generate redundant code in empty inlined functions
Summary: Unused lazy arguments generate redundant code in empty inlined functions
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Mac OS X
: P2 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-03 13:32 UTC by Peter Alexander
Modified: 2020-03-21 03:56 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Peter Alexander 2012-09-03 13:32:12 UTC
% cat test.d
void foo(lazy ulong x) {}
void main(string[] args)
{
	foo(args.length);
}

admin@poita ~% dmd -inline -O -release test.d
admin@poita ~% otool -tV test | grep __Dmain: -A 9
__Dmain:
0000000100000dac	pushq	%rbp
0000000100000dad	movq	%rsp,%rbp
0000000100000db0	subq	$0x10,%rsp
0000000100000db4	movq	%rdi,0xf0(%rbp)
0000000100000db8	movq	%rsi,0xf8(%rbp)
0000000100000dbc	xorl	%eax,%eax
0000000100000dbe	movq	%rbp,%rsp
0000000100000dc1	popq	%rbp
0000000100000dc2	ret

Notice the redundant movq's. They aren't there when the parameter isn't lazy.

Ideally, this empty function would have no effect on the generated code.

Tested using DMD 2.060
Comment 1 basile-z 2020-02-20 15:01:44 UTC
fixed see, https://godbolt.org/z/3P_PtD