[llvm-bugs] [Bug 47444] New: DeadArgumentEliminationPass eliminates live return value

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Sep 6 16:42:52 PDT 2020


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

            Bug ID: 47444
           Summary: DeadArgumentEliminationPass eliminates live return
                    value
           Product: libraries
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Interprocedural Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: tomasz.miasko at gmail.com
                CC: llvm-bugs at lists.llvm.org

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}

-- 
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/20200906/caca7941/attachment-0001.html>


More information about the llvm-bugs mailing list