Hi Revital,

Because of doing copy, paste I forgot to delete one line from the CASE
1 example:

Instead:

>     /* below I pass a the tree of the current_function_decl a global
> variable in tree.h */
>     this_cfun = DECL_STRUCT_FUNCTION(current_function_decl);
>     FOR_EACH_BB_FN(bb, this_cfun) /* Crashes here, Also tried with
> FOR_EACH_BB */
>         for (bsi = bsi_start(bb); !bsi_end_p(bsi); bsi_next(&bsi))
>         {
>                bsi_stmt(bsi);
>         }
>     bsi = bsi_for_stmt(current_function_decl); /* Crashes right here */
> }

I have:

 /* below I pass a the tree of the current_function_decl a global
variable in tree.h */
 this_cfun = DECL_STRUCT_FUNCTION(current_function_decl);
 FOR_EACH_BB_FN(bb, this_cfun)
/* Crashes here, Also tried with FOR_EACH_BB */
     for (bsi = bsi_start(bb); !bsi_end_p(bsi); bsi_next(&bsi))
     {
            bsi_stmt(bsi);
     }
}

And the code crashes at the macro FOR_EACH_BB_FN.. This is exatly as
it is implemented in cgraph_create_edges() function.. but I think that
the problem is because I call it at wrong time (too early, or too late
- before or after parsing).. Could it be?

When cgraph_create_edges() function is called it is passed a
function's declaration tree. In my case I also pass a function
declaration tree:

this_cfun = DECL_STRUCT_FUNCTION(current_function_decl);

where this_cfun is used in macro FOR_EACH_BB_FN

bsi_for_stmt(current_function_decl); does not seems correct to me
as it should return the function's declaration's basic block
iterator; which does not belongs to bb.

I am sorry this statement shouldn't be in the code. I have it in CASE2
that is a different way I tried to do my implementation/

I think you are also missing some statement to get the current
tree node in the loop:

tree stmt = bsi_stmt (bsi);
and later recursively manipulate it with walk_tree ().

The execution actually does not reach this part of the code. I had it
written but, decided to remove them until solvin the problem with the
correct initialization of bb (basic blok) with the FOR_EACH_BB_FN
macro.

Ferad Zyulkyarov

Reply via email to