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] Fix for DW_AT_low_pc and DW_AT_high_pc of inlined functions (DW_TAG_inlined_subroutine).


This fixes PR 12319.

When re-adding block begin and end notes, the instructions
that are part a function prologue/epilogue did fall out
the boat: There is no locator added for them in the block_locators_locs
VARRAY.   As a result, insn_scope  - that does a binary search
on 'locator' ids in that VARRAY - would simply return the block
for the first valid instruction in the function for the prologue,
and NULL for the epilogue (the requested prologue_locator will be
smaller than the first locator in the array, and the epilogue_locator
will be larger then the maximum locator in the array).  Returning
NULL for the epilogue insns results in the end in the epilogue insns
to be included in the block of the last instruction.

This leads to the described bug when the first and/or last instruction
belong to a block / scope that is not the initial decl scope of the
function but when these instructions belong to an inlined function:
the LBB and LBE labels (block begin and block end) are used to compute
the low_pc and high_pc of the inlined function.

The solution is simple and trivial: When the block_locators_locs
VARRAY is build, the pro- and epilogue locator values are stored
in the variables prologue_locator and epilogue_locator respectively.
We only have to compare the requested locator to these values
and return the initial decl scope of the function.

Ok for mainline?


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

ChangeLog:

2003-11-20  Carlo Wood  <carlo@alinoe.com>

	PR debug/12319
        * cfglayout.c (insn_scope):  Use prologue_locator and
	epilogue_locator; return the outer function scope for
	pro- and epilogue insns.

Index: cfglayout.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/cfglayout.c,v
retrieving revision 1.46
diff -u -d -p -r1.46 cfglayout.c
--- cfglayout.c	19 Aug 2003 23:21:52 -0000	1.46
+++ cfglayout.c	20 Sep 2003 16:26:59 -0000
@@ -415,6 +415,18 @@ insn_scope (rtx insn)
   int min = 0;
   int loc = INSN_LOCATOR (insn);
 
+  /* When block_locators_locs was initialized, the pro- and epilogue
+     insns didn't exist yet and can therefore not be found this way.
+     But we know that they belong to the outer most block of the
+     current function.
+     Without this test, the prologue would be put inside the block of
+     the first valid instruction in the function and when that first
+     insn is part of an inlined function then the low_pc of that
+     inlined function is messed up.  Likewise for the epilogue and
+     the last valid instruction. */
+  if (loc == prologue_locator || loc == epilogue_locator)
+    return DECL_INITIAL (cfun->decl);
+
   if (!max || !loc)
     return NULL;
   while (1)


-- 
Carlo Wood <carlo@alinoe.com>


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