<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Emitted binary code changes when -g is enabled at -O2 with -flto"
   href="https://bugs.llvm.org/show_bug.cgi?id=51196">51196</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Emitted binary code changes when -g is enabled at -O2 with -flto
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Loop Optimizer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>tlwang@uwaterloo.ca
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>cnsun@uwaterloo.ca, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Blocks</th>
          <td>37728
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Note: this might be a duplicate of <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Emitted binary code changes when -g is enabled at -O3 with -flto"
   href="show_bug.cgi?id=51110">https://bugs.llvm.org/show_bug.cgi?id=51110</a>,
but I'm not sure because the programs look different.

The .text section for the following program (program0.c) changes after toggling
the -g flag.

$ cat program0.c
int a, f;
short b, d;
char c[3];
char e[2];
int main() {
  d = ({
    int g = &e[1] == &c[2];
    b;
  });
  a = a ^ c[2];
  for (; f < 2; f++)
    a = e[1];
}
$
$ clang-trunk -v
clang version 13.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
ab5ac659c81a453a3f58df94f39fe8ba3cd35918)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/cnsun/usr/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$
$ clang-trunk -O2 -flto program0.c ; objdump --disassemble --section=.text >
no_g.txt
$ clang-trunk -g -O2 -flto program0.c ; objdump --disassemble --section=.text >
g.txt
$ diff no_g.txt g.txt
16,17c16,17
<   401033:     49 c7 c0 a0 11 40 00    mov    $0x4011a0,%r8
<   40103a:     48 c7 c1 30 11 40 00    mov    $0x401130,%rcx
---
<span class="quote">>   401033:      49 c7 c0 b0 11 40 00    mov    $0x4011b0,%r8
>   40103a:  48 c7 c1 40 11 40 00    mov    $0x401140,%rcx</span >
88,136c88,132
<   401110:     80 3d 15 2f 00 00 00    cmpb   $0x0,0x2f15(%rip)        #
40402c <f>
<   401117:     75 07                   jne    401120 <main+0x10>
<   401119:     c6 05 0c 2f 00 00 01    movb   $0x1,0x2f0c(%rip)        #
40402c <f>
<   401120:     31 c0                   xor    %eax,%eax
<   401122:     c3                      retq
<   401123:     66 2e 0f 1f 84 00 00    nopw   %cs:0x0(%rax,%rax,1)
<   40112a:     00 00 00
<   40112d:     0f 1f 00                nopl   (%rax)
<
< 0000000000401130 <__libc_csu_init>:
<   401130:     f3 0f 1e fa             endbr64
<   401134:     41 57                   push   %r15
<   401136:     4c 8d 3d 13 2d 00 00    lea    0x2d13(%rip),%r15        #
403e50 <__frame_dummy_init_array_entry>
<   40113d:     41 56                   push   %r14
<   40113f:     49 89 d6                mov    %rdx,%r14
<   401142:     41 55                   push   %r13
<   401144:     49 89 f5                mov    %rsi,%r13
<   401147:     41 54                   push   %r12
<   401149:     41 89 fc                mov    %edi,%r12d
<   40114c:     55                      push   %rbp
<   40114d:     48 8d 2d 04 2d 00 00    lea    0x2d04(%rip),%rbp        #
403e58 <__do_global_dtors_aux_fini_array_entry>
<   401154:     53                      push   %rbx
<   401155:     4c 29 fd                sub    %r15,%rbp
<   401158:     48 83 ec 08             sub    $0x8,%rsp
<   40115c:     e8 9f fe ff ff          callq  401000 <_init>
<   401161:     48 c1 fd 03             sar    $0x3,%rbp
<   401165:     74 1f                   je     401186 <__libc_csu_init+0x56>
<   401167:     31 db                   xor    %ebx,%ebx
<   401169:     0f 1f 80 00 00 00 00    nopl   0x0(%rax)
<   401170:     4c 89 f2                mov    %r14,%rdx
<   401173:     4c 89 ee                mov    %r13,%rsi
<   401176:     44 89 e7                mov    %r12d,%edi
<   401179:     41 ff 14 df             callq  *(%r15,%rbx,8)
<   40117d:     48 83 c3 01             add    $0x1,%rbx
<   401181:     48 39 dd                cmp    %rbx,%rbp
<   401184:     75 ea                   jne    401170 <__libc_csu_init+0x40>
<   401186:     48 83 c4 08             add    $0x8,%rsp
<   40118a:     5b                      pop    %rbx
<   40118b:     5d                      pop    %rbp
<   40118c:     41 5c                   pop    %r12
<   40118e:     41 5d                   pop    %r13
<   401190:     41 5e                   pop    %r14
<   401192:     41 5f                   pop    %r15
<   401194:     c3                      retq
<   401195:     66 66 2e 0f 1f 84 00    data16 nopw %cs:0x0(%rax,%rax,1)
<   40119c:     00 00 00 00
<
< 00000000004011a0 <__libc_csu_fini>:
<   4011a0:     f3 0f 1e fa             endbr64
---
<span class="quote">>   401110:      0f be 05 16 2f 00 00    movsbl 0x2f16(%rip),%eax        # 40402d <c+0x2>
>   401117:  31 05 13 2f 00 00       xor    %eax,0x2f13(%rip)        # 404030 <a>
>   40111d:  80 3d 10 2f 00 00 00    cmpb   $0x0,0x2f10(%rip)        # 404034 <f>
>   401124:  75 14                   jne    40113a <main+0x2a>
>   401126:  0f be 05 fd 2e 00 00    movsbl 0x2efd(%rip),%eax        # 40402a <e+0x1>
>   40112d:  89 05 fd 2e 00 00       mov    %eax,0x2efd(%rip)        # 404030 <a>
>   401133:  c6 05 fa 2e 00 00 01    movb   $0x1,0x2efa(%rip)        # 404034 <f>
>   40113a:  31 c0                   xor    %eax,%eax
>   40113c:  c3                      retq
>   40113d:  0f 1f 00                nopl   (%rax)</span >
>
<span class="quote">> 0000000000401140 <__libc_csu_init>:
>   401140:  f3 0f 1e fa             endbr64
>   401144:  41 57                   push   %r15
>   401146:  4c 8d 3d 03 2d 00 00    lea    0x2d03(%rip),%r15        # 403e50 <__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 f4 2c 00 00    lea    0x2cf4(%rip),%rbp        # 403e58 <__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</span >
137a134,139
<span class="quote">>   4011a5:      66 66 2e 0f 1f 84 00    data16 nopw %cs:0x0(%rax,%rax,1)
>   4011ac:  00 00 00 00</span >
>
<span class="quote">> 00000000004011b0 <__libc_csu_fini>:
>   4011b0:  f3 0f 1e fa             endbr64
>   4011b4:  c3                      retq</span ></pre>
        </div>
      </p>

        <div id="referenced">
          <hr style="border: 1px dashed #969696">
          <b>Referenced Bugs:</b>
          <ul>
              <li>
                [<a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [meta] Make llvm passes debug info invariant"
   href="https://bugs.llvm.org/show_bug.cgi?id=37728">Bug 37728</a>] [meta] Make llvm passes debug info invariant
              </li>
          </ul>
        </div>
        <br>

      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>