In expand_stack_alignment, we decide we need to relign stack to support
big outgoing stack boundary.  Reload will make frame pointer available
for stack alignment by eliminating it to stack pointer.  After reload,
we realize that we don't need to relign stack after all, for example,
callee doesn't need such a big incoming stack boundary, and we won't
generate the stack alignment instruction.  But as far as reload and
debug info are concerned, skipping the stack alignment instruction is a
codegen optimization and shouldn't make any difference for reload and
debug info. However, dwarf2out.c checks the stack alignment instruction
to see if stack is realigned.  When the stack alignment instruction is
omitted, based_loc_descr doesn't know it should use stack pointer + offset
to access stack variables.  I am checking in this patch to add a
stack_realign_tried field to rtl_data so that based_loc_descr can
generate debug info for stack variables even if the stack alignment
instruction is omitted.

[EMAIL PROTECTED] stack-13]$ cat bug852.c
void
marker1 ()
{

}

int
main ()
{
  struct {
    char c[100];
  } cbig;

  struct {
    int i[800];
  } ibig;

  struct {
    long l[900];
  } lbig;

  struct {
    float f[200];
  } fbig;

  struct {
    double d[300];
  } dbig;

  struct {
    short s[400];
  } sbig;


  ibig.i[0] = 55;
  ibig.i[100] = 5;
  cbig.c[0] = '\0';
  cbig.c[99] = 'A';
  fbig.f[100] = 11.99999;
  dbig.d[202] = 9.99999999;
  sbig.s[90] = 255;
  lbig.l[333] = 999999999;

  marker1 ();
  return 0;
}
[EMAIL PROTECTED] stack-13]$ make bug852
/export/build/gnu/gcc-work/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc-work/build-x86_64-linux/gcc/ -m32 -g    -c -o bug852.o
bug852.c
/export/build/gnu/gcc-work/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc-work/build-x86_64-linux/gcc/ -m32 -o bug852 bug852.o
[EMAIL PROTECTED] stack-13]$ ./gdb bug852
GNU gdb (GDB) 6.8.50.20080728-cvs
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
(gdb) b main
Breakpoint 1 at 0x8048382: file bug852.c, line 35.
(gdb) r
Starting program: /export/home/hjl/bugs/gcc/stack-13/bug852 

Breakpoint 1, main () at bug852.c:35
35        ibig.i[0] = 55;
(gdb) next
36        ibig.i[100] = 5;
(gdb) p ibig
Cannot access memory at address 0xfffff004
(gdb)


-- 
           Summary: Incorrect debug info for stack variables with stack
                    alignment
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hjl dot tools at gmail dot com
GCC target triplet: i686-pc-linux-gnu


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

Reply via email to