[llvm-bugs] [Bug 34940] New: SROA miscomputes struct element offsets

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Oct 13 12:32:24 PDT 2017


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

            Bug ID: 34940
           Summary: SROA miscomputes struct element offsets
           Product: libraries
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Transformation Utilities
          Assignee: unassignedbugs at nondot.org
          Reporter: vtjnash at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 19270
  --> https://bugs.llvm.org/attachment.cgi?id=19270&action=edit
mixed-size-sroa-confusion

As can be seen from running the SROA pass on the attached IR, SROA seems to be
confused about the size of simple mixed-type struct aggregates. It seems to
think all of the struct elements must be the same? This can be seen from its
attempt to store an `i32 undef` to the i8 field, the missing store of the
second `i8 0`, and the effect of increasing the memcpy size on those.


$ ./opt -o - mixed-size-sroa.ll -S -sroa
define void @mixed_size_sroa_confusion({ { i32, i8 }, { i8, i8 } }*) {
top:
  %1 = bitcast { { i32, i8 }, { i8, i8 } }* %0 to i8*
  %.sroa.0.0..sroa_idx = getelementptr inbounds { { i32, i8 }, { i8, i8 } }, {
{ i32, i8 }, { i8, i8 } }* %0, i64 0, i32 0, i32 0
  store i32 undef, i32* %.sroa.0.0..sroa_idx, align 1
  %.sroa.1.0..sroa_idx = getelementptr inbounds { { i32, i8 }, { i8, i8 } }, {
{ i32, i8 }, { i8, i8 } }* %0, i64 0, i32 0, i32 1
  store i8 0, i8* %.sroa.1.0..sroa_idx, align 1
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, i8* %1, i64 5
  %.sroa.2.0..sroa_cast = bitcast i8* %.sroa.2.0..sroa_idx to i16*
  %.sroa.2.0.extract.trunc = trunc i32 undef to i16
  store i16 %.sroa.2.0.extract.trunc, i16* %.sroa.2.0..sroa_cast, align 1
  ret void
}

-- 
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/20171013/cd82afae/attachment.html>


More information about the llvm-bugs mailing list