<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 --- - [IfConverter/BranchFolding] An empty, non-reachable MBB is not removed."
   href="https://llvm.org/bugs/show_bug.cgi?id=27657">27657</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[IfConverter/BranchFolding] An empty, non-reachable MBB is not removed.
          </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>normal
          </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>dexonsmith@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=16312" name="attach_16312" title="llc input">attachment 16312</a> <a href="attachment.cgi?id=16312&action=edit" title="llc input">[details]</a></span>
llc input

The IfConverter should remove a block and its successor/predecessor edges from
MF because it is not reachable. BranchFolding fails to assist with this.
Interesting is to note that the probability of the edge to that block is 0,
which is another observation which means it could be removed.

Not having empty blocks is good generally for algorithms (I am experimenting
currently with something like global scheduler states to propagate processor
resources usage between regions.)

BB#0: derived from LLVM BB %entry
    Live Ins: %R2D
        CGHI %R2D, 0, %CC<imp-def>
        BRC 14, 6, <BB#2>, %CC<imp-use>
    Successors according to CFG: BB#1(0x30000000 / 0x80000000 = 37.50%)
BB#2(0x50000000 / 0x80000000 = 62.50%)

BB#1: derived from LLVM BB %return
    Predecessors according to CFG: BB#0
        %R2D<def> = LGHI 0
        Return %R2D<imp-use>

BB#2: derived from LLVM BB %if.end
    Live Ins: %R2D
    Predecessors according to CFG: BB#0
        CallJG <ga:@Perl_newSVsv>

=>

BB#0: derived from LLVM BB %entry
    Live Ins: %R2D
        CGHI %R2D, 0, %CC<imp-def>
        CallBRCL 14, 6, <ga:@Perl_newSVsv>
    Successors according to CFG: BB#1(0x80000000 / 0x80000000 = 100.00%)
BB#2(0x00000000 / 0x80000000 = 0.00%)

BB#1: derived from LLVM BB %return
    Predecessors according to CFG: BB#0
        %R2D<def> = LGHI 0
        Return %R2D<imp-use>

BB#2: derived from LLVM BB %if.end
    Live Ins: %R2D
    Predecessors according to CFG: BB#0

./bin/llc ./minperlio.ll -mtriple=s390x-linux-gnu -mcpu=z13

Could this be done in BranchFolder.cpp? I am not sure if there could be cases
lika a call to an empty block without successors to replace it..?</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>