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]\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

Reply via email to