public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/100464] New: emitted binary code changes when -g is enabled at -O3
@ 2021-05-06 23:16 cnsun at uwaterloo dot ca
  2021-05-06 23:35 ` [Bug tree-optimization/100464] [11/12 Regression] " pinskia at gcc dot gnu.org
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: cnsun at uwaterloo dot ca @ 2021-05-06 23:16 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100464
           Summary: emitted binary code changes when -g is enabled at -O3
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cnsun at uwaterloo dot ca
  Target Milestone: ---

For the following program, when I turn on and off the flag '-g', the emitted
binary code by gcc-trunk is difference.


$ cat small.c
int *a;
static int b, c, d, e, g, h;
int f;
void i() {
  int *j[] = {&e, &b, &b, &d, &b, &b, &g, &e, &g, &b, &b,
              &b, &b, &g, &e, &e, &b, &b, &d, &b, &b, &e,
              &e, &g, &b, &b, &b, &b, &g, &e, &g, &c, &e};
  int **k = &j[5];
  for (; f;)
    b |= *a;
  *k = &h;
}
int main() {}
$
$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/scratch/software/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /tmp/tmp.PQ1fNP1RKJ-gcc-builder/gcc/configure
--enable-languages=c,c++,lto --enable-multiarch
--prefix=/scratch/software/gcc-trunk --disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210506 (experimental) [master revision
:60f7b28fb:e1fcf14f33e4f371aae8ae497ca58a760d53ca6d] (GCC)
$
$ gcc-trunk small.c -O3 -w ; objdump --disassemble a.out > "no-g.txt"
$ gcc-trunk small.c -O3 -w -g ; objdump --disassemble a.out > "g.txt"
$ diff no-g.txt g.txt
35,36c35,36
<   401043:     49 c7 c0 b0 11 40 00    mov    $0x4011b0,%r8
<   40104a:     48 c7 c1 40 11 40 00    mov    $0x401140,%rcx
---
>   401043:     49 c7 c0 d0 11 40 00    mov    $0x4011d0,%r8
>   40104a:     48 c7 c1 60 11 40 00    mov    $0x401160,%rcx
108,156c108,162
<   401128:     74 06                   je     401130 <i+0x10>
<   40112a:     eb fe                   jmp    40112a <i+0xa>
<   40112c:     0f 1f 40 00             nopl   0x0(%rax)
<   401130:     c3                      retq
<   401131:     66 2e 0f 1f 84 00 00    nopw   %cs:0x0(%rax,%rax,1)
<   401138:     00 00 00
<   40113b:     0f 1f 44 00 00          nopl   0x0(%rax,%rax,1)
<
< 0000000000401140 <__libc_csu_init>:
<   401140:     f3 0f 1e fa             endbr64
<   401144:     41 57                   push   %r15
<   401146:     4c 8d 3d f3 2c 00 00    lea    0x2cf3(%rip),%r15        #
403e40 <__frame_dummy_init_array_entry>
<   40114d:     41 56                   push   %r14
<   40114f:     49 89 d6                mov    %rdx,%r14
<   401152:     41 55                   push   %r13
<   401154:     49 89 f5                mov    %rsi,%r13
<   401157:     41 54                   push   %r12
<   401159:     41 89 fc                mov    %edi,%r12d
<   40115c:     55                      push   %rbp
<   40115d:     48 8d 2d e4 2c 00 00    lea    0x2ce4(%rip),%rbp        #
403e48 <__do_global_dtors_aux_fini_array_entry>
<   401164:     53                      push   %rbx
<   401165:     4c 29 fd                sub    %r15,%rbp
<   401168:     48 83 ec 08             sub    $0x8,%rsp
<   40116c:     e8 8f fe ff ff          callq  401000 <_init>
<   401171:     48 c1 fd 03             sar    $0x3,%rbp
<   401175:     74 1f                   je     401196 <__libc_csu_init+0x56>
<   401177:     31 db                   xor    %ebx,%ebx
<   401179:     0f 1f 80 00 00 00 00    nopl   0x0(%rax)
<   401180:     4c 89 f2                mov    %r14,%rdx
<   401183:     4c 89 ee                mov    %r13,%rsi
<   401186:     44 89 e7                mov    %r12d,%edi
<   401189:     41 ff 14 df             callq  *(%r15,%rbx,8)
<   40118d:     48 83 c3 01             add    $0x1,%rbx
<   401191:     48 39 dd                cmp    %rbx,%rbp
<   401194:     75 ea                   jne    401180 <__libc_csu_init+0x40>
<   401196:     48 83 c4 08             add    $0x8,%rsp
<   40119a:     5b                      pop    %rbx
<   40119b:     5d                      pop    %rbp
<   40119c:     41 5c                   pop    %r12
<   40119e:     41 5d                   pop    %r13
<   4011a0:     41 5e                   pop    %r14
<   4011a2:     41 5f                   pop    %r15
<   4011a4:     c3                      retq
<   4011a5:     66 66 2e 0f 1f 84 00    data16 nopw %cs:0x0(%rax,%rax,1)
<   4011ac:     00 00 00 00
<
< 00000000004011b0 <__libc_csu_fini>:
<   4011b0:     f3 0f 1e fa             endbr64
<   4011b4:     c3                      retq
---
>   401128:     74 26                   je     401150 <i+0x30>
>   40112a:     48 8b 15 07 2f 00 00    mov    0x2f07(%rip),%rdx        # 404038 <a>
>   401131:     8b 05 09 2f 00 00       mov    0x2f09(%rip),%eax        # 404040 <b>
>   401137:     66 0f 1f 84 00 00 00    nopw   0x0(%rax,%rax,1)
>   40113e:     00 00
>   401140:     0b 02                   or     (%rdx),%eax
>   401142:     89 05 f8 2e 00 00       mov    %eax,0x2ef8(%rip)        # 404040 <b>
>   401148:     eb f6                   jmp    401140 <i+0x20>
>   40114a:     66 0f 1f 44 00 00       nopw   0x0(%rax,%rax,1)
>   401150:     c3                      retq
>   401151:     66 2e 0f 1f 84 00 00    nopw   %cs:0x0(%rax,%rax,1)
>   401158:     00 00 00
>   40115b:     0f 1f 44 00 00          nopl   0x0(%rax,%rax,1)
>
> 0000000000401160 <__libc_csu_init>:
>   401160:     f3 0f 1e fa             endbr64
>   401164:     41 57                   push   %r15
>   401166:     4c 8d 3d d3 2c 00 00    lea    0x2cd3(%rip),%r15        # 403e40 <__frame_dummy_init_array_entry>
>   40116d:     41 56                   push   %r14
>   40116f:     49 89 d6                mov    %rdx,%r14
>   401172:     41 55                   push   %r13
>   401174:     49 89 f5                mov    %rsi,%r13
>   401177:     41 54                   push   %r12
>   401179:     41 89 fc                mov    %edi,%r12d
>   40117c:     55                      push   %rbp
>   40117d:     48 8d 2d c4 2c 00 00    lea    0x2cc4(%rip),%rbp        # 403e48 <__do_global_dtors_aux_fini_array_entry>
>   401184:     53                      push   %rbx
>   401185:     4c 29 fd                sub    %r15,%rbp
>   401188:     48 83 ec 08             sub    $0x8,%rsp
>   40118c:     e8 6f fe ff ff          callq  401000 <_init>
>   401191:     48 c1 fd 03             sar    $0x3,%rbp
>   401195:     74 1f                   je     4011b6 <__libc_csu_init+0x56>
>   401197:     31 db                   xor    %ebx,%ebx
>   401199:     0f 1f 80 00 00 00 00    nopl   0x0(%rax)
>   4011a0:     4c 89 f2                mov    %r14,%rdx
>   4011a3:     4c 89 ee                mov    %r13,%rsi
>   4011a6:     44 89 e7                mov    %r12d,%edi
>   4011a9:     41 ff 14 df             callq  *(%r15,%rbx,8)
>   4011ad:     48 83 c3 01             add    $0x1,%rbx
>   4011b1:     48 39 dd                cmp    %rbx,%rbp
>   4011b4:     75 ea                   jne    4011a0 <__libc_csu_init+0x40>
>   4011b6:     48 83 c4 08             add    $0x8,%rsp
>   4011ba:     5b                      pop    %rbx
>   4011bb:     5d                      pop    %rbp
>   4011bc:     41 5c                   pop    %r12
>   4011be:     41 5d                   pop    %r13
>   4011c0:     41 5e                   pop    %r14
>   4011c2:     41 5f                   pop    %r15
>   4011c4:     c3                      retq
>   4011c5:     66 66 2e 0f 1f 84 00    data16 nopw %cs:0x0(%rax,%rax,1)
>   4011cc:     00 00 00 00
>
> 00000000004011d0 <__libc_csu_fini>:
>   4011d0:     f3 0f 1e fa             endbr64
>   4011d4:     c3                      retq
160,164c166,170
< 00000000004011b8 <_fini>:
<   4011b8:     f3 0f 1e fa             endbr64
<   4011bc:     48 83 ec 08             sub    $0x8,%rsp
<   4011c0:     48 83 c4 08             add    $0x8,%rsp
<   4011c4:     c3                      retq
---
> 00000000004011d8 <_fini>:
>   4011d8:     f3 0f 1e fa             endbr64
>   4011dc:     48 83 ec 08             sub    $0x8,%rsp
>   4011e0:     48 83 c4 08             add    $0x8,%rsp
>   4011e4:     c3                      retq

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2022-02-18  9:29 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06 23:16 [Bug c/100464] New: emitted binary code changes when -g is enabled at -O3 cnsun at uwaterloo dot ca
2021-05-06 23:35 ` [Bug tree-optimization/100464] [11/12 Regression] " pinskia at gcc dot gnu.org
2021-05-07  7:22 ` rguenth at gcc dot gnu.org
2021-05-07  7:51 ` rguenth at gcc dot gnu.org
2021-05-07  8:12 ` jakub at gcc dot gnu.org
2021-05-07 13:22 ` cnsun at uwaterloo dot ca
2021-05-07 13:27 ` jakub at gcc dot gnu.org
2021-05-07 13:28 ` cnsun at uwaterloo dot ca
2021-05-07 13:36 ` jakub at gcc dot gnu.org
2021-05-07 13:38 ` cnsun at uwaterloo dot ca
2021-05-10  9:42 ` cvs-commit at gcc dot gnu.org
2021-05-10  9:46 ` [Bug tree-optimization/100464] [11 " rguenth at gcc dot gnu.org
2021-07-28  7:06 ` rguenth at gcc dot gnu.org
2021-10-13  5:13 ` cnsun at uwaterloo dot ca
2021-10-13  7:39 ` jakub at gcc dot gnu.org
2021-10-13 15:54 ` cnsun at uwaterloo dot ca
2022-02-18  9:29 ` cvs-commit at gcc dot gnu.org
2022-02-18  9:29 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).