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]

PR 22051


Attached is a proposed patch for PR 22051, in which we fail to call the special PA function-pointer-comparision routine.

I've not yet properly tested this patch, but it does seem to fix the testcase. Joseph, if convenient, would you mind running this through a test cycle on PA HP-UX?

The current code in find_equivalent_equality_comparison is blindly assuming that NOP_EXPRs and CONVERT_EXPRs can be ignored, in that, given something like:

<L1>:;
  p___0_5 = (int (*<T26a>) (int, char * *)) p_3;
  if (p___0_5 != main) goto <L2>; else goto <L3>;

it is OK to replace p___0_5 in the test with p__2 (of type void *):

p_2 = dlsym (5B, &"main"[0]);

because we cast the second operand to the conditional ("main") to the type of p_2 (void*), and then fold that, getting back "main", and then call tree_int_cst_equal to see if that is the same as "main", which of course it is.

In other words, what we're trying to test is whether doing the comparision with p_2 (which means converting the RHS to that type) is OK. It's not OK in this case, because converting from a function pointer type to "void *" is not OK.

Any comments?

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304
Index: tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-dom.c,v
retrieving revision 2.94
diff -c -5 -p -r2.94 tree-ssa-dom.c
*** tree-ssa-dom.c	24 Feb 2005 21:47:26 -0000	2.94
--- tree-ssa-dom.c	24 Jun 2005 04:19:06 -0000
*************** find_equivalent_equality_comparison (tre
*** 1930,1940 ****
        tree def_rhs = TREE_OPERAND (def_stmt, 1);
  
        /* Now make sure the RHS of the MODIFY_EXPR is a typecast.  */
        if ((TREE_CODE (def_rhs) == NOP_EXPR
  	   || TREE_CODE (def_rhs) == CONVERT_EXPR)
! 	  && TREE_CODE (TREE_OPERAND (def_rhs, 0)) == SSA_NAME)
  	{
  	  tree def_rhs_inner = TREE_OPERAND (def_rhs, 0);
  	  tree def_rhs_inner_type = TREE_TYPE (def_rhs_inner);
  	  tree new;
  
--- 1930,1941 ----
        tree def_rhs = TREE_OPERAND (def_stmt, 1);
  
        /* Now make sure the RHS of the MODIFY_EXPR is a typecast.  */
        if ((TREE_CODE (def_rhs) == NOP_EXPR
  	   || TREE_CODE (def_rhs) == CONVERT_EXPR)
! 	  && TREE_CODE (TREE_OPERAND (def_rhs, 0)) == SSA_NAME
! 	  && tree_ssa_useless_type_conversion (def_rhs))
  	{
  	  tree def_rhs_inner = TREE_OPERAND (def_rhs, 0);
  	  tree def_rhs_inner_type = TREE_TYPE (def_rhs_inner);
  	  tree new;
  

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