<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - changeToUnreachable makes questionable decisions (and modifies the CFG)"
   href="https://llvm.org/bugs/show_bug.cgi?id=31801">31801</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>changeToUnreachable makes questionable decisions (and modifies the CFG)
          </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>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>davide@freebsd.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>chandlerc@gmail.com, dberlin@dberlin.org, filcab@gmail.com, Florian.Hahn@arm.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, simon.f.whittaker@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Some recent changes in NewGVN revealed a couple of issues in
changeToUnreachable().
1) It's declared in Local.h, although it modifies the CFG (it shouldn't :().
2) It takes a `preserveLCSSA` boolean argument which prevents removal of
useless PHI nodes (the argument is passed down to
BasicBlock::removePredecessor). As discussed with Danny, this doesn't seem
enough to preserve LCSSA, but it could just be that the arugment of the
function is misnamed.

We should:
1) Modify the function so that it preserves the CFG
Danny suggested we could probably just insert before the terminator

new StoreInst(UndefValue::get(Int8Ty), Constant::getNullValue(Int8Ty\
getPointerTo()), TI)

so that SimplifyCFG knows how to remove it.

2) Understand how `preserveLCSSA` is used, and either fix to really preserve
LCSSA or change the parameter name (and document it, while we're there:)</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>