[llvm-bugs] [Bug 50697] New: InstCombine breaks calls of casted functions with type attributes

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jun 12 10:55:51 PDT 2021


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

            Bug ID: 50697
           Summary: InstCombine breaks calls of casted functions with type
                    attributes
           Product: libraries
           Version: 12.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: sean.m.bartell at gmail.com
                CC: llvm-bugs at lists.llvm.org

In LLVM 12.0.0, InstCombine can break call instructions of casted functions
when type attributes (byval, sret, etc.) are involved. Example input:


%struct0 = type { i32 }
%struct1 = type { float }

declare void @callee(%struct0* sret(%struct0))

define void @caller() {
  %1 = alloca %struct1
  call void bitcast (void (%struct0*)* @callee to void (%struct1*)*)(%struct1*
sret(%struct1) %1)
  unreachable
}


When run through `opt -S -instcombine`, the output is:


%struct0 = type { i32 }

declare void @callee(%struct0* sret(%struct0))

define void @caller() {
  %1 = alloca %struct0, align 8
  call void @callee(%struct0* nonnull sret(%struct1) %1)
  unreachable
}


This is invalid because the argument type (%struct0*) no longer matches the
attribute type (%struct1).

-- 
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/20210612/34ee427c/attachment-0001.html>


More information about the llvm-bugs mailing list