<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 at -O0 when compiling through -S"
   href="https://bugs.llvm.org/show_bug.cgi?id=51571">51571</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Emitted binary code changes at -O0 when compiling through -S
          </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></table>
      <p>
        <div>
        <pre>The .text section of program.c changes when the program is compiled through -S.

$ cat program.c
int a;
void b() {
  if (a)
    ;
}
int main() {}
$
$ 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 -O0 -c program.c ; objdump --disassemble --section=.text
program.o > no_s.txt
$ clang-trunk -O0 -S program.c ; clang-trunk -O0 -c program.s ; objdump
--disassemble --section=.text program.o > s.txt
$ diff s.txt no_s.txt
12,18c12,16
<    c: 74 02                   je     10 <b+0x10>
<    e: eb 00                   jmp    10 <b+0x10>
<   10: 5d                      pop    %rbp
<   11: c3                      retq
<   12: 66 2e 0f 1f 84 00 00    nopw   %cs:0x0(%rax,%rax,1)
<   19: 00 00 00
<   1c: 0f 1f 40 00             nopl   0x0(%rax)
---
<span class="quote">>    c:  0f 84 05 00 00 00       je     17 <b+0x17>
>   12:      e9 00 00 00 00          jmpq   17 <b+0x17>
>   17:      5d                      pop    %rbp
>   18:      c3                      retq
>   19:      0f 1f 80 00 00 00 00    nopl   0x0(%rax)</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>