Skip to content

Commit c68580a

Browse files
committed
added more test cases
1 parent bd412f6 commit c68580a

File tree

4 files changed

+166
-28
lines changed

4 files changed

+166
-28
lines changed

tests/codegen/patchable-function-entry.rs

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
//@ compile-flags: -Z patchable-function-entry=15,10
2+
3+
#![feature(patchable_function_entry)]
4+
#![crate_type = "lib"]
5+
6+
// This should have the default, as set by the compile flags
7+
#[no_mangle]
8+
pub fn fun0() {}
9+
10+
// The attribute should override the compile flags
11+
#[no_mangle]
12+
#[patchable_function_entry(prefix_nops = 1, entry_nops = 2)]
13+
pub fn fun1() {}
14+
15+
// If we override an attribute to 0 or unset, the attribute should go away
16+
#[no_mangle]
17+
#[patchable_function_entry(entry_nops = 0)]
18+
pub fn fun2() {}
19+
20+
// The attribute should override the compile flags
21+
#[no_mangle]
22+
#[patchable_function_entry(prefix_nops = 20, entry_nops = 1)]
23+
pub fn fun3() {}
24+
25+
// The attribute should override the compile flags
26+
#[no_mangle]
27+
#[patchable_function_entry(prefix_nops = 2, entry_nops = 19)]
28+
pub fn fun4() {}
29+
30+
// The attribute should override patchable-function-entry to 3 and patchable-function-prefix to the default of 0, clearing it entirely
31+
#[no_mangle]
32+
#[patchable_function_entry(entry_nops = 3)]
33+
pub fn fun5() {}
34+
35+
// The attribute should override patchable-function-prefix to 4 and patchable-function-entry to the default of 0, clearing it entirely
36+
#[no_mangle]
37+
#[patchable_function_entry(prefix_nops = 4)]
38+
pub fn fun6() {}
39+
40+
// CHECK: @fun0() unnamed_addr #0
41+
// CHECK: @fun1() unnamed_addr #1
42+
// CHECK: @fun2() unnamed_addr #2
43+
// CHECK: @fun3() unnamed_addr #3
44+
// CHECK: @fun4() unnamed_addr #4
45+
// CHECK: @fun5() unnamed_addr #5
46+
// CHECK: @fun6() unnamed_addr #6
47+
48+
// CHECK: attributes #0 = { {{.*}}"patchable-function-entry"="5"{{.*}}"patchable-function-prefix"="10" {{.*}} }
49+
// CHECK: attributes #1 = { {{.*}}"patchable-function-entry"="2"{{.*}}"patchable-function-prefix"="1" {{.*}} }
50+
51+
// CHECK-NOT: attributes #2 = { {{.*}}patchable-function-entry{{.*}} }
52+
// CHECK-NOT: attributes #2 = { {{.*}}patchable-function-prefix{{.*}} }
53+
// CHECK: attributes #2 = { {{.*}} }
54+
55+
// CHECK: attributes #3 = { {{.*}}"patchable-function-entry"="1"{{.*}}"patchable-function-prefix"="20" {{.*}} }
56+
// CHECK: attributes #4 = { {{.*}}"patchable-function-entry"="19"{{.*}}"patchable-function-prefix"="2" {{.*}} }
57+
58+
// CHECK: attributes #5 = { {{.*}}"patchable-function-entry"="3"{{.*}} }
59+
// CHECK-NOT: attributes #5 = { {{.*}}patchable-function-prefix{{.*}} }
60+
61+
// CHECK: attributes #6 = { {{.*}}"patchable-function-prefix"="4"{{.*}} }
62+
// CHECK-NOT: attributes #6 = { {{.*}}patchable-function-entry{{.*}} }
63+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#![feature(patchable_function_entry)]
2+
#![crate_type = "lib"]
3+
4+
// No patchable function entry should be set
5+
#[no_mangle]
6+
pub fn fun0() {}
7+
8+
// The attribute should work even without compiler flags
9+
#[no_mangle]
10+
#[patchable_function_entry(prefix_nops = 1, entry_nops = 2)]
11+
pub fn fun1() {}
12+
13+
// The attribute should work even without compiler flags and only set patchable-function-entry to 3.
14+
#[no_mangle]
15+
#[patchable_function_entry(entry_nops = 3)]
16+
pub fn fun2() {}
17+
18+
// The attribute should work even without compiler flags and only set patchable-function-prefix to 4.
19+
#[no_mangle]
20+
#[patchable_function_entry(prefix_nops = 4)]
21+
pub fn fun3() {}
22+
23+
// CHECK: @fun0() unnamed_addr #0
24+
// CHECK: @fun1() unnamed_addr #1
25+
// CHECK: @fun2() unnamed_addr #2
26+
// CHECK: @fun3() unnamed_addr #3
27+
28+
29+
// CHECK-NOT: attributes #0 = { {{.*}}patchable-function-entry{{.*}} }
30+
// CHECK-NOT: attributes #0 = { {{.*}}patchable-function-prefix{{.*}} }
31+
32+
// CHECK: attributes #1 = { {{.*}}"patchable-function-entry"="2"{{.*}}"patchable-function-prefix"="1" {{.*}} }
33+
34+
// CHECK: attributes #2 = { {{.*}}"patchable-function-entry"="3"{{.*}} }
35+
// CHECK-NOT: attributes #2 = { {{.*}}patchable-function-prefix{{.*}} }
36+
37+
// CHECK: attributes #3 = { {{.*}}"patchable-function-prefix"="4"{{.*}} }
38+
// CHECK-NOT: attributes #3 = { {{.*}}patchable-function-entry{{.*}} }
39+
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//@ compile-flags: -Z patchable-function-entry=15
2+
3+
#![feature(patchable_function_entry)]
4+
#![crate_type = "lib"]
5+
6+
// This should have the default, as set by the compile flags
7+
#[no_mangle]
8+
pub fn fun0() {}
9+
10+
// The attribute should override the compile flags
11+
#[no_mangle]
12+
#[patchable_function_entry(prefix_nops = 1, entry_nops = 2)]
13+
pub fn fun1() {}
14+
15+
// If we override an attribute to 0 or unset, the attribute should go away
16+
#[no_mangle]
17+
#[patchable_function_entry(entry_nops = 0)]
18+
pub fn fun2() {}
19+
20+
// The attribute should override the compile flags
21+
#[no_mangle]
22+
#[patchable_function_entry(prefix_nops = 20, entry_nops = 1)]
23+
pub fn fun3() {}
24+
25+
// The attribute should override the compile flags
26+
#[no_mangle]
27+
#[patchable_function_entry(prefix_nops = 2, entry_nops = 19)]
28+
pub fn fun4() {}
29+
30+
// The attribute should override patchable-function-entry to 3 and patchable-function-prefix to the default of 0, clearing it entirely
31+
#[no_mangle]
32+
#[patchable_function_entry(entry_nops = 3)]
33+
pub fn fun5() {}
34+
35+
// The attribute should override patchable-function-prefix to 4 and patchable-function-entry to the default of 0, clearing it entirely
36+
#[no_mangle]
37+
#[patchable_function_entry(prefix_nops = 4)]
38+
pub fn fun6() {}
39+
40+
// CHECK: @fun0() unnamed_addr #0
41+
// CHECK: @fun1() unnamed_addr #1
42+
// CHECK: @fun2() unnamed_addr #2
43+
// CHECK: @fun3() unnamed_addr #3
44+
// CHECK: @fun4() unnamed_addr #4
45+
// CHECK: @fun5() unnamed_addr #5
46+
// CHECK: @fun6() unnamed_addr #6
47+
48+
// CHECK: attributes #0 = { {{.*}}"patchable-function-entry"="15" {{.*}} }
49+
// CHECK-NOT: attributes #0 = { {{.*}}patchable-function-prefix{{.*}} }
50+
51+
// CHECK: attributes #1 = { {{.*}}"patchable-function-entry"="2"{{.*}}"patchable-function-prefix"="1" {{.*}} }
52+
53+
// CHECK-NOT: attributes #2 = { {{.*}}patchable-function-entry{{.*}} }
54+
// CHECK-NOT: attributes #2 = { {{.*}}patchable-function-prefix{{.*}} }
55+
// CHECK: attributes #2 = { {{.*}} }
56+
57+
// CHECK: attributes #3 = { {{.*}}"patchable-function-entry"="1"{{.*}}"patchable-function-prefix"="20" {{.*}} }
58+
// CHECK: attributes #4 = { {{.*}}"patchable-function-entry"="19"{{.*}}"patchable-function-prefix"="2" {{.*}} }
59+
60+
// CHECK: attributes #5 = { {{.*}}"patchable-function-entry"="3"{{.*}} }
61+
// CHECK-NOT: attributes #5 = { {{.*}}patchable-function-prefix{{.*}} }
62+
63+
// CHECK: attributes #6 = { {{.*}}"patchable-function-prefix"="4"{{.*}} }
64+
// CHECK-NOT: attributes #6 = { {{.*}}patchable-function-entry{{.*}} }

0 commit comments

Comments
 (0)