<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 -m32 -O1"
   href="https://bugs.llvm.org/show_bug.cgi?id=51570">51570</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Emitted binary code changes when -g is enabled at -m32 -O1
          </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>All
          </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>Common Code Generator Code
          </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>The .text section for the following program (program.c) changes after toggling
the -g flag.

$ cat program.c
struct a {
  int b[100];
} c, d;
__attribute__((noinline)) struct a e() { return d; }
int main() { c = e(); }
$
$ clang-trunk -v
clang version 14.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
3890ce708d4f94d0326172650ce22262f6b56661)
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 -c -m32 -O1 program.c ; objdump --disassemble --section=.text
program.o > no_g.txt
$ clang-trunk -c -m32 -O1 -g program.c ; objdump --disassemble --section=.text
program.o > g.txt
$ diff no_g.txt g.txt
26,39c26,40
<   31: 81 ec a4 01 00 00       sub    $0x1a4,%esp
<   37: 8d 74 24 14             lea    0x14(%esp),%esi
<   3b: 56                      push   %esi
<   3c: e8 fc ff ff ff          call   3d <main+0xd>
<   41: 83 c4 08                add    $0x8,%esp
<   44: 68 90 01 00 00          push   $0x190
<   49: 56                      push   %esi
<   4a: 68 00 00 00 00          push   $0x0
<   4f: e8 fc ff ff ff          call   50 <main+0x20>
<   54: 83 c4 10                add    $0x10,%esp
<   57: 31 c0                   xor    %eax,%eax
<   59: 81 c4 98 01 00 00       add    $0x198,%esp
<   5f: 5e                      pop    %esi
<   60: c3                      ret
---
<span class="quote">>   31:  81 ec 98 01 00 00       sub    $0x198,%esp
>   37:      83 ec 0c                sub    $0xc,%esp
>   3a:      8d 74 24 14             lea    0x14(%esp),%esi
>   3e:      56                      push   %esi
>   3f:      e8 fc ff ff ff          call   40 <main+0x10>
>   44:      83 c4 08                add    $0x8,%esp
>   47:      68 90 01 00 00          push   $0x190
>   4c:      56                      push   %esi
>   4d:      68 00 00 00 00          push   $0x0
>   52:      e8 fc ff ff ff          call   53 <main+0x23>
>   57:      83 c4 10                add    $0x10,%esp
>   5a:      31 c0                   xor    %eax,%eax
>   5c:      81 c4 98 01 00 00       add    $0x198,%esp
>   62:      5e                      pop    %esi
>   63:      c3                      ret</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>