<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 - Csmith program prints checksum at -O0, but crashes at -O1"
   href="https://bugs.llvm.org/show_bug.cgi?id=34827">34827</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Csmith program prints checksum at -O0, but crashes at -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>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>Common Code Generator Code
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>paulsson@linux.vnet.ibm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=19228" name="attach_19228" title="reduced testcase">attachment 19228</a> <a href="attachment.cgi?id=19228&action=edit" title="reduced testcase">[details]</a></span>
reduced testcase

Csmith generated a program that when built and executed at -O0 gives completely
different behaviour as when the same is done with -O1:

bin/clang -O0 -march=z13 tc_O1IllegalIns.ll -o a.out
./a.out 
checksum = F8458AC2

bin/clang -O1 -march=z13 tc_O1IllegalIns.ll -o a.out
./a.out 
Illegal instruction (core dumped)

>From what I am seeing, the Trap instruction is generated at -O1, but not at
-O0, and my best guess is that this difference is the reason for the crash with
-O1.

tc_O1IllegalIns.ll is the reduced input that has apparently the same behaviour
as the original csmith program.

Is this expected for some reason, or should this be fixed per the rule that
optimization levels should not affect the program result?</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>