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]

[PATCH] Improve debug info for optimized away parameters passed in memory


Hi!

On the attached enhanced typeddwarf.c testcase there is no location
info for the 3 vars in f4 function with -O2 -m32 -g.  The parameter
is unused during expansion except for debug stmts, but DECL_INCOMING_RTL
isn't a hard register or MEM with hard register as address that would be
represented as ENTRY_VALUE.  But, if it is unused, then IMHO nothing should
modify the stack slot in which it has been passed to the function, thus
it should be fine to just use the DECL_INCOMING_RTL MEM.
Without this patch, we will use a pseudo that is loaded from the MEM,
but those pseudos will be quickly optimized away afterwards.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2011-05-05  Jakub Jelinek  <jakub@redhat.com>

	* cfgexpand.c (expand_debug_expr): For unused non-addressable
	parameters passed in memory prefer using DECL_INCOMING_RTL over
	the pseudos it will be copied into.

--- gcc/cfgexpand.c.jj	2011-05-02 18:39:28.000000000 +0200
+++ gcc/cfgexpand.c	2011-05-05 09:29:50.000000000 +0200
@@ -3160,6 +3160,20 @@ expand_debug_expr (tree exp)
 			ENTRY_VALUE_EXP (op0) = incoming;
 			goto adjust_mode;
 		      }
+		    if (incoming
+			&& MEM_P (incoming)
+			&& !TREE_ADDRESSABLE (SSA_NAME_VAR (exp))
+			&& GET_MODE (incoming) != BLKmode
+			&& (XEXP (incoming, 0) == virtual_incoming_args_rtx
+			    || (GET_CODE (XEXP (incoming, 0)) == PLUS
+				&& XEXP (XEXP (incoming, 0), 0)
+				   == virtual_incoming_args_rtx
+				&& CONST_INT_P (XEXP (XEXP (incoming, 0),
+						      1)))))
+		      {
+			op0 = incoming;
+			goto adjust_mode;
+		      }
 		    op0 = expand_debug_expr (SSA_NAME_VAR (exp));
 		    if (!op0)
 		      return NULL;

	Jakub

Attachment: typeddwarf.c
Description: Text document


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