pure calls versus CONST_CALL_P take 2

Jan Hubicka jh@suse.cz
Mon Aug 6 04:21:00 GMT 2001


Hi,
regtesting has shown, that find_loads needs to be modified to grok NULL
pointers.

Bootstrapped/regtested i586

Mon Aug  6 12:52:25 CEST 2001  Jan Hubicka  <jh@suse.cz>
	* alias.c (nonlocal_mentioned_p):
	Rename CONST_CALL_P to CONST_OR_PURE_CALL_P
	* calls.c (emit_call_1): Likewise.
	* cse.c (cse_insn, invalidate_skipped_block): Likewise.
	* cselib.c (cselib_process_insn): Likewise.
	* df.c (df_insns_modify): Likewise.
	* flow.c (need_fake_edge_p): Likewise.
	(propagate_one_insn): Likewise.
	* haifa-sched.c (reemit_notes): Likewise.
	* integrate.c (copy_insn_list): Likewise.
	* jump.c (delete_prior_computation): Likewise.
	* local-alloc.c (validate_equiv_mem): Likewise.
	* loop.c (scan_loop): Likewise.
	* predict.c (estimate_probability): Likewise.
	* reload.c (reload): Likewise.
	* sched-deps (sched_analyze): Likewise.
	* rtl.h (CONST_CALL_P): rename to CONST_OR_PURE_CALL_P.
	* gcse.c (compute_hash_table): Likewise.
	(mark_call): Likewise.
	(store_killed_in_insn): Fix handling of const calls.
	(find_loads): Accept NULL.
