[llvm-bugs] [Bug 52320] New: [BranchFolding] Merging blocks with identical PATCHPOINTs

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 26 02:27:28 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=52320

            Bug ID: 52320
           Summary: [BranchFolding]  Merging blocks with identical
                    PATCHPOINTs
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: paulsson at linux.vnet.ibm.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 25392
  --> https://bugs.llvm.org/attachment.cgi?id=25392&action=edit
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..?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211026/1ec3a865/attachment.html>


More information about the llvm-bugs mailing list