> ?? wrote: > > Now, my question becomes clear. How to make my inserted function call > >not affect the orginal state of program? > > Try looking at a similar feature. One such similar feature is the > mcount calls emitted for profiling. The various solutions for mcount > include > 1) saving lots of registers before the call, and restoring lots of > registers after the call. This has a high cost which may not work in > your case. > 2) Writing mcount in assembly language, so that you can avoid clobbering > any registers.
Actually I would say that copying mcount code would be dificult (because we need to emit the calls at arbitrary basic blocks rather than in prologue) and not very maintanale. I belive that it would be better to simply insert the calls at gimple level like edge/value profiling is done. Using custom calling conventions to speed process up might be interesting, I guess it can be done via target hook+attribute but I would leave it for later time. Honza