Re: Obtaining a callsite address.
On Sun, Mar 10, 2013 at 01:51:04PM +1100, Matt Davis wrote: > I have a GIMPLE_CALL gimple object. I want to get the tree node > representing the callsite for this particular instance of a call, how > can I get this information? I'm not sure to understand your question (what exactly do you mean by "callsite"). However, the called function can be obtained by gimple_call_fndecl which gives a tree. If using MELT http://gcc-melt.org/ you just use a gimple_call pattern... Regards. -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basilestarynkevitchnet mobile: +33 6 8501 2359 8, rue de la Faiencerie, 92340 Bourg La Reine, France *** opinions {are only mines, sont seulement les miennes} ***
Re: Obtaining a callsite address.
On Sun, Mar 10, 2013 at 9:35 PM, Basile Starynkevitch wrote: > On Sun, Mar 10, 2013 at 01:51:04PM +1100, Matt Davis wrote: >> I have a GIMPLE_CALL gimple object. I want to get the tree node >> representing the callsite for this particular instance of a call, how >> can I get this information? > > I'm not sure to understand your question (what exactly do you mean by > "callsite"). Hi Basile, Thanks for the quick response. 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. > However, the called function can be obtained by gimple_call_fndecl which > gives a tree. Yep, but that fndecl is not unique to just that instance of the function call, but applies to all calls of that function. Ultimately I need the address for all calls in the program. -Matt
Re: Obtaining a callsite address.
On Sun, Mar 10, 2013 at 10:54:39PM +1100, Matt Davis wrote: > On Sun, Mar 10, 2013 at 9:35 PM, Basile Starynkevitch > wrote: > > On Sun, Mar 10, 2013 at 01:51:04PM +1100, Matt Davis wrote: > >> I have a GIMPLE_CALL gimple object. I want to get the tree node > >> representing the callsite for this particular instance of a call, how > >> can I get this information? > > > > I'm not sure to understand your question (what exactly do you mean by > > "callsite"). > > Hi Basile, > Thanks for the quick response. 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. I would rather put the label just before the function call, not after it. (or maybe do both) Maybe you could do something else, like generate debug related gimples But I don't understand well what will happen to these added gimples after your pass. BTW, where exactly did you insert your pass? Cheers -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basilestarynkevitchnet mobile: +33 6 8501 2359 8, rue de la Faiencerie, 92340 Bourg La Reine, France *** opinions {are only mines, sont seulement les miennes} ***
Re: Obtaining a callsite address.
On Sun, 10 Mar 2013 at 13:51, Matt Davis wrote: > I have a GIMPLE_CALL gimple object. I want to get the tree node > representing the callsite for this particular instance of a call, how > can I get this information? The GIMPLE_CALL gimple object *is* the call site. Ciao! Steven
Re: Obtaining a callsite address.
On Sun, Mar 10, 2013 at 11:27 PM, Basile Starynkevitch wrote: > On Sun, Mar 10, 2013 at 10:54:39PM +1100, Matt Davis wrote: >> On Sun, Mar 10, 2013 at 9:35 PM, Basile Starynkevitch >> wrote: >> > On Sun, Mar 10, 2013 at 01:51:04PM +1100, Matt Davis wrote: >> >> I have a GIMPLE_CALL gimple object. I want to get the tree node >> >> representing the callsite for this particular instance of a call, how >> >> can I get this information? >> > >> > I'm not sure to understand your question (what exactly do you mean by >> > "callsite"). >> >> Hi Basile, >> Thanks for the quick response. 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. > > I would rather put the label just before the function call, not after it. (or > maybe do both) Ok, I have tried both, but I was hoping to avoid adding labels and just reference the function call location. > BTW, where exactly did you insert your pass? This pass is after all IPA passes. Thanks, again for all of the info. -Matt > > Cheers > -- > Basile STARYNKEVITCH http://starynkevitch.net/Basile/ > email: basilestarynkevitchnet mobile: +33 6 8501 2359 > 8, rue de la Faiencerie, 92340 Bourg La Reine, France > *** opinions {are only mines, sont seulement les miennes} ***
Re: Obtaining a callsite address.
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. 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. Ciao! Steven
Re: Obtaining a callsite address.
On Mon, Mar 11, 2013 at 12:13 AM, Steven Bosscher 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
gcc-4.8-20130310 is now available
Snapshot gcc-4.8-20130310 is now available on ftp://gcc.gnu.org/pub/gcc/snapshots/4.8-20130310/ and on various mirrors, see http://gcc.gnu.org/mirrors.html for details. This snapshot has been generated from the GCC 4.8 SVN branch with the following options: svn://gcc.gnu.org/svn/gcc/trunk revision 196584 You'll find: gcc-4.8-20130310.tar.bz2 Complete GCC MD5=46df519745d610762981eabf60e4aa41 SHA1=ddae4e08f64df0ad7b14761015933bad17e0bfc0 Diffs from 4.8-20130303 are available in the diffs/ subdirectory. When a particular snapshot is ready for public consumption the LATEST-4.8 link is updated and a message is sent to the gcc list. Please do not use a snapshot before it has been announced that way.