2012-12-30 09:28:40 +08:00
|
|
|
; RUN: opt -deadargelim -S < %s | FileCheck %s
|
2010-04-14 11:46:42 +08:00
|
|
|
|
|
|
|
define void @test(i32) {
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @foo() {
|
|
|
|
call void @test(i32 0)
|
|
|
|
ret void
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @foo(
|
2010-04-14 11:46:42 +08:00
|
|
|
; CHECK: i32 undef
|
|
|
|
}
|
2011-01-17 05:25:33 +08:00
|
|
|
|
|
|
|
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
|
2011-11-27 14:54:59 +08:00
|
|
|
store volatile i32 10, i32* %i, align 4
|
2015-02-28 05:17:42 +08:00
|
|
|
; CHECK: %tmp = load volatile i32, i32* %i, align 4
|
2014-02-16 15:31:05 +08:00
|
|
|
; CHECK-NEXT: call void @f(i32 undef)
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp = load volatile i32, i32* %i, align 4
|
2011-01-17 05:25:33 +08:00
|
|
|
call void @f(i32 %tmp)
|
|
|
|
ret void
|
|
|
|
}
|
2011-03-01 08:33:47 +08:00
|
|
|
|
|
|
|
; Check that callers are not transformed for weak definitions.
|
|
|
|
define weak i32 @weak_f(i32 %x) nounwind {
|
|
|
|
entry:
|
|
|
|
ret i32 0
|
|
|
|
}
|
|
|
|
define void @weak_f_caller() nounwind {
|
|
|
|
entry:
|
|
|
|
; CHECK: call i32 @weak_f(i32 10)
|
|
|
|
%call = tail call i32 @weak_f(i32 10)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-09-21 23:29:08 +08:00
|
|
|
%swift_error = type opaque
|
|
|
|
|
|
|
|
define void @unused_swifterror_arg(%swift_error** swifterror %dead_arg) {
|
|
|
|
tail call void @sideeffect() nounwind
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: @dont_replace_by_undef
|
|
|
|
; CHECK-NOT: call void @unused_swifterror_arg({{.*}}undef)
|
|
|
|
define void @dont_replace_by_undef() {
|
|
|
|
%error_ptr_ref = alloca swifterror %swift_error*
|
|
|
|
store %swift_error* null, %swift_error** %error_ptr_ref
|
|
|
|
call void @unused_swifterror_arg(%swift_error** %error_ptr_ref)
|
|
|
|
ret void
|
|
|
|
}
|