<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 - [BranchFolding] Merging blocks with identical PATCHPOINTs"
   href="https://bugs.llvm.org/show_bug.cgi?id=52320">52320</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[BranchFolding]  Merging blocks with identical PATCHPOINTs
          </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>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=25392" name="attach_25392" title="testcase">attachment 25392</a> <a href="attachment.cgi?id=25392&action=edit" title="testcase">[details]</a></span>
testcase

I suspect that there is a bug in branch-folding as it merges two different
patchpoints into one:

define void @fun(i32 %Arg) {
  %c = icmp eq i32 %Arg, 0
  br i1 %c, label %patch0, label %patch1

patch0:
  call void (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.void(i64 0,
i32 14, i8* null, i32 0)
  br label %exit

patch1:
  call void (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.void(i64 0,
i32 14, i8* null, i32 0)
  br label %exit

exit:
  ret void
}

declare void @llvm.experimental.patchpoint.void(i64, i32, i8*, i32, ...)

llc -mtriple=s390x-linux-gnu -O3 -o - ./tc_patchpoint_branchfolder.ll

CFG optimizer will see that these are identical and therefore remove the
conditional branch:

# *** IR Dump After Control Flow Optimizer (branch-folder) ***:

bb.0 (%ir-block.0):
  STMG killed $r14d, killed $r15d, $r15d, 112
  $r15d = AGHI $r15d(tied-def 0), -160, implicit-def dead $cc
  CHI killed renamable $r2l, 0, implicit-def $cc
  PATCHPOINT 0, 14, 0, 0, 0, <regmask $f8d $f9d $f10d $f11d $f12d $f13d $f14d
$f15d $f8q $f9q $f12q $f13q $f8s $f9s $f10s $f11s $f12s $f13s $f14s $f15s $r6d
$r7d $r8d $r9d $r10d $r11d $r12d $r13d $r14d $r15d $r6h $r7h $r8h and 22
more...>, implicit-def dead early-clobber $r0d, implicit-def dead early-clobber
$r1d, implicit-def dead early-clobber $r14d
  $r14d, $r15d = LMG $r15d, 272
  Return

# End machine code for function fun

IIUC, PATCHPOINTs can not be considered identical as they will be patched
during runtime and therefore are conceptually always different..?</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>