compiler trashes edx register when using -pg on x86

Dimitris Michailidis dimitris@darkside.engr.sgi.com
Tue Mar 9 15:47:00 GMT 1999


When compiling with -pg on linux the compiler generates a call to mcount in
each function, but right before this call it loads edx without saving its
original contents.  This causes code using regparm to pass arguments in
registers to crash.  It appears that the compiler should save edx and restore
it after mcount.  On the other hand, mcount does not appear to be using the 
value loaded into edx for anything, so why does the compiler load edx at all?
mcount in glibc saves and restores the registers appropriately and it is only
that load right before the mcount call that causes the problem.  Why is it
there?

---
Dimitris Michailidis		dimitris@engr.sgi.com


More information about the Gcc-bugs mailing list