<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 -O3 with -flto"
   href="https://bugs.llvm.org/show_bug.cgi?id=51110">51110</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Emitted binary code changes when -g is enabled at -O3 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>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The .text section for the following program (transformed_program.c) changes
after toggling the -g flag.

$ cat transformed_program0.c
int printf(const char *, ...);
long a[8];
long *b;
long c[7];
int(d)(int l) { return 0; }
int main() {
  long *e = &c[6], *f = &a[2];
  b = e;
  int g = f != e, h = d(g);
  *b = 7;
i:;
  int k = h < 8;
  if (!k)
    goto j;
  printf("%d\n", (int)a[h]);
  h = h + 1;
  goto i;
j:;
}

$ 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>
9cfec72ffeec242783b70e792c50bd163dcf9dbb)
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 -flto -O3 -w transformed_program0.c ; objdump --disassemble a.out
<span class="quote">> "no-g.txt"</span >
$ clang-trunk -g -flto -O3 -w transformed_program0.c ; objdump --disassemble
a.out > "g.txt"
$ diff no-g.txt g.txt
40,41c40,41
<   401053:     49 c7 c0 20 12 40 00    mov    $0x401220,%r8
<   40105a:     48 c7 c1 b0 11 40 00    mov    $0x4011b0,%rcx
---
<span class="quote">>   401053:      49 c7 c0 40 12 40 00    mov    $0x401240,%r8
>   40105a:  48 c7 c1 d0 11 40 00    mov    $0x4011d0,%rcx</span >
113,144c113,136
<   401131:     bf 04 20 40 00          mov    $0x402004,%edi
<   401136:     31 f6                   xor    %esi,%esi
<   401138:     31 c0                   xor    %eax,%eax
<   40113a:     e8 f1 fe ff ff          callq  401030 <printf@plt>
<   40113f:     bf 04 20 40 00          mov    $0x402004,%edi
<   401144:     31 f6                   xor    %esi,%esi
<   401146:     31 c0                   xor    %eax,%eax
<   401148:     e8 e3 fe ff ff          callq  401030 <printf@plt>
<   40114d:     bf 04 20 40 00          mov    $0x402004,%edi
<   401152:     31 f6                   xor    %esi,%esi
<   401154:     31 c0                   xor    %eax,%eax
<   401156:     e8 d5 fe ff ff          callq  401030 <printf@plt>
<   40115b:     bf 04 20 40 00          mov    $0x402004,%edi
<   401160:     31 f6                   xor    %esi,%esi
<   401162:     31 c0                   xor    %eax,%eax
<   401164:     e8 c7 fe ff ff          callq  401030 <printf@plt>
<   401169:     bf 04 20 40 00          mov    $0x402004,%edi
<   40116e:     31 f6                   xor    %esi,%esi
<   401170:     31 c0                   xor    %eax,%eax
<   401172:     e8 b9 fe ff ff          callq  401030 <printf@plt>
<   401177:     bf 04 20 40 00          mov    $0x402004,%edi
<   40117c:     31 f6                   xor    %esi,%esi
<   40117e:     31 c0                   xor    %eax,%eax
<   401180:     e8 ab fe ff ff          callq  401030 <printf@plt>
<   401185:     bf 04 20 40 00          mov    $0x402004,%edi
<   40118a:     31 f6                   xor    %esi,%esi
<   40118c:     31 c0                   xor    %eax,%eax
<   40118e:     e8 9d fe ff ff          callq  401030 <printf@plt>
<   401193:     bf 04 20 40 00          mov    $0x402004,%edi
<   401198:     31 f6                   xor    %esi,%esi
<   40119a:     31 c0                   xor    %eax,%eax
<   40119c:     e8 8f fe ff ff          callq  401030 <printf@plt>
---
<span class="quote">>   401131:      48 c7 05 34 2f 00 00    movq   $0x7,0x2f34(%rip)        # 404070 <c+0x30>
>   401138:  07 00 00 00
>   40113c:  8b 35 3e 2f 00 00       mov    0x2f3e(%rip),%esi        # 404080 <a>
>   401142:  bf 04 20 40 00          mov    $0x402004,%edi
>   401147:  31 c0                   xor    %eax,%eax
>   401149:  e8 e2 fe ff ff          callq  401030 <printf@plt>
>   40114e:  8b 35 34 2f 00 00       mov    0x2f34(%rip),%esi        # 404088 <a+0x8>
>   401154:  bf 04 20 40 00          mov    $0x402004,%edi
>   401159:  31 c0                   xor    %eax,%eax
>   40115b:  e8 d0 fe ff ff          callq  401030 <printf@plt>
>   401160:  8b 35 2a 2f 00 00       mov    0x2f2a(%rip),%esi        # 404090 <a+0x10>
>   401166:  bf 04 20 40 00          mov    $0x402004,%edi
>   40116b:  31 c0                   xor    %eax,%eax
>   40116d:  e8 be fe ff ff          callq  401030 <printf@plt>
>   401172:  8b 35 20 2f 00 00       mov    0x2f20(%rip),%esi        # 404098 <a+0x18>
>   401178:  bf 04 20 40 00          mov    $0x402004,%edi
>   40117d:  31 c0                   xor    %eax,%eax
>   40117f:  e8 ac fe ff ff          callq  401030 <printf@plt>
>   401184:  8b 35 16 2f 00 00       mov    0x2f16(%rip),%esi        # 4040a0 <a+0x20>
>   40118a:  bf 04 20 40 00          mov    $0x402004,%edi
>   40118f:  31 c0                   xor    %eax,%eax
>   401191:  e8 9a fe ff ff          callq  401030 <printf@plt>
>   401196:  8b 35 0c 2f 00 00       mov    0x2f0c(%rip),%esi        # 4040a8 <a+0x28>
>   40119c:  bf 04 20 40 00          mov    $0x402004,%edi</span >
146,192c138,191
<   4011a3:     59                      pop    %rcx
<   4011a4:     c3                      retq
<   4011a5:     66 2e 0f 1f 84 00 00    nopw   %cs:0x0(%rax,%rax,1)
<   4011ac:     00 00 00
<   4011af:     90                      nop
<
< 00000000004011b0 <__libc_csu_init>:
<   4011b0:     f3 0f 1e fa             endbr64
<   4011b4:     41 57                   push   %r15
<   4011b6:     4c 8d 3d 53 2c 00 00    lea    0x2c53(%rip),%r15        #
403e10 <__frame_dummy_init_array_entry>
<   4011bd:     41 56                   push   %r14
<   4011bf:     49 89 d6                mov    %rdx,%r14
<   4011c2:     41 55                   push   %r13
<   4011c4:     49 89 f5                mov    %rsi,%r13
<   4011c7:     41 54                   push   %r12
<   4011c9:     41 89 fc                mov    %edi,%r12d
<   4011cc:     55                      push   %rbp
<   4011cd:     48 8d 2d 44 2c 00 00    lea    0x2c44(%rip),%rbp        #
403e18 <__do_global_dtors_aux_fini_array_entry>
<   4011d4:     53                      push   %rbx
<   4011d5:     4c 29 fd                sub    %r15,%rbp
<   4011d8:     48 83 ec 08             sub    $0x8,%rsp
<   4011dc:     e8 1f fe ff ff          callq  401000 <_init>
<   4011e1:     48 c1 fd 03             sar    $0x3,%rbp
<   4011e5:     74 1f                   je     401206 <__libc_csu_init+0x56>
<   4011e7:     31 db                   xor    %ebx,%ebx
<   4011e9:     0f 1f 80 00 00 00 00    nopl   0x0(%rax)
<   4011f0:     4c 89 f2                mov    %r14,%rdx
<   4011f3:     4c 89 ee                mov    %r13,%rsi
<   4011f6:     44 89 e7                mov    %r12d,%edi
<   4011f9:     41 ff 14 df             callq  *(%r15,%rbx,8)
<   4011fd:     48 83 c3 01             add    $0x1,%rbx
<   401201:     48 39 dd                cmp    %rbx,%rbp
<   401204:     75 ea                   jne    4011f0 <__libc_csu_init+0x40>
<   401206:     48 83 c4 08             add    $0x8,%rsp
<   40120a:     5b                      pop    %rbx
<   40120b:     5d                      pop    %rbp
<   40120c:     41 5c                   pop    %r12
<   40120e:     41 5d                   pop    %r13
<   401210:     41 5e                   pop    %r14
<   401212:     41 5f                   pop    %r15
<   401214:     c3                      retq
<   401215:     66 66 2e 0f 1f 84 00    data16 nopw %cs:0x0(%rax,%rax,1)
<   40121c:     00 00 00 00
<
< 0000000000401220 <__libc_csu_fini>:
<   401220:     f3 0f 1e fa             endbr64
<   401224:     c3                      retq
---
<span class="quote">>   4011a3:      e8 88 fe ff ff          callq  401030 <printf@plt>
>   4011a8:  8b 35 02 2f 00 00       mov    0x2f02(%rip),%esi        # 4040b0 <a+0x30>
>   4011ae:  bf 04 20 40 00          mov    $0x402004,%edi
>   4011b3:  31 c0                   xor    %eax,%eax
>   4011b5:  e8 76 fe ff ff          callq  401030 <printf@plt>
>   4011ba:  8b 35 f8 2e 00 00       mov    0x2ef8(%rip),%esi        # 4040b8 <a+0x38>
>   4011c0:  bf 04 20 40 00          mov    $0x402004,%edi
>   4011c5:  31 c0                   xor    %eax,%eax
>   4011c7:  e8 64 fe ff ff          callq  401030 <printf@plt>
>   4011cc:  31 c0                   xor    %eax,%eax
>   4011ce:  59                      pop    %rcx
>   4011cf:  c3                      retq</span >
>
<span class="quote">> 00000000004011d0 <__libc_csu_init>:
>   4011d0:  f3 0f 1e fa             endbr64
>   4011d4:  41 57                   push   %r15
>   4011d6:  4c 8d 3d 33 2c 00 00    lea    0x2c33(%rip),%r15        # 403e10 <__frame_dummy_init_array_entry>
>   4011dd:  41 56                   push   %r14
>   4011df:  49 89 d6                mov    %rdx,%r14
>   4011e2:  41 55                   push   %r13
>   4011e4:  49 89 f5                mov    %rsi,%r13
>   4011e7:  41 54                   push   %r12
>   4011e9:  41 89 fc                mov    %edi,%r12d
>   4011ec:  55                      push   %rbp
>   4011ed:  48 8d 2d 24 2c 00 00    lea    0x2c24(%rip),%rbp        # 403e18 <__do_global_dtors_aux_fini_array_entry>
>   4011f4:  53                      push   %rbx
>   4011f5:  4c 29 fd                sub    %r15,%rbp
>   4011f8:  48 83 ec 08             sub    $0x8,%rsp
>   4011fc:  e8 ff fd ff ff          callq  401000 <_init>
>   401201:  48 c1 fd 03             sar    $0x3,%rbp
>   401205:  74 1f                   je     401226 <__libc_csu_init+0x56>
>   401207:  31 db                   xor    %ebx,%ebx
>   401209:  0f 1f 80 00 00 00 00    nopl   0x0(%rax)
>   401210:  4c 89 f2                mov    %r14,%rdx
>   401213:  4c 89 ee                mov    %r13,%rsi
>   401216:  44 89 e7                mov    %r12d,%edi
>   401219:  41 ff 14 df             callq  *(%r15,%rbx,8)
>   40121d:  48 83 c3 01             add    $0x1,%rbx
>   401221:  48 39 dd                cmp    %rbx,%rbp
>   401224:  75 ea                   jne    401210 <__libc_csu_init+0x40>
>   401226:  48 83 c4 08             add    $0x8,%rsp
>   40122a:  5b                      pop    %rbx
>   40122b:  5d                      pop    %rbp
>   40122c:  41 5c                   pop    %r12
>   40122e:  41 5d                   pop    %r13
>   401230:  41 5e                   pop    %r14
>   401232:  41 5f                   pop    %r15
>   401234:  c3                      retq
>   401235:  66 66 2e 0f 1f 84 00    data16 nopw %cs:0x0(%rax,%rax,1)
>   40123c:  00 00 00 00</span >
>
<span class="quote">> 0000000000401240 <__libc_csu_fini>:
>   401240:  f3 0f 1e fa             endbr64
>   401244:  c3                      retq</span >
196,200c195,199
< 0000000000401228 <_fini>:
<   401228:     f3 0f 1e fa             endbr64
<   40122c:     48 83 ec 08             sub    $0x8,%rsp
<   401230:     48 83 c4 08             add    $0x8,%rsp
<   401234:     c3                      retq
---
<span class="quote">> 0000000000401248 <_fini>:
>   401248:  f3 0f 1e fa             endbr64
>   40124c:  48 83 ec 08             sub    $0x8,%rsp
>   401250:  48 83 c4 08             add    $0x8,%rsp
>   401254:  c3                      retq</span ></pre>
        </div>
      </p>


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

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