[patch] Record VUSE operands for noreturn calls

Zdenek Dvorak rakdver@atrey.karlin.mff.cuni.cz
Sun Aug 22 22:01:00 GMT 2004


Hello,

we do not record VUSE operands for noreturn calls; this is wrong,
since this may cause the assignments to variables used by the
noreturn call to be removed in DCE.  I will commit the following
patch together with the testcase once it passes bootstrap & regtesting
as obvious.

Zdenek

#include <stdlib.h>
#include <string.h>

int *pwarn;

void bla (void) __attribute__ ((noreturn));

void bla (void)
{
  if (!*pwarn)
    abort ();
    
  exit (0);
}

int main (void)
{
  int warn;

  memset (&warn, 0, sizeof (warn));

  pwarn = &warn;

  warn = 1;

  bla ();
}

	* tree-ssa-operands.c (get_call_expr_operands): Add VUSE operands for
	noreturn functions.

Index: tree-ssa-operands.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-operands.c,v
retrieving revision 2.30
diff -c -3 -p -r2.30 tree-ssa-operands.c
*** tree-ssa-operands.c	18 Aug 2004 18:21:23 -0000	2.30
--- tree-ssa-operands.c	22 Aug 2004 20:48:04 -0000
*************** get_call_expr_operands (tree stmt, tree 
*** 1378,1384 ****
        if (TREE_SIDE_EFFECTS (expr)
  	  && !(call_flags & (ECF_PURE | ECF_CONST | ECF_NORETURN)))
  	add_call_clobber_ops (stmt);
!       else if (!(call_flags & (ECF_CONST | ECF_NORETURN)))
  	add_call_read_ops (stmt);
      }
  }
--- 1378,1384 ----
        if (TREE_SIDE_EFFECTS (expr)
  	  && !(call_flags & (ECF_PURE | ECF_CONST | ECF_NORETURN)))
  	add_call_clobber_ops (stmt);
!       else if (!(call_flags & ECF_CONST))
  	add_call_read_ops (stmt);
      }
  }



More information about the Gcc-patches mailing list