[llvm-bugs] [Bug 37540] New: [NewGVN] Miscompile with nonnull metadata

via llvm-bugs llvm-bugs at lists.llvm.org
Mon May 21 06:40:19 PDT 2018


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

            Bug ID: 37540
           Summary: [NewGVN] Miscompile with nonnull metadata
           Product: libraries
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: nikita.ppv at gmail.com
                CC: llvm-bugs at lists.llvm.org

NewGVN optimizes:

define i1 @test({}** %arg, i1 %arg2) {
    br i1 %arg2, label %bb1, label %bb2

bb1:
    %load1 = load {}*, {}** %arg
    %cmp1 = icmp eq {}* %load1, null
    ret i1 %cmp1

bb2:
    %load2 = load {}*, {}** %arg, !nonnull !1
    %cmp2 = icmp eq {}* %load2, null
    ret i1 %cmp2
}

!1 = !{}

into:

define i1 @test({}** %arg, i1 %arg2) {
  br i1 %arg2, label %bb1, label %bb2

bb1:                                              ; preds = %0
  ret i1 false

bb2:                                              ; preds = %0
  ret i1 false
}

The reason is that %load1 and %load2 are found congruent with %load2 chosen as
leader. Thus %cmp1 in bb1 calls SimplifyCmp with icmp eq {}* %load2, null,
which is simplified to i1 false based on the !nonnull metadata of %load2.
However, this metadata is not applicable in this branch.

This bug prevents bootstrapping of rustc under newgvn.

-- 
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/20180521/c79c6c2f/attachment-0001.html>


More information about the llvm-bugs mailing list