On Mon, Mar 11, 2013 at 12:13 AM, Steven Bosscher <stevenb....@gmail.com> wrote:
> On Sun, Mar 10, 2013 at 22:54, Matt Davis wrote:
>> I have a particular instance of a
>> function call within a function that I am analyzing (and
>> transforming).  I want the address of that function call, for which I
>> do have a gimple_call instance of.  I want to somehow create a symbol
>> identifying that particular address/location for that instance of the
>> function call.  I need this address at runtime. I was inserting labels
>> just after each function call, but the placement of my label was not
>> always immediately after the function call, even if I set the label as
>> being addressable and/or volatile.
>
> You have the GIMPLE_CALL gimple statement, and you can use
> gsi_for_stmt to get an insertion point for the labels. But at this
> point in the compilation chain, you can't expect this label to be the
> exact call site, e.g. because arguments need to be set up, registers
> saved/restored around the call, etc.  Also, a label will count as a
> basic block split point, so your call and your label may end up being
> separated by a jump when basic blocks are re-ordered.

Yep! That was what I was seeing. The return value results/registers
being adjusted immediately after the function call, resulting in my
label getting moved.

> If you want to get the address of the actual call site at runtime,
> you're going to have to put the label before the call insn in the
> "final" pass. Perhaps you could do that by inserting
> NOTE_INSN_DELETED_LABEL notes before the call insn, or by modifying
> the assembly output routines for calls to put a label just before the
> call. But even this may not work reliable if a call output pattern
> emits multiple assembly instructions for a single call RTL
> instruction.

Thanks for this suggestion!

-Matt

Reply via email to