[GSoC 2019] Interested in Baremetal D Runtime and project ideas
Stefanos Baziotis
sdi1600105 at di.uoa.gr
Wed Apr 10 12:25:55 UTC 2019
On Wednesday, 10 April 2019 at 00:05:16 UTC, Mike Franklin wrote:
> Yes, looking at the asm would be a good way to confirm it. I
> haven't done that, and I'm mostly relying on rumor, but here's
> some evidence:
> https://github.com/dlang/dmd/blob/e3cb9363bff55170624667fb819289aceccdc90d/src/dmd/backend/cod2.d#L3395-L3399
Yes, it's interesting. Well, unfortunately it needs a lot of time
to understand
the backend enough to track whether it actually replaces it.
However, I made a simple test case:
import core.stdc.string;
extern(C) void main() {
int a = 5;
int b = 5;
memcmp(&a, &b, int.sizeof);
}
which is a test case that should definitely be inlined.
Compiled with -betterC -g -O -release -inline, there is an actual
call:
lea rsi,[rbp-0x4]
lea rdi,[rbp-0x8]
call 0x400640 <memcmp at plt>
and the code inside the call is what I would expect for a full
memcmp.
I used -betterC because it makes smaller executables and makes it
easy to
inspect on GDB. Maybe without it, dmd inlines it in some way
although I doubt it.
Also, maybe LDC and GDC do something clever, but I don't have
available right now either
of them.
More information about the Digitalmars-d
mailing list