GOTO_FAKE_P to mark implicit goto statememnts

Jan Hubicka jh@suse.cz
Thu Nov 15 09:52:00 GMT 2001


Hi,
while testing the Zdenek's prediction patch I've noticed that
tree inliner produces GOTO statements at it's own will that confuses
the heuristics.  This patch adds flag to GOTO_STMT to mark the case.
I would like to get this into mainline, as it would be nice if
ast and others kept this in the mind.

Mon Nov 26 12:25:41 CET 2001  Jan Hubicka  <jh@suse.cz>

	* c-common.h (GOTO_FAKE_P): New macro.
	* tree-inline.c (GOTO_FAKE_P): Set.
	* c-tree.texi (GOTO_FAKE_P): Document.

Index: c-common.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-common.h,v
retrieving revision 1.95.2.1
diff -c -3 -p -r1.95.2.1 c-common.h
*** c-common.h	2001/11/22 16:04:24	1.95.2.1
--- c-common.h	2001/11/26 10:56:27
*************** extern tree strip_array_types           
*** 598,603 ****
--- 598,605 ----
  /* GOTO_STMT accessor. This gives access to the label associated with
     a goto statement.  */
  #define GOTO_DESTINATION(NODE)  TREE_OPERAND (GOTO_STMT_CHECK (NODE), 0)
+ /* True for goto created artifically by the compiler.  */
+ #define GOTO_FAKE_P(NODE)	(TREE_LANG_FLAG_0 (GOTO_STMT_CHECK (NODE)))
  
  /* COMPOUND_STMT accessor. This gives access to the TREE_LIST of
     statements associated with a compound statement. The result is the
Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tree-inline.c,v
retrieving revision 1.9
diff -c -3 -p -r1.9 tree-inline.c
*** tree-inline.c	2001/11/06 21:12:08	1.9
--- tree-inline.c	2001/11/26 10:56:30
*************** copy_body_r (tp, walk_subtrees, data)
*** 350,355 ****
--- 350,356 ----
        /* Build the GOTO_STMT.  */
        goto_stmt = build_stmt (GOTO_STMT, id->ret_label);
        TREE_CHAIN (goto_stmt) = TREE_CHAIN (return_stmt);
+       GOTO_FAKE_P (goto_stmt) = 1;
  
        /* If we're returning something, just turn that into an
  	 assignment into the equivalent of the original
Index: c-tree.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/doc/c-tree.texi,v
retrieving revision 1.22
diff -c -3 -p -r1.22 c-tree.texi
*** c-tree.texi	2001/10/17 08:44:09	1.22
--- c-tree.texi	2001/11/26 11:25:24
*************** This predicate holds if the function an 
*** 1278,1283 ****
--- 1278,1284 ----
  @findex FOR_BODY
  @tindex GOTO_STMT
  @findex GOTO_DESTINATION
+ @findex GOTO_FAKE_P
  @tindex HANDLER
  @tindex IF_STMT
  @findex IF_COND
*************** expressions.
*** 1511,1521 ****
  
  @item GOTO_STMT
  
! Used to represent a @code{goto} statement.  The @code{GOTO_DESTINATION}
! will usually be a @code{LABEL_DECL}.  However, if the ``computed
! goto'' extension has been used, the @code{GOTO_DESTINATION} will be an
! arbitrary expression indicating the destination.  This expression will
! always have pointer type.
  
  @item HANDLER
  
--- 1512,1524 ----
  
  @item GOTO_STMT
  
! Used to represent a @code{goto} statement.  The @code{GOTO_DESTINATION} will
! usually be a @code{LABEL_DECL}.  However, if the ``computed goto'' extension
! has been used, the @code{GOTO_DESTINATION} will be an arbitrary expression
! indicating the destination.  This expression will always have pointer type.
! Additionally the @code{GOTO_FAKE_P} flag is set whenever the goto statement
! does not come from source code, but it is generated implicitly by the compiler.
! This is used for branch prediction.
  
  @item HANDLER
  



More information about the Gcc-patches mailing list