Index: alias.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/alias.c,v
retrieving revision 1.132
diff -c -3 -p -r1.132 alias.c
*** alias.c	2001/08/05 16:26:01	1.132
--- alias.c	2001/08/06 10:50:29
*************** nonlocal_mentioned_p (x)
*** 1934,1940 ****
      {
        /* Constant functions can be constant if they don't use
           scratch memory used to mark function w/o side effects.  */
!       if (code == CALL_INSN && CONST_CALL_P (x))
          {
  	  x = CALL_INSN_FUNCTION_USAGE (x);
  	  if (x == 0)
--- 1934,1940 ----
      {
        /* Constant functions can be constant if they don't use
           scratch memory used to mark function w/o side effects.  */
!       if (code == CALL_INSN && CONST_OR_PURE_CALL_P (x))
          {
  	  x = CALL_INSN_FUNCTION_USAGE (x);
  	  if (x == 0)
Index: calls.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/calls.c,v
retrieving revision 1.189
diff -c -3 -p -r1.189 calls.c
*** calls.c	2001/08/01 17:57:24	1.189
--- calls.c	2001/08/06 10:50:31
*************** emit_call_1 (funexp, fndecl, funtype, st
*** 598,604 ****
  
    /* If this is a const call, then set the insn's unchanging bit.  */
    if (ecf_flags & (ECF_CONST | ECF_PURE))
!     CONST_CALL_P (call_insn) = 1;
  
    /* If this call can't throw, attach a REG_EH_REGION reg note to that
       effect.  */
--- 598,604 ----
  
    /* If this is a const call, then set the insn's unchanging bit.  */
    if (ecf_flags & (ECF_CONST | ECF_PURE))
!     CONST_OR_PURE_CALL_P (call_insn) = 1;
  
    /* If this call can't throw, attach a REG_EH_REGION reg note to that
       effect.  */
Index: cse.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cse.c,v
retrieving revision 1.198
diff -c -3 -p -r1.198 cse.c
*** cse.c	2001/08/03 01:19:15	1.198
--- cse.c	2001/08/06 10:50:34
*************** cse_insn (insn, libcall_insn)
*** 5956,5962 ****
  
    if (GET_CODE (insn) == CALL_INSN)
      {
!       if (! CONST_CALL_P (insn))
  	invalidate_memory ();
        invalidate_for_call ();
      }
--- 5956,5962 ----
  
    if (GET_CODE (insn) == CALL_INSN)
      {
!       if (! CONST_OR_PURE_CALL_P (insn))
  	invalidate_memory ();
        invalidate_for_call ();
      }
*************** invalidate_skipped_block (start)
*** 6636,6642 ****
  
        if (GET_CODE (insn) == CALL_INSN)
  	{
! 	  if (! CONST_CALL_P (insn))
  	    invalidate_memory ();
  	  invalidate_for_call ();
  	}
--- 6636,6642 ----
  
        if (GET_CODE (insn) == CALL_INSN)
  	{
! 	  if (! CONST_OR_PURE_CALL_P (insn))
  	    invalidate_memory ();
  	  invalidate_for_call ();
  	}
Index: cselib.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cselib.c,v
retrieving revision 1.7
diff -c -3 -p -r1.7 cselib.c
*** cselib.c	2001/08/01 17:57:26	1.7
--- cselib.c	2001/08/06 10:50:34
*************** cselib_process_insn (insn)
*** 1279,1285 ****
  	if (call_used_regs[i])
  	  cselib_invalidate_regno (i, VOIDmode);
  
!       if (! CONST_CALL_P (insn))
  	cselib_invalidate_mem (callmem);
      }
  
--- 1279,1285 ----
  	if (call_used_regs[i])
  	  cselib_invalidate_regno (i, VOIDmode);
  
!       if (! CONST_OR_PURE_CALL_P (insn))
  	cselib_invalidate_mem (callmem);
      }
  
Index: df.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/df.c,v
retrieving revision 1.5
diff -c -3 -p -r1.5 df.c
*** df.c	2001/07/29 18:23:35	1.5
--- df.c	2001/08/06 10:50:35
*************** df_insns_modify (df, bb, first_insn, las
*** 2882,2888 ****
  	 it does, we need to create a new basic block.  Ouch.  The
  	 same applies for a label.  */
        if ((GET_CODE (insn) == CALL_INSN
! 	   && ! CONST_CALL_P (insn))
  	  || GET_CODE (insn) == CODE_LABEL)
  	abort ();
  
--- 2882,2888 ----
  	 it does, we need to create a new basic block.  Ouch.  The
  	 same applies for a label.  */
        if ((GET_CODE (insn) == CALL_INSN
! 	   && ! CONST_OR_PURE_CALL_P (insn))
  	  || GET_CODE (insn) == CODE_LABEL)
  	abort ();
  
Index: flow.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/flow.c,v
retrieving revision 1.455
diff -c -3 -p -r1.455 flow.c
*** flow.c	2001/08/06 06:39:20	1.455
--- flow.c	2001/08/06 10:50:38
*************** need_fake_edge_p (insn)
*** 2512,2518 ****
  
    if ((GET_CODE (insn) == CALL_INSN
         && !SIBLING_CALL_P (insn)
!        && !find_reg_note (insn, REG_NORETURN, NULL) && !CONST_CALL_P (insn)))
      return true;
  
    return ((GET_CODE (PATTERN (insn)) == ASM_OPERANDS
--- 2512,2519 ----
  
    if ((GET_CODE (insn) == CALL_INSN
         && !SIBLING_CALL_P (insn)
!        && !find_reg_note (insn, REG_NORETURN, NULL)
!        && !CONST_OR_PURE_CALL_P (insn)))
      return true;
  
    return ((GET_CODE (PATTERN (insn)) == ASM_OPERANDS
*************** propagate_one_insn (pbi, insn)
*** 5392,5398 ****
  	    cond = COND_EXEC_TEST (PATTERN (insn));
  
  	  /* Non-constant calls clobber memory.  */
! 	  if (! CONST_CALL_P (insn))
  	    {
  	      free_EXPR_LIST_list (&pbi->mem_set_list);
  	      pbi->mem_set_list_len = 0;
--- 5393,5399 ----
  	    cond = COND_EXEC_TEST (PATTERN (insn));
  
  	  /* Non-constant calls clobber memory.  */
! 	  if (! CONST_OR_PURE_CALL_P (insn))
  	    {
  	      free_EXPR_LIST_list (&pbi->mem_set_list);
  	      pbi->mem_set_list_len = 0;
Index: haifa-sched.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/haifa-sched.c,v
retrieving revision 1.180
diff -c -3 -p -r1.180 haifa-sched.c
*** haifa-sched.c	2001/06/26 10:47:30	1.180
--- haifa-sched.c	2001/08/06 10:50:40
*************** reemit_notes (insn, last)
*** 1561,1567 ****
  	  if (note_type == NOTE_INSN_SETJMP)
  	    {
  	      retval = emit_note_after (NOTE_INSN_SETJMP, insn);
! 	      CONST_CALL_P (retval) = CONST_CALL_P (note);
  	      remove_note (insn, note);
  	      note = XEXP (note, 1);
  	    }
--- 1561,1567 ----
  	  if (note_type == NOTE_INSN_SETJMP)
  	    {
  	      retval = emit_note_after (NOTE_INSN_SETJMP, insn);
! 	      CONST_OR_PURE_CALL_P (retval) = CONST_OR_PURE_CALL_P (note);
  	      remove_note (insn, note);
  	      note = XEXP (note, 1);
  	    }
Index: integrate.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/integrate.c,v
retrieving revision 1.154
diff -c -3 -p -r1.154 integrate.c
*** integrate.c	2001/07/20 11:30:13	1.154
--- integrate.c	2001/08/06 10:50:41
*************** copy_insn_list (insns, map, static_chain
*** 1522,1528 ****
  	  copy = emit_call_insn (pattern);
  
  	  SIBLING_CALL_P (copy) = SIBLING_CALL_P (insn);
! 	  CONST_CALL_P (copy) = CONST_CALL_P (insn);
  
  	  /* Because the USAGE information potentially contains objects other
  	     than hard registers, we need to copy it.  */
--- 1522,1528 ----
  	  copy = emit_call_insn (pattern);
  
  	  SIBLING_CALL_P (copy) = SIBLING_CALL_P (insn);
! 	  CONST_OR_PURE_CALL_P (copy) = CONST_OR_PURE_CALL_P (insn);
  
  	  /* Because the USAGE information potentially contains objects other
  	     than hard registers, we need to copy it.  */
Index: jump.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/jump.c,v
retrieving revision 1.189
diff -c -3 -p -r1.189 jump.c
*** jump.c	2001/07/31 13:36:10	1.189
--- jump.c	2001/08/06 10:50:42
*************** delete_prior_computation (note, insn)
*** 1521,1527 ****
        /* If we reach a CALL which is not calling a const function
  	 or the callee pops the arguments, then give up.  */
        if (GET_CODE (our_prev) == CALL_INSN
! 	  && (! CONST_CALL_P (our_prev)
  	      || GET_CODE (pat) != SET || GET_CODE (SET_SRC (pat)) != CALL))
  	break;
  
--- 1521,1527 ----
        /* If we reach a CALL which is not calling a const function
  	 or the callee pops the arguments, then give up.  */
        if (GET_CODE (our_prev) == CALL_INSN
! 	  && (! CONST_OR_PURE_CALL_P (our_prev)
  	      || GET_CODE (pat) != SET || GET_CODE (SET_SRC (pat)) != CALL))
  	break;
  
Index: local-alloc.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/local-alloc.c,v
retrieving revision 1.83
diff -c -3 -p -r1.83 local-alloc.c
*** local-alloc.c	2001/08/06 06:41:46	1.83
--- local-alloc.c	2001/08/06 10:50:43
*************** validate_equiv_mem (start, reg, memref)
*** 498,504 ****
  	return 1;
  
        if (GET_CODE (insn) == CALL_INSN && ! RTX_UNCHANGING_P (memref)
! 	  && ! CONST_CALL_P (insn))
  	return 0;
  
        note_stores (PATTERN (insn), validate_equiv_mem_from_store, NULL);
--- 498,504 ----
  	return 1;
  
        if (GET_CODE (insn) == CALL_INSN && ! RTX_UNCHANGING_P (memref)
! 	  && ! CONST_OR_PURE_CALL_P (insn))
  	return 0;
  
        note_stores (PATTERN (insn), validate_equiv_mem_from_store, NULL);
Index: loop.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/loop.c,v
retrieving revision 1.342
diff -c -3 -p -r1.342 loop.c
*** loop.c	2001/08/04 12:08:42	1.342
--- loop.c	2001/08/06 10:50:46
*************** scan_loop (loop, flags)
*** 950,956 ****
        /* Past a call insn, we get to insns which might not be executed
  	 because the call might exit.  This matters for insns that trap.
  	 Constant and pure call insns always return, so they don't count.  */
!       else if (GET_CODE (p) == CALL_INSN && ! CONST_CALL_P (p))
  	call_passed = 1;
        /* Past a label or a jump, we get to insns for which we
  	 can't count on whether or how many times they will be
--- 950,956 ----
        /* Past a call insn, we get to insns which might not be executed
  	 because the call might exit.  This matters for insns that trap.
  	 Constant and pure call insns always return, so they don't count.  */
!       else if (GET_CODE (p) == CALL_INSN && ! CONST_OR_PURE_CALL_P (p))
  	call_passed = 1;
        /* Past a label or a jump, we get to insns for which we
  	 can't count on whether or how many times they will be
*************** prescan_loop (loop)
*** 2364,2370 ****
  	}
        else if (GET_CODE (insn) == CALL_INSN)
  	{
! 	  if (! CONST_CALL_P (insn))
  	    {
  	      loop_info->unknown_address_altered = 1;
  	      loop_info->has_nonconst_call = 1;
--- 2364,2370 ----
  	}
        else if (GET_CODE (insn) == CALL_INSN)
  	{
! 	  if (! CONST_OR_PURE_CALL_P (insn))
  	    {
  	      loop_info->unknown_address_altered = 1;
  	      loop_info->has_nonconst_call = 1;
Index: predict.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/predict.c,v
retrieving revision 1.30
diff -c -3 -p -r1.30 predict.c
*** predict.c	2001/07/30 18:04:32	1.30
--- predict.c	2001/08/06 10:50:46
*************** estimate_probability (loops_info)
*** 386,392 ****
  		if (GET_CODE (insn) == CALL_INSN
  		    /* Constant and pure calls are hardly used to signalize
  		       something exceptional.  */
! 		    && ! CONST_CALL_P (insn))
  		  {
  		    predict_edge_def (e, PRED_CALL, NOT_TAKEN);
  		    break;
--- 386,392 ----
  		if (GET_CODE (insn) == CALL_INSN
  		    /* Constant and pure calls are hardly used to signalize
  		       something exceptional.  */
! 		    && ! CONST_OR_PURE_CALL_P (insn))
  		  {
  		    predict_edge_def (e, PRED_CALL, NOT_TAKEN);
  		    break;
Index: reload1.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/reload1.c,v
retrieving revision 1.280
diff -c -3 -p -r1.280 reload1.c
*** reload1.c	2001/08/06 06:39:20	1.280
--- reload1.c	2001/08/06 10:50:50
*************** reload (first, global)
*** 762,768 ****
      {
        rtx set = single_set (insn);
  
!       if (GET_CODE (insn) == NOTE && CONST_CALL_P (insn)
  	  && NOTE_LINE_NUMBER (insn) == NOTE_INSN_SETJMP)
  	for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
  	  if (! call_used_regs[i])
--- 762,768 ----
      {
        rtx set = single_set (insn);
  
!       if (GET_CODE (insn) == NOTE && CONST_OR_PURE_CALL_P (insn)
  	  && NOTE_LINE_NUMBER (insn) == NOTE_INSN_SETJMP)
  	for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
  	  if (! call_used_regs[i])
Index: rtl.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/rtl.h,v
retrieving revision 1.282
diff -c -3 -p -r1.282 rtl.h
*** rtl.h	2001/07/29 21:28:42	1.282
--- rtl.h	2001/08/06 10:50:51
*************** extern void rtvec_check_failed_bounds PA
*** 393,400 ****
  /* 1 if insn has been deleted.  */
  #define INSN_DELETED_P(INSN) ((INSN)->volatil)
  
! /* 1 if insn is a call to a const function.  */
! #define CONST_CALL_P(INSN) ((INSN)->unchanging)
  
  /* 1 if insn (assumed to be a CALL_INSN) is a sibling call.  */
  #define SIBLING_CALL_P(INSN) ((INSN)->jump)
--- 393,400 ----
  /* 1 if insn has been deleted.  */
  #define INSN_DELETED_P(INSN) ((INSN)->volatil)
  
! /* 1 if insn is a call to a const or pure function.  */
! #define CONST_OR_PURE_CALL_P(INSN) ((INSN)->unchanging)
  
  /* 1 if insn (assumed to be a CALL_INSN) is a sibling call.  */
  #define SIBLING_CALL_P(INSN) ((INSN)->jump)
Index: sched-deps.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/sched-deps.c,v
retrieving revision 1.18
diff -c -3 -p -r1.18 sched-deps.c
*** sched-deps.c	2001/07/26 13:59:22	1.18
--- sched-deps.c	2001/08/06 10:50:51
*************** sched_analyze (deps, head, tail)
*** 1343,1349 ****
  	     all pending reads and writes, and start new dependencies starting
  	     from here.  But only flush writes for constant calls (which may
  	     be passed a pointer to something we haven't written yet).  */
! 	  flush_pending_lists (deps, insn, CONST_CALL_P (insn));
  
  	  /* Depend this function call (actually, the user of this
  	     function call) on all hard register clobberage.  */
--- 1343,1349 ----
  	     all pending reads and writes, and start new dependencies starting
  	     from here.  But only flush writes for constant calls (which may
  	     be passed a pointer to something we haven't written yet).  */
! 	  flush_pending_lists (deps, insn, CONST_OR_PURE_CALL_P (insn));
  
  	  /* Depend this function call (actually, the user of this
  	     function call) on all hard register clobberage.  */
*************** sched_analyze (deps, head, tail)
*** 1393,1399 ****
  	  loop_notes = alloc_EXPR_LIST (REG_SAVE_NOTE,
  					GEN_INT (NOTE_LINE_NUMBER (insn)),
  					loop_notes);
! 	  CONST_CALL_P (loop_notes) = CONST_CALL_P (insn);
  	}
  
        if (insn == tail)
--- 1393,1399 ----
  	  loop_notes = alloc_EXPR_LIST (REG_SAVE_NOTE,
  					GEN_INT (NOTE_LINE_NUMBER (insn)),
  					loop_notes);
! 	  CONST_OR_PURE_CALL_P (loop_notes) = CONST_OR_PURE_CALL_P (insn);
  	}
  
        if (insn == tail)

Index: gcse.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/gcse.c,v
retrieving revision 1.144
diff -c -3 -p -r1.144 gcse.c
*** gcse.c	2001/08/04 06:07:59	1.144
--- gcse.c	2001/08/06 10:59:41
*************** compute_hash_table (set_p)
*** 2514,2521 ****
  		if (TEST_HARD_REG_BIT (regs_invalidated_by_call, regno))
  		  record_last_reg_set_info (insn, regno);
  
! 	      if (! CONST_CALL_P (insn))
! 		record_last_mem_set_info (insn);
  	    }
  
  	  note_stores (PATTERN (insn), record_last_set_info, insn);
--- 2514,2520 ----
  		if (TEST_HARD_REG_BIT (regs_invalidated_by_call, regno))
  		  record_last_reg_set_info (insn, regno);
  
! 	      mark_call (insn);
  	    }
  
  	  note_stores (PATTERN (insn), record_last_set_info, insn);
*************** find_loads (x, store_pattern)
*** 6478,6483 ****
--- 6477,6485 ----
    int i,j;
    int ret = 0;
  
+   if (!x)
+     return 0;
+ 
    if (GET_CODE (x) == SET) 
      x = SET_SRC (x);
  
*************** static void
*** 2794,2800 ****
  mark_call (insn)
       rtx insn;
  {
!   if (! CONST_CALL_P (insn))
      record_last_mem_set_info (insn);
  }
  
--- 2793,2799 ----
  mark_call (insn)
       rtx insn;
  {
!   if (! CONST_OR_PURE_CALL_P (insn))
      record_last_mem_set_info (insn);
  }
  
*************** store_killed_in_insn (x, insn)
*** 6513,6519 ****
    
    if (GET_CODE (insn) == CALL_INSN)
      {
!       if (CONST_CALL_P (insn))
  	return 0;
        else
  	return 1;
--- 6512,6519 ----
    
    if (GET_CODE (insn) == CALL_INSN)
      {
!       if (CONST_OR_PURE_CALL_P (insn)
! 	  && !find_loads (CALL_INSN_FUNCTION_USAGE (insn), x))
  	return 0;
        else
  	return 1;



More information about the Gcc-patches mailing list