Teach DAE to look for functions whose arguments are unused, and change all callers to pass in an undefvalue instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123596 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Anders Carlsson
2011-01-16 21:25:33 +00:00
parent 3c98e14bc9
commit 0599c6bb3c
2 changed files with 88 additions and 2 deletions

View File

@@ -1,5 +1,4 @@
; RUN: opt -deadargelim -S %s | FileCheck %s
; XFAIL: *
define void @test(i32) {
ret void
@@ -11,3 +10,30 @@ define void @foo() {
; CHECK: @foo
; CHECK: i32 undef
}
define void @f(i32 %X) {
entry:
tail call void @sideeffect() nounwind
ret void
}
declare void @sideeffect()
define void @g(i32 %n) {
entry:
%add = add nsw i32 %n, 1
; CHECK: tail call void @f(i32 undef)
tail call void @f(i32 %add)
ret void
}
define void @h() {
entry:
%i = alloca i32, align 4
volatile store i32 10, i32* %i, align 4
; CHECK: %tmp = volatile load i32* %i, align 4
; CHECK-next: call void @f(i32 undef)
%tmp = volatile load i32* %i, align 4
call void @f(i32 %tmp)
ret void
}