This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: adjust_stack variants?


> On Thu, 2002-06-13 at 10:38, Jan Hubicka wrote:
> > > I'm working with inserting some additional instructions into the RTL
> > > stream and was wondering about the adjust_stack function. It would be
> > > really nice if there was an adjust_stack_after variant like the
> > > emit_*_insn_after variety. I'm having to go back and insert a function
> > > call into the RTL and need to adjust the stack after making that function 
> > 
> > Inserting call into already generated RTL is dificult, if not
> > impossible.  The function calling code is keeping a lot of information
> > about the context - what parts of outgoing argument area are occupied or
> > what is the current (miss) alignemnt of stack.  This won't work once the
> > RTL generation has moved from the call site.
> That's what I was afraid of...
> 
> > 
> > What exactly do you need the function for?
> Instrumentation. We're modifying GCC to instrument code on the fly.
> Specifically, we're instrumenting the loop entries, continues and exits.
> In the case of a while loop, you have to insert the loop continue code
> in the expand_end_loop call, but by that time the body of the loop has
> already been emitted so you have to go back and insert the continue code
> after the start label is generated which also requires that we fix the
> stack after the fact. We've got a dirty hack that just adds 4 back onto
> the stack pointer, but we're looking for a better way. 

I guess the trick you can do is just to emit the call afterwards into
sequence and emit it to proper place. In the case the proper place is
basic block boundary - for instrumenting loops this should be easy, you
should be on safe side.

What do you need instrumentation for?  I am thinking about adding some
functionality to the edge profiler to produce loop iteration count
histograms for optimizers.  In case you are shooting for similar goals,
we should probably synchronize.

Honza


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]