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: Accessing current_function_decl body


Hi all,

I have received no reply regarding this issue so I am still wondering
if anyone has any idea about this since I am still struggling to
understand if the tree of current_function_decl gets partially
destroyed during the expand pass where TARGET_FUNCTION_OK_FOR_SIBCALL
gets called.

If anybody has a faint idea on how this works, please let me know.

Thanks,

Paulo Matos

On Thu, Jan 14, 2010 at 5:00 PM, Paulo J. Matos <pocmatos@gmail.com> wrote:
> Hi,
>
> I am trying to walk through the body of the current_function_decl in
> TARGET_FUNCTION_OK_FOR_SIBCALL for a specific arch in gcc 4.3.4. I am
> using DECL_SAVED_TREE but it's not working as I expect.
> For the c file:
> extern unsigned int source_size(void *s);
> extern void source_drop_no_checks(void *s, unsigned int amount);
>
> void source_drop(void *s, unsigned int amount)
> {
> Â Âif(s && amount <= source_size(s))
> Â Â{
> Â Â Â Âsource_drop_no_checks(s, amount);
> Â Â}
> }
>
> I have in my TARGET_FUNCTION_OK_FOR_SIBCALL the following:
> fprintf(stderr,"INFO_SIBCALL %s[%s,%d@%d]\n",
> IDENTIFIER_POINTER(DECL_NAME(current_function_decl)),
> DECL_SOURCE_FILE(current_function_decl),
> DECL_SOURCE_LINE(current_function_decl), getpid());
> print_c_tree(stderr, DECL_SAVED_TREE(current_function_decl));
>
>
> which prints:
> INFO_SIBCALL source_drop[codegen.c,5@11875]
>
> if (s != 0B)
>
> so when I walk the tree with tree_walk I only go through the nodes of
> 'if(...)', 's' and '0B'.
>
> But the function is more than that. A simple tree dump results in
> codegen.c.026t.einline2:
> ;; Function source_drop (source_drop)
>
> source_drop (sD.1177, amountD.1178)
> {
> Âunsigned intD.3 D.1181;
>
> Â# BLOCK 2
> Â# PRED: ENTRY (fallthru)
> Âif (sD.1177_1(D) != 0B)
> Â Âgoto <bb 3>;
> Âelse
> Â Âgoto <bb 5>;
> Â# SUCC: 3 (true) 5 (false)
>
> Â# BLOCK 3
> Â# PRED: 2 (true)
> ÂD.1181_2 = source_size (sD.1177_1(D));
> Âif (amountD.1178_3(D) <= D.1181_2)
> Â Âgoto <bb 4>;
> Âelse
> Â Âgoto <bb 5>;
> Â# SUCC: 4 (true) 5 (false)
>
> Â# BLOCK 4
> Â# PRED: 3 (true)
> Âsource_drop_no_checks (sD.1177_1(D), amountD.1178_3(D));
> Â# SUCC: 5 (fallthru)
>
> Â# BLOCK 5
> Â# PRED: 2 (false) 3 (false) 4 (fallthru)
> Âreturn;
> Â# SUCC: EXIT
>
> }
>
> So it seems I am only getting back the first part of Âbasic block 2...
> but I want to go through all of them. How can I do this?
>
> Cheers,
>
> --
> Paulo Jorge Matos - pocmatos at gmail.com
> http://www.pmatos.net
>



-- 
Paulo Jorge Matos - pocmatos at gmail.com
http://www.pmatos.net


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