<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - DeadArgumentEliminationPass eliminates live return value"
   href="https://bugs.llvm.org/show_bug.cgi?id=47444">47444</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>DeadArgumentEliminationPass eliminates live return value
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>11.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Interprocedural Optimizations
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>tomasz.miasko@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>In example below, return values from functions f & g are live, but
DeadArgumentEliminationPass incorrectly removes the "return value 1 from g":

Args: opt -S -deadargelim -debug -print-before-all -print-after-all 
*** IR Dump Before Dead Argument Elimination ***
; ModuleID = '<stdin>'
source_filename = "b.7rcbfp3g-cgu.0"
target datalayout =
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nonlazybind
define internal { i64, i64 } @f(i64 %a, i64 %b) #0 {
start:
  %0 = insertvalue { i64, i64 } undef, i64 %a, 0
  %1 = insertvalue { i64, i64 } %0, i64 %b, 1
  ret { i64, i64 } %1
}

; Function Attrs: nonlazybind
define internal { i64, i64 } @g(i64 %a, i64 %b) #0 {
start:
  %0 = call { i64, i64 } @f(i64 %a, i64 %b)
  ret { i64, i64 } %0
}

; Function Attrs: nonlazybind
declare dso_local i32 @test(i64, i64) #0

; Function Attrs: nonlazybind
define i32 @main(i32 %argc, i8** %argv) #0 {
start:
  %x = call { i64, i64 } @g(i64 13, i64 42)
  %x.0 = extractvalue { i64, i64 } %x, 0
  %x.1 = extractvalue { i64, i64 } %x, 1
  %z = bitcast i64 %x.0 to i64
  %y = call { i64, i64 } @f(i64 %x.0, i64 %x.1)
  %y.0 = extractvalue { i64, i64 } %y, 0
  %y.1 = extractvalue { i64, i64 } %y, 1
  %0 = call i32 @test(i64 %x.0, i64 %y.1)
  ret i32 %0
}

attributes #0 = { nonlazybind "target-cpu"="x86-64" }

!llvm.module.flags = !{!0, !1, !2}

!0 = !{i32 7, !"PIC Level", i32 2}
!1 = !{i32 7, !"PIE Level", i32 2}
!2 = !{i32 2, !"RtLibUseGOT", i32 1}
DeadArgumentEliminationPass - Deleting dead varargs
DeadArgumentEliminationPass - Determining liveness
DeadArgumentEliminationPass - Inspecting callers for fn: f
DeadArgumentEliminationPass - Inspecting args for fn: f
DeadArgumentEliminationPass - Inspecting callers for fn: g
DeadArgumentEliminationPass - Marking Return value #0 of function g live
DeadArgumentEliminationPass - Marking Return value #0 of function f live
DeadArgumentEliminationPass - Marking Argument #0 of function f live
DeadArgumentEliminationPass - Marking Return value #1 of function f live
DeadArgumentEliminationPass - Marking Argument #1 of function f live
DeadArgumentEliminationPass - Inspecting args for fn: g
DeadArgumentEliminationPass - Marking Argument #0 of function g live
DeadArgumentEliminationPass - Marking Argument #1 of function g live
DeadArgumentEliminationPass - Intrinsically live fn: test
DeadArgumentEliminationPass - Intrinsically live fn: main
DeadArgumentEliminationPass - Removing return value 1 from g
*** IR Dump After Dead Argument Elimination ***
; ModuleID = '<stdin>'
source_filename = "b.7rcbfp3g-cgu.0"
target datalayout =
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nonlazybind
define internal { i64, i64 } @f(i64 %a, i64 %b) #0 {
start:
  %0 = insertvalue { i64, i64 } undef, i64 %a, 0
  %1 = insertvalue { i64, i64 } %0, i64 %b, 1
  ret { i64, i64 } %1
}

; Function Attrs: nonlazybind
define internal i64 @g(i64 %a, i64 %b) #0 {
start:
  %0 = call { i64, i64 } @f(i64 %a, i64 %b)
  %oldret = extractvalue { i64, i64 } %0, 0
  ret i64 %oldret
}

; Function Attrs: nonlazybind
declare dso_local i32 @test(i64, i64) #0

; Function Attrs: nonlazybind
define i32 @main(i32 %argc, i8** %argv) #0 {
start:
  %x = call i64 @g(i64 13, i64 42)
  %oldret = insertvalue { i64, i64 } undef, i64 %x, 0
  %x.0 = extractvalue { i64, i64 } %oldret, 0
  %x.1 = extractvalue { i64, i64 } %oldret, 1
  %z = bitcast i64 %x.0 to i64
  %y = call { i64, i64 } @f(i64 %x.0, i64 %x.1)
  %y.0 = extractvalue { i64, i64 } %y, 0
  %y.1 = extractvalue { i64, i64 } %y, 1
  %0 = call i32 @test(i64 %x.0, i64 %y.1)
  ret i32 %0
}

attributes #0 = { nonlazybind "target-cpu"="x86-64" }

!llvm.module.flags = !{!0, !1, !2}

!0 = !{i32 7, !"PIC Level", i32 2}
!1 = !{i32 7, !"PIE Level", i32 2}
!2 = !{i32 2, !"RtLibUseGOT", i32 1}</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>