44#![ crate_type = "lib" ]  
55#![ feature( try_blocks) ]  
66
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- 
117use  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+ } 
1234
1335// CHECK-LABEL: @result_nop_match_32 
1436#[ no_mangle]  
1537pub  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 } 
1842    match  x { 
1943        Ok ( x)  => Ok ( x) , 
2044        Err ( x)  => Err ( x) , 
@@ -24,8 +48,60 @@ pub fn result_nop_match_32(x: Result<i32, u32>) -> Result<i32, u32> {
2448// CHECK-LABEL: @result_nop_traits_32 
2549#[ no_mangle]  
2650pub  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 
29105    try { 
30106        x?
31107    } 
@@ -34,8 +110,10 @@ pub fn result_nop_traits_32(x: Result<i32, u32>) -> Result<i32, u32> {
34110// CHECK-LABEL: @control_flow_nop_match_32 
35111#[ no_mangle]  
36112pub  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 } 
39117    match  x { 
40118        Continue ( x)  => Continue ( x) , 
41119        Break ( x)  => Break ( x) , 
@@ -45,8 +123,10 @@ pub fn control_flow_nop_match_32(x: ControlFlow<i32, u32>) -> ControlFlow<i32, u
45123// CHECK-LABEL: @control_flow_nop_traits_32 
46124#[ no_mangle]  
47125pub  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 } 
50130    try { 
51131        x?
52132    } 
0 commit comments