This is the mail archive of the gcc-patches@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: [tree-ssa] CFG fix


On Thu, 2003-06-12 at 00:31, law@redhat.com wrote:
> first_exec_block is as far as I can tell a remnant of when empty statements
> used to be shared.
> 
Yup.  It used to exist only to skip over empty_stmt_nodes.  In fact, we
could probably get rid of first_exec_stmt.  Although first_exec_stmt is
used to prevent building a flowgraph when the function body is empty.

I also see another use of first_exec_stmt when making edges for
TRY_FINALLY_EXPR.  I'm a bit confused about this hunk in
make_ctrl_stmt_edges:


            case TRY_FINALLY_EXPR:
              VARRAY_PUSH_TREE (try_finallys, last);
              if (first_exec_stmt (&TREE_OPERAND (last, 0)) == NULL)
                make_edge (bb, bb_for_stmt (TREE_OPERAND (last, 1)), EDGE_ABNORMAL);
                                                                                        
              /* FALL THROUGH */
            case TRY_CATCH_EXPR:
              {
                basic_block target_bb = bb_for_stmt (TREE_OPERAND (last, 0));
                                                                                        
                if (target_bb)
                  make_edge (bb, target_bb, EDGE_FALLTHRU);
                make_edge (bb, successor_block (bb), EDGE_FALLTHRU);
                break;
              }
                                                                                       
Say we have an try/finally with an empty body:

	try		<- B1
	  (void)0;	<- B2
	finally
          {
            s1;		<- B3
            s2;
	  }
	...		<- B4

The above will create three edges out of B1:

	    B1
	  |  \     \
       (A)|   \(F)  \(F)
	  |    \     \
	  B3   B2    B4


Why do we create an abnormal edge when the body of a try/finally is
empty?  It's not immediately obvious.  Are we trying to avoid inserting
things in the empty body?  But we also create a fall through to the
empty body.  So, the above looks odd.

In fact, target_bb here should always be non-NULL now, so we could just
implement 'case TRY_CATCH_EXPR:' with

	case TRY_CATCH_EXPR:
	  make_edge (bb, bb_for_stmt (TREE_OPERAND (last, 0), EDGE_FALLTHRU);
	  make_edge (bb, successor_block (bb), EDGE_FALLTHRU);



Thanks.  Diego.


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