[Bug tree-optimization/15438] [3.5 Regression] miscompilation with attribute (__malloc__)

steven at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Mon May 17 20:00:00 GMT 2004


------- Additional Comments From steven at gcc dot gnu dot org  2004-05-17 08:37 -------
I don't think it is safe to not add call clobbered ops if the  
function has the malloc attribute.  It is definitely not safe 
if the function _may_ be alloca (ECF_MAY_BE_ALLOCA does not 
mean the call _is_ alloca, afaict). 
 
Index: tree-ssa-operands.c 
=================================================================== 
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-operands.c,v 
retrieving revision 2.2 
diff -c -3 -p -r2.2 tree-ssa-operands.c 
*** tree-ssa-operands.c 14 May 2004 02:32:58 -0000      2.2 
--- tree-ssa-operands.c 17 May 2004 08:35:00 -0000 
*************** get_expr_operands (tree stmt, tree *expr 
*** 1023,1034 **** 
 
        if (bitmap_first_set_bit (call_clobbered_vars) >= 0) 
        { 
!         if (!(call_flags 
!               & (ECF_PURE 
!                  | ECF_CONST 
!                  | ECF_NORETURN 
!                  | ECF_MALLOC 
!                  | ECF_MAY_BE_ALLOCA))) 
            add_call_clobber_ops (stmt, prev_vops); 
          else if (!(call_flags & (ECF_CONST | ECF_NORETURN))) 
            add_call_read_ops (stmt, prev_vops); 
--- 1023,1032 ---- 
 
        if (bitmap_first_set_bit (call_clobbered_vars) >= 0) 
        { 
!         /* A 'pure' or a 'const' functions never call clobber anything. 
!            A 'noreturn' function might, but since we don't return anyway 
!            there is no point in recording that.  */ 
!         if (!(call_flags & (ECF_PURE | ECF_CONST | ECF_NORETURN))) 
            add_call_clobber_ops (stmt, prev_vops); 
          else if (!(call_flags & (ECF_CONST | ECF_NORETURN))) 
            add_call_read_ops (stmt, prev_vops); 

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15438



More information about the Gcc-bugs mailing list