|
| 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