<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 - load from @i hoisted before store to @i by -speculative-execution"
   href="https://bugs.llvm.org/show_bug.cgi?id=32964">32964</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>load from @i hoisted before store to @i by -speculative-execution
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>mikael.holmen@ericsson.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=18415" name="attach_18415" title="reproducer">attachment 18415</a> <a href="attachment.cgi?id=18415&action=edit" title="reproducer">[details]</a></span>
reproducer

opt -S -speculative-execution -o - spec.ll

In the input we have:

entry:
  %0 = load i8, i8* @i
  %tobool = icmp eq i8 %0, 0
  br i1 %tobool, label %if.end, label %if.then

if.then:                                          ; preds = %entry
  store i8 0, i8* @i
  %.pre = load i8, i8* @i
  br label %if.end

and in the output we get:

entry:
  %0 = load i8, i8* @i
  %tobool = icmp eq i8 %0, 0
  %.pre = load i8, i8* @i
  br i1 %tobool, label %if.end, label %if.then

if.then:                                          ; preds = %entry
  store i8 0, i8* @i
  br label %if.end

so

  %.pre = load i8, i8* @i

has been moved before

  store i8 0, i8* @i

and we'll load the old (wrong) value.

This started going wrong after commit

 SpeculativeExecution: Stop using whitelist for costs

but I suppose that is because costs in general went down
with that patch so it triggers in more cases.

This seems very broken to me and I see these errors a lot in our out-of-tree
backend.</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>