4
4
#![ crate_type = "lib" ]
5
5
#![ feature( try_blocks) ]
6
6
7
- // These are now NOPs in LLVM 15, presumably thanks to nikic's change mentioned in
8
- // <https://github.com/rust-lang/rust/issues/85133#issuecomment-1072168354>.
9
- // Unfortunately, as of 2022-08-17 they're not yet nops for `u64`s nor `Option`.
10
-
11
7
use std:: ops:: ControlFlow :: { self , Continue , Break } ;
8
+ use std:: ptr:: NonNull ;
9
+
10
+ // CHECK-LABEL: @option_nop_match_32
11
+ #[ no_mangle]
12
+ pub fn option_nop_match_32 ( x : Option < u32 > ) -> Option < u32 > {
13
+ // CHECK: start:
14
+ // CHECK-NEXT: insertvalue { i32, i32 }
15
+ // CHECK-NEXT: insertvalue { i32, i32 }
16
+ // CHECK-NEXT: ret { i32, i32 }
17
+ match x {
18
+ Some ( x) => Some ( x) ,
19
+ None => None ,
20
+ }
21
+ }
22
+
23
+ // CHECK-LABEL: @option_nop_traits_32
24
+ #[ no_mangle]
25
+ pub fn option_nop_traits_32 ( x : Option < u32 > ) -> Option < u32 > {
26
+ // CHECK: start:
27
+ // CHECK-NEXT: insertvalue { i32, i32 }
28
+ // CHECK-NEXT: insertvalue { i32, i32 }
29
+ // CHECK-NEXT: ret { i32, i32 }
30
+ try {
31
+ x?
32
+ }
33
+ }
12
34
13
35
// CHECK-LABEL: @result_nop_match_32
14
36
#[ no_mangle]
15
37
pub fn result_nop_match_32 ( x : Result < i32 , u32 > ) -> Result < i32 , u32 > {
16
- // CHECK: start
17
- // CHECK-NEXT: ret i64 %0
38
+ // CHECK: start:
39
+ // CHECK-NEXT: insertvalue { i32, i32 }
40
+ // CHECK-NEXT: insertvalue { i32, i32 }
41
+ // CHECK-NEXT: ret { i32, i32 }
18
42
match x {
19
43
Ok ( x) => Ok ( x) ,
20
44
Err ( x) => Err ( x) ,
@@ -24,8 +48,60 @@ pub fn result_nop_match_32(x: Result<i32, u32>) -> Result<i32, u32> {
24
48
// CHECK-LABEL: @result_nop_traits_32
25
49
#[ no_mangle]
26
50
pub fn result_nop_traits_32 ( x : Result < i32 , u32 > ) -> Result < i32 , u32 > {
27
- // CHECK: start
28
- // CHECK-NEXT: ret i64 %0
51
+ // CHECK: start:
52
+ // CHECK-NEXT: insertvalue { i32, i32 }
53
+ // CHECK-NEXT: insertvalue { i32, i32 }
54
+ // CHECK-NEXT: ret { i32, i32 }
55
+ try {
56
+ x?
57
+ }
58
+ }
59
+
60
+ // CHECK-LABEL: @result_nop_match_64
61
+ #[ no_mangle]
62
+ pub fn result_nop_match_64 ( x : Result < i64 , u64 > ) -> Result < i64 , u64 > {
63
+ // CHECK: start:
64
+ // CHECK-NEXT: insertvalue { i64, i64 }
65
+ // CHECK-NEXT: insertvalue { i64, i64 }
66
+ // CHECK-NEXT: ret { i64, i64 }
67
+ match x {
68
+ Ok ( x) => Ok ( x) ,
69
+ Err ( x) => Err ( x) ,
70
+ }
71
+ }
72
+
73
+ // CHECK-LABEL: @result_nop_traits_64
74
+ #[ no_mangle]
75
+ pub fn result_nop_traits_64 ( x : Result < i64 , u64 > ) -> Result < i64 , u64 > {
76
+ // CHECK: start:
77
+ // CHECK-NEXT: insertvalue { i64, i64 }
78
+ // CHECK-NEXT: insertvalue { i64, i64 }
79
+ // CHECK-NEXT: ret { i64, i64 }
80
+ try {
81
+ x?
82
+ }
83
+ }
84
+
85
+ // CHECK-LABEL: @result_nop_match_ptr
86
+ #[ no_mangle]
87
+ pub fn result_nop_match_ptr ( x : Result < usize , Box < ( ) > > ) -> Result < usize , Box < ( ) > > {
88
+ // CHECK: start:
89
+ // CHECK-NEXT: insertvalue { i{{[0-9]+}}, ptr }
90
+ // CHECK-NEXT: insertvalue { i{{[0-9]+}}, ptr }
91
+ // CHECK-NEXT: ret
92
+ match x {
93
+ Ok ( x) => Ok ( x) ,
94
+ Err ( x) => Err ( x) ,
95
+ }
96
+ }
97
+
98
+ // CHECK-LABEL: @result_nop_traits_ptr
99
+ #[ no_mangle]
100
+ pub fn result_nop_traits_ptr ( x : Result < u64 , NonNull < ( ) > > ) -> Result < u64 , NonNull < ( ) > > {
101
+ // CHECK: start:
102
+ // CHECK-NEXT: insertvalue { i{{[0-9]+}}, ptr }
103
+ // CHECK-NEXT: insertvalue { i{{[0-9]+}}, ptr }
104
+ // CHECK-NEXT: ret
29
105
try {
30
106
x?
31
107
}
@@ -34,8 +110,10 @@ pub fn result_nop_traits_32(x: Result<i32, u32>) -> Result<i32, u32> {
34
110
// CHECK-LABEL: @control_flow_nop_match_32
35
111
#[ no_mangle]
36
112
pub fn control_flow_nop_match_32 ( x : ControlFlow < i32 , u32 > ) -> ControlFlow < i32 , u32 > {
37
- // CHECK: start
38
- // CHECK-NEXT: ret i64 %0
113
+ // CHECK: start:
114
+ // CHECK-NEXT: insertvalue { i32, i32 }
115
+ // CHECK-NEXT: insertvalue { i32, i32 }
116
+ // CHECK-NEXT: ret { i32, i32 }
39
117
match x {
40
118
Continue ( x) => Continue ( x) ,
41
119
Break ( x) => Break ( x) ,
@@ -45,8 +123,10 @@ pub fn control_flow_nop_match_32(x: ControlFlow<i32, u32>) -> ControlFlow<i32, u
45
123
// CHECK-LABEL: @control_flow_nop_traits_32
46
124
#[ no_mangle]
47
125
pub fn control_flow_nop_traits_32 ( x : ControlFlow < i32 , u32 > ) -> ControlFlow < i32 , u32 > {
48
- // CHECK: start
49
- // CHECK-NEXT: ret i64 %0
126
+ // CHECK: start:
127
+ // CHECK-NEXT: insertvalue { i32, i32 }
128
+ // CHECK-NEXT: insertvalue { i32, i32 }
129
+ // CHECK-NEXT: ret { i32, i32 }
50
130
try {
51
131
x?
52
132
}
0 commit comments