[llvm-bugs] [Bug 51668] New: EarlyCSE incorrectly assumes that readonly functions return

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 30 02:48:21 PDT 2021


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

            Bug ID: 51668
           Summary: EarlyCSE incorrectly assumes that readonly functions
                    return
           Product: libraries
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Keywords: miscompilation
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: nunoplopes at sapo.pt
                CC: alina.sbirlea at gmail.com, florian_hahn at apple.com,
                    gberry at codeaurora.org, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk

Test: Transforms/EarlyCSE/globalsaa-memoryssa.ll

define void @f3() {
  %call1 = call i16 @f1() nowrite nofree
  call void @f2()
  %call2 = call i16 @f1() nowrite nofree
  ret void
}
=>
define void @f3() {
  %call1 = call i16 @f1() nowrite nofree
  call void @f2()
  ret void
}

The second call to @f1() is incorrectly removed. We don't know if it exits, for
example. Function @f2 may change the state read by @f1 and thus the first call
may return and the second exit.
The optimization should be restricted to functions with the 'willreturn'
attribute.

-- 
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/20210830/e59e9127/attachment.html>


More information about the llvm-bugs mailing list