[llvm-bugs] [Bug 47736] New: SystemZ reordered store/compare clobbers CC

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Oct 5 15:12:22 PDT 2020


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

            Bug ID: 47736
           Summary: SystemZ reordered store/compare clobbers CC
           Product: libraries
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: SystemZ
          Assignee: unassignedbugs at nondot.org
          Reporter: jistone at redhat.com
                CC: llvm-bugs at lists.llvm.org

xref: https://bugzilla.redhat.com/show_bug.cgi?id=1883457
xref: https://github.com/rust-lang/rust/issues/77382

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:
https://jistone.fedorapeople.org/bz1883457/libcoreinst-bc0e880cd40833af.libcoreinst.354hlw07-cgu.0.rcgu.ll.xz

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.

-- 
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/20201005/28cfc269/attachment.html>


More information about the llvm-bugs mailing list