https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99334

--- Comment #6 from AJ D <aatsnps at gmail dot com> ---
Test Case:
----------

typedef long int intptr_t;
typedef unsigned long int uintptr_t;
typedef intptr_t DummyType14;
typedef intptr_t DummyType8;
typedef struct DummyType15IntT DummyType15T;
typedef struct DummyType15IntT *DummyType15;
typedef struct DummyType13Struct DummyType13;
typedef struct DummyType10Struct DummyType10;
typedef struct DummyType4_struct DummyType4_struct;
typedef struct DummyType4_struct *DummyType4;
typedef struct DummyType4_struct DummyType6;
typedef struct DummyType1Struct DummyType1;
typedef struct DummyType2Struct DummyType2;
typedef struct DummyType12Struct DummyType12;
typedef double DummyType19;
extern int DummyType20;
extern int DummyType21;
extern int DummyType22;

struct DummyType13Struct {
    DummyType13 *dm1;
    void *dm2;
};

typedef struct DummyType9Struct {
    DummyType13 *dm1;
    DummyType13 *dm2;
    int dm3;
} DummyType9;

struct DummyType10Struct
{
};

struct DummyType4_struct {
    void *dm1;
    int dm2;
    int dm3;
    int dm4;
};

typedef struct DummyType5Struct {
} DummyType5;

typedef union DummyType18Union {
    DummyType12 *dm1;
    uintptr_t dm2;
} DummyType18;

struct DummyType1Struct {
    DummyType15 dm1;
    unsigned int dm2:1;
};

typedef struct DummyType3Struct {
    DummyType18 dm1;
} DummyType3;

typedef struct DummyType11Struct {
    DummyType10 *dm1;
    double dm2;
} DummyType11;

typedef struct DummyType17Struct {
    DummyType2 *dm1;
} DummyType17;

typedef struct DummyType7Struct {
    DummyType6 *dm1;
    DummyType17 *dm2;
} DummyType7;

typedef struct DummyType16Struct {
    DummyType12 *dm1;
} DummyType16;

extern int func1(DummyType15, DummyType14, DummyType8*);
extern int func2(DummyType2*);
extern const DummyType12 *func3(DummyType2*);
extern DummyType9 *func4(const DummyType12*);
extern DummyType13* func5(void);
extern DummyType9* func6(void);
extern int func7(int);
extern DummyType16 *func8(double, DummyType12*);

DummyType5 *_func_with_dwarf_issue_(DummyType1 *arg1,
                                    DummyType2 *arg2,
                                    DummyType3 **arg3,
                                    unsigned int *arg4,
                                    unsigned int *arg5,
                                    DummyType4 *arg6,
                                    DummyType4 *arg7) {
    DummyType6 *var1 = 0;
    DummyType7 *var2 = 0;
    DummyType8 var3 = 0;

    *arg3 = 0;
    if (arg1->dm1 &&
            func1((arg1->dm1), (DummyType14) (func2(arg2)), (DummyType8 *)
(&var3))

                              ) {
        var2 = (DummyType7 *)var3;
        if (var2) {
            DummyType9 *var4 = 0;
            DummyType9 *var5 = 0;
            DummyType5 *var6 = 0;
            DummyType10 *var7 = 0;
            DummyType11 *var8 = 0;
            int var9 = 0;
            DummyType12 *var10 = 
                                  ((void *)0)
                                      ;

            var1 = var2->dm1;
            var4 = func4(func3(arg2));
            { DummyType13 *var11; var11 = (var4)->dm1; while(var11){ var7 =
(DummyType10 *) var11->dm2; var11 = var11->dm1; {
                for (; var9 < ((var1)->dm2); var9++) {
                    var8 = (DummyType21 = (var9), (DummyType21 < 0 ||
DummyType21 >= (var1)->dm2) ? func7(0) : 0, sizeof(DummyType11 *) !=
(var1)->dm4 ? func7(1) : 0, ((DummyType11 * *)((var1)->dm1))[DummyType21]);
                    if (var8->dm1) {
                        if (var10 && var2->dm2->dm1 && arg1->dm2) {
                            var10 = 0;
                        }

                        if (var2->dm2->dm1 &&
                                !var10) {
                            if (!var5) {
                                var5 = func6();
                            }
                            { DummyType13 *var11; var11 = func5(); var11->dm2 =
(void *)(var6); if(!((var5)->dm2)){ (var5)->dm1 = var11; (var5)->dm2 = var11; }
else{ (var5)->dm2->dm1 = var11; (var5)->dm2 = var11; } (var5)->dm3++;
var11->dm1 = (DummyType13 *)0; };
                        }
                        else {
                            func8(var8->dm2,
                                                                      var10);
                        }
                    }
                }
            } } };
        }
    }
    return 0;
}


