[llvm-bugs] [Bug 36795] New: Missing (potentially lots of) optimizations for type c_void* when compared to i8*

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Mar 19 04:33:20 PDT 2018


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

            Bug ID: 36795
           Summary: Missing (potentially lots of) optimizations for type
                    c_void* when compared to i8*
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: gonzalobg88 at gmail.com
                CC: chandlerc at gmail.com, llvm-bugs at lists.llvm.org

See it live: https://godbolt.org/g/nNDaWy

This IR using i8*:

define void @call_malloc() #0 {
  %1 = call i8* @malloc(i64 1)
  ret void
}
declare i8* @malloc(i64) #1

optimizes to:

define void @call_malloc() local_unnamed_addr #0 {
  ret void
}
attributes #0 = { norecurse nounwind readnone }

while this IR using an opaque type c_void *:

%struct.c_void = type opaque
define void @call_malloc() #0 {
  %1 = call %struct.c_void* @malloc(i64 1)
  ret void
}
declare %struct.c_void* @malloc(i64) #1

optimizes to:

%struct.c_void = type opaque
define void @call_malloc() local_unnamed_addr #0 {
  %1 = tail call %struct.c_void* @malloc(i64 1)
  ret void
}

declare noalias %struct.c_void* @malloc(i64) local_unnamed_addr #0
attributes #0 = { nounwind }

Note, in particular, that the call to malloc has not been removed.

-- 
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/20180319/86e79759/attachment-0001.html>


More information about the llvm-bugs mailing list