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]

Dealing with basic blocks


Hello all,

I am moving basic blocks around and currently the cfg is getting very,
very awkward. My guess is that I am doing something I shouldn't [as
usual].

For each SWITCH_EXPR I found on the code I generate a CFG which I have
to replace with the SWITCH_EXPR. The switch is always the last statement
on a basic block, so what I am doing is removing all the edges of the
current bb:

VEC_truncate (edge, bsi.bb->succs, 0);

Create a single edge from the current bb to the initial bb of the
generated cfg:

make_edge(bsi.bb, new, EDGE_FALLTHRU);

And finally remove the switch_expr we are pointing to:

bsi_remove(&bsi, true);

Is this the correct way to do it? I am quite concerned as to whether I
am removing all the edges from the basic block correctly and if I can
simply had a fallthru edge to the new cfg (given that after removing the
switch_expr, the original basic block will end on a statement that would
normally not require the basic block to end).

Cheers,

-- 
PMatos


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