deadexternal.ll
1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
; RUN: opt -deadargelim -S < %s | FileCheck %s
define void @test(i32) {
ret void
}
define void @foo() {
call void @test(i32 0)
ret void
; CHECK-LABEL: @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
store volatile i32 10, i32* %i, align 4
; CHECK: %tmp = load volatile i32, i32* %i, align 4
; CHECK-NEXT: call void @f(i32 undef)
%tmp = load volatile i32, i32* %i, align 4
call void @f(i32 %tmp)
ret void
}
; 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
}
%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
}