Switch to list all druntime calls?
bearophile via Digitalmars-d
digitalmars-d at puremagic.com
Wed May 21 16:32:40 PDT 2014
This shows one purpose of the ldc2 -noruntime switch. A simple
test program:
void foo(ref int[10] data) {
data[0 .. 3] = 5;
data[7 .. 9] = 10;
}
void main() {}
dmd compiles it to:
_D5test53fooFKG10iZv:
L0: push EAX
push 3
push 5
push EAX
call near ptr __memset32
push 2
push 0Ah
mov EAX,014h[ESP]
lea ECX,01Ch[EAX]
push ECX
call near ptr __memset32
add ESP,018h
pop EAX
ret
ldc2 is smarter and removes the calls to memset, generating kind
of optimal 32 bit code:
__D5test53fooFKG10iZv:
movl $5, (%eax)
movl $5, 4(%eax)
movl $5, 8(%eax)
movl $10, 28(%eax)
movl $10, 32(%eax)
ret
If you call such function many times you see a significant run
time difference between the two compilations.
A switch like -noruntime helps find the unwanted cases where the
compiler you are using doesn't remove some run time call.
Bye,
bearophile
More information about the Digitalmars-d
mailing list