<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 - SystemZ reordered store/compare clobbers CC"
   href="https://bugs.llvm.org/show_bug.cgi?id=47736">47736</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>SystemZ reordered store/compare clobbers CC
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>11.0
          </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>Backend: SystemZ
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jistone@redhat.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>xref: <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1883457">https://bugzilla.redhat.com/show_bug.cgi?id=1883457</a>
xref: <a href="https://github.com/rust-lang/rust/issues/77382">https://github.com/rust-lang/rust/issues/77382</a>

In one particular Rust test case, we're seeing code miss a branch that should
be taken, and in my limited knowledge of Z, it looks like a clobbered
condition.

The IR is too big for bugzilla, and I wasn't able to reduce it, so I uploaded
it here:
<a href="https://jistone.fedorapeople.org/bz1883457/libcoreinst-bc0e880cd40833af.libcoreinst.354hlw07-cgu.0.rcgu.ll.xz">https://jistone.fedorapeople.org/bz1883457/libcoreinst-bc0e880cd40833af.libcoreinst.354hlw07-cgu.0.rcgu.ll.xz</a>

The function in question is
_ZN11libcoreinst8download5tests22test_write_image_limit17hdd3aea2f720151ebE.

In particular, this block:

bb60.i:                                           ; preds = %bb59.i
  call void @llvm.lifetime.end.p0i8(i64 48, i8* nonnull %444), !dbg !182775,
!noalias !181924
  call void @llvm.lifetime.end.p0i8(i64 16, i8* nonnull %370), !dbg !182775,
!noalias !181924
  %452 = bitcast %"std::option::Option<std::vec::Vec<u8>>"* %signature.i to
{}**, !dbg !182787
  store {}* null, {}** %452, align 8, !dbg !182787, !noalias !181924
  call void @llvm.dbg.value(metadata %"std::io::Error"* %err4.i, metadata
!6256, metadata !DIExpression()), !dbg !182788
  call void @llvm.dbg.value(metadata %"std::io::Error"* %err4.i, metadata
!6247, metadata !DIExpression()), !dbg !182790
  %453 = load i8, i8* %441, align 8, !dbg !182792, !range !20068, !noalias
!181924
  %switch.i.i.i251 = icmp ult i8 %453, 2, !dbg !182792
  br i1 %switch.i.i.i251, label %bb61.i, label %bb2.i.i.i252, !dbg !182792

So that's basically a store null, then branch less than 2.

Here's "llc -O0", which looks ok:

.LBB387_319:                            # %bb60.i
        #DEBUG_VALUE: out <- [DW_OP_plus_uconst 4732] [$r15d+0]
        #DEBUG_VALUE: sources:self <- [DW_OP_plus_uconst 9056,
DW_OP_stack_value] $r15d
        #DEBUG_VALUE: precious <- [DW_OP_LLVM_fragment 64 64] 11
        #DEBUG_VALUE: offset <- 4194304
        .loc    64 134 17               # src/source.rs:134:17
        lay     %r1, 8192(%r15)
        mvghi   2488(%r1), 0
.Ltmp56831:
        #DEBUG_VALUE: drop_in_place<std::io::error::Error>: <-
[DW_OP_plus_uconst 10800, DW_OP_stack_value] $r15d
        #DEBUG_VALUE: drop_in_place<std::io::error::Repr>: <-
[DW_OP_plus_uconst 10800, DW_OP_stack_value] $r15d
        .loc    15 175 1                #
/rustc/beb5ae474d2835962ebdf7416bd1c9ad864fe101/library/core/src/ptr/mod.rs:175:1
        lg      %r1, 4000(%r15)         # 8-byte Folded Reload
        llc     %r0, 0(%r1)
        chi     %r0, 2
        jl      .LBB387_325
        j       .LBB387_320


Here's "llc -O1":

# %bb.193:                              # %bb60.i
        #DEBUG_VALUE: sources:self <- [DW_OP_plus_uconst 616,
DW_OP_stack_value] $r15d
        #DEBUG_VALUE: offset <- 4194304
        #DEBUG_VALUE: precious <- [DW_OP_LLVM_fragment 64 64] 11
        .loc    9 175 1                 #
/rustc/beb5ae474d2835962ebdf7416bd1c9ad864fe101/library/core/src/ptr/mod.rs:175:1
        cli     712(%r15), 2
.Ltmp39998:
        .loc    64 134 17               # src/source.rs:134:17
        llilh   %r1, 16
        agr     %r1, %r15
        mvghi   912(%r1), 0
.Ltmp39999:
        #DEBUG_VALUE: drop_in_place<std::io::error::Repr>: <-
[DW_OP_plus_uconst 712, DW_OP_stack_value] $r15d
        #DEBUG_VALUE: drop_in_place<std::io::error::Error>: <-
[DW_OP_plus_uconst 712, DW_OP_stack_value] $r15d
        .loc    9 175 1                 #
/rustc/beb5ae474d2835962ebdf7416bd1c9ad864fe101/library/core/src/ptr/mod.rs:175:1
        jl      .LBB387_201

It looks like CLI will set the CC we want for the jump, but AGR also sets CC,
so then JL has the wrong condition.</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>