[PATCH] Fix LD_DEBUG=statistics on x86-64
Jakub Jelinek
jakub@redhat.com
Wed Mar 17 12:52:00 GMT 2004
Hi!
17214: runtime linker statistics:
17214: total startup time in dynamic loader: 12434 clock cycles
17214: time needed for relocation: 280243 clock cycles (%)
17214: number of relocations: 98
17214: number of relocations from cache: 3
17214: number of relative relocations: 1286
17214: time needed to load objects: 0 clock cycles (.0%)
certainly doesn't look correct.
The problem is that without volatile in the rdtsc asm GCC happily merges
HP_TIMING_NOW (start);
call something
HP_TIMING_NOW (stop);
so that stop == start (rdtsc done only before the call).
17232: runtime linker statistics:
17232: total startup time in dynamic loader: 733738 clock cycles
17232: time needed for relocation: 278644 clock cycles (37.9%)
17232: number of relocations: 83
17232: number of relocations from cache: 3
17232: number of relative relocations: 1295
17232: time needed to load objects: 326662 clock cycles (44.5%)
looks better.
2004-03-17 Jakub Jelinek <jakub@redhat.com>
* sysdeps/x86_64/hp-timing.h (HP_TIMING_NOW): Make asm volatile.
--- libc/sysdeps/x86_64/hp-timing.h.jj 2002-08-31 01:09:29.000000000 +0200
+++ libc/sysdeps/x86_64/hp-timing.h 2004-03-17 13:26:02.139127766 +0100
@@ -1,5 +1,5 @@
/* High precision, low overhead timing functions. x86-64 version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -25,7 +25,8 @@
/* The "=A" constraint used in 32-bit mode does not work in 64-bit mode. */
# undef HP_TIMING_NOW
# define HP_TIMING_NOW(Var) \
- ({ unsigned int _hi, _lo; asm ("rdtsc" : "=a" (_lo), "=d" (_hi)); \
+ ({ unsigned int _hi, _lo; \
+ asm volatile ("rdtsc" : "=a" (_lo), "=d" (_hi)); \
(Var) = ((unsigned long long int) _hi << 32) | _lo; })
/* The funny business for 32-bit mode is not required here. */
Jakub
More information about the Libc-hacker
mailing list