GCC Command Line:
----------------

gcc -DSTATIC_LIBRARY -DINST64_ENABLE -Xassembler -mrelax-relocations=no -m64
-msse2 -fPIC -DSTATIC_LIBRARY -D__NO_STRING_INLINES -mstackrealign
-DPEBLK_THREAD -DINST64_ENABLE -DLINUX -m64 -rdynamic -DMM_MODE=0
-DLINUX_X86_64 -fPIC -DLINUX_X86_64 -DLONG_PTR_64 -DVM_LITTLE_ENDIAN
-DMM_MODE=0 -rdynamic -O3 -fPIC -fomit-frame-pointer -o test.o -O3 -msse2
-fno-strict-aliasing -fPIC -fomit-frame-pointer -c test.i


GCC Version / Configuration
---------------------------

vg-centos72-vm01> gcc --version
gcc (GCC) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

vg-centos72-vm01> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/depot/qsc/QSCS/GCC/libexec/gcc/x86_64-centos-linux/9.2.0/lto-wrapper
Target: x86_64-centos-linux
Configured with: ../src/gcc-9.2.0/configure --prefix=/depot/gcc-9.2.0
--enable-bootstrap --enable-threads=posix --disable-checking --with-system-zlib
--enable-__cxa_atexit --disable-libunwind-exceptions
--enable-languages=c,c++,fortran --disable-libgcj --with-cpu=generic
--build=x86_64-centos-linux
Thread model: posix
gcc version 9.2.0 (GCC) 
vg-centos72-vm01> 



Generated Assembly
------------------

0000000000000000 <_func_with_dwarf_issue_>:
   0:   4c 8d 54 24 08          lea    0x8(%rsp),%r10
   5:   48 83 e4 f0             and    $0xfffffffffffffff0,%rsp
   9:   41 ff 72 f8             pushq  -0x8(%r10)
   d:   55                      push   %rbp
-> e:   48 89 e5                mov    %rsp,%rbp
  11:   41 57                   push   %r15
  13:   41 56                   push   %r14
  15:   41 55                   push   %r13
  17:   41 54                   push   %r12
  19:   41 52                   push   %r10


Interrupted at the following instruction:

   e:   48 89 e5                mov    %rsp,%rbp

Generated DWARF
--------------
00000018 0000000000000044 0000001c FDE cie=00000000
pc=0000000000000000..000000000000018d
  DW_CFA_advance_loc: 5 to 0000000000000005
  DW_CFA_def_cfa: r10 (r10) ofs 0
  DW_CFA_advance_loc: 9 to 000000000000000e
  DW_CFA_expression: r6 (rbp) (DW_OP_breg6 (rbp): 0)
  DW_CFA_advance_loc: 13 to 000000000000001b
  DW_CFA_def_cfa_expression (DW_OP_breg6 (rbp): -40; DW_OP_deref)
  DW_CFA_expression: r15 (r15) (DW_OP_breg6 (rbp): -8)
  DW_CFA_expression: r14 (r14) (DW_OP_breg6 (rbp): -16)
  DW_CFA_expression: r13 (r13) (DW_OP_breg6 (rbp): -24)
  DW_CFA_expression: r12 (r12) (DW_OP_breg6 (rbp): -32)


Issue:
  DW_CFA_advance_loc: 9 to 000000000000000e
  DW_CFA_expression: r6 (rbp) (DW_OP_breg6 (rbp): 0)

At address 000000000000000e, %rbp is pointing to parent's stack frame, instead
of current stack frame.

Reply via email to