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]

RFA (i386): PATCH to ix86_code_end to set DECL_IGNORED_P on the PC thunk


While working on another DWARF patch I ran into a crash because we didn't set DECL_IGNORED_P on the PC thunk, but we also don't emit any debug info for it. Since there's no debug info, we should set DECL_IGNORED_P, and we shouldn't add ignored functions to .debug_aranges or .debug_ranges.

OK for trunk?
commit 1c8822f0eba9797ca937fd899c960a1b355d0563
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Apr 23 16:29:36 2012 -0400

    	* config/i386/i386.c (ix86_code_end): Set DECL_IGNORED_P on the
    	pc thunk.
    	* dwarf2out.c (output_aranges): Skip DECL_IGNORED_P functions.
    	(dwarf2out_finish): Likewise.

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 903683e..43d8b8b 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -8612,6 +8612,7 @@ ix86_code_end (void)
 				       NULL_TREE, void_type_node);
       TREE_PUBLIC (decl) = 1;
       TREE_STATIC (decl) = 1;
+      DECL_IGNORED_P (decl) = 1;
 
 #if TARGET_MACHO
       if (TARGET_MACHO)
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 8bbf954..311914a 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -8085,6 +8085,8 @@ output_aranges (unsigned long aranges_length)
 
       FOR_EACH_VEC_ELT (dw_fde_ref, fde_vec, fde_idx, fde)
 	{
+	  if (DECL_IGNORED_P (fde->decl))
+	    continue;
 	  if (!fde->in_std_section)
 	    {
 	      dw2_asm_output_addr (DWARF2_ADDR_SIZE, fde->dw_fde_begin,
@@ -21895,6 +21897,8 @@ dwarf2out_finish (const char *filename)
 
       FOR_EACH_VEC_ELT (dw_fde_ref, fde_vec, fde_idx, fde)
 	{
+	  if (DECL_IGNORED_P (fde->decl))
+	    continue;
 	  if (!fde->in_std_section)
 	    add_ranges_by_labels (comp_unit_die (), fde->dw_fde_begin,
 				  fde->dw_fde_end, &range_list_added);
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/thunk1.C b/gcc/testsuite/g++.dg/debug/dwarf2/thunk1.C
new file mode 100644
index 0000000..c34373e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/thunk1.C
@@ -0,0 +1,11 @@
+// Test that we don't add the x86 PC thunk to .debug_ranges
+// { dg-do compile { target i?86-*-* } }
+// { dg-options "-g -fpic" }
+// { dg-final { scan-assembler-times "LFB3" 1 } }
+
+template <class T> void f(T t) { }
+
+int main()
+{
+  f(42);
+}

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