[llvm-bugs] [Bug 31142] New: SROA is dropping !nonnull/!range metadata

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Nov 23 10:49:10 PST 2016


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

            Bug ID: 31142
           Summary: SROA is dropping !nonnull/!range metadata
           Product: libraries
           Version: 3.9
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: arielb1 at mail.tau.ac.il
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

When SROA optimizes out an alloca whose load contains a !nonnull metadata, the
load is dropped on the floor.

This can lead to the metadata being dropped in cases such as

    define float* @yummy_nonnull(float**) {
    entry-block:
      %buf = alloca float*

      %_0_i8 = bitcast float** %0 to i8*
      %_buf_i8 = bitcast float** %buf to i8*
      call void @llvm.memcpy.p0i8.p0i8.i64(i8* %_buf_i8, i8* %_0_i8, i64 8, i32
8, i1 false)

      %ret = load float*, float** %buf, align 8, !nonnull !0
      ret float* %ret
    }

    declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8*
nocapture readonly, i64, i32, i1)
    !0 = !{}

Which is optimized to
    define float* @yummy_nonnull(float** nocapture readonly) local_unnamed_addr
#0 {
    entry-block:
      %buf.0.copyload = load float*, float** %0, align 8
      ret float* %buf.0.copyload
    }


If this function is later inlined, the !nonnull metadata will no longer be
present to help further optimizations.

This is the cause of Rust bug https://github.com/rust-lang/rust/issues/37945.

-- 
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/20161123/fdc8c8c7/attachment.html>


More information about the llvm-bugs mailing list