]>
Commit | Line | Data |
---|---|---|
5869c6ff XL |
1 | // Checks that only functions with the compatible instruction_set attributes are inlined. |
2 | // | |
487cf647 FG |
3 | // A function is "compatible" when the *callee* has the same attribute or no attribute. |
4 | // | |
5869c6ff XL |
5 | // compile-flags: --target thumbv4t-none-eabi |
6 | // needs-llvm-components: arm | |
7 | ||
8 | #![crate_type = "lib"] | |
9 | #![feature(rustc_attrs)] | |
10 | #![feature(no_core, lang_items)] | |
11 | #![feature(isa_attribute)] | |
12 | #![no_core] | |
13 | ||
14 | #[rustc_builtin_macro] | |
15 | #[macro_export] | |
16 | macro_rules! asm { | |
17 | ("assembly template", | |
18 | $(operands,)* | |
19 | $(options($(option),*))? | |
20 | ) => { | |
21 | /* compiler built-in */ | |
22 | }; | |
23 | } | |
24 | ||
25 | #[lang = "sized"] | |
26 | trait Sized {} | |
27 | #[lang = "copy"] | |
28 | trait Copy {} | |
29 | ||
30 | #[instruction_set(arm::a32)] | |
31 | #[inline] | |
32 | fn instruction_set_a32() {} | |
33 | ||
34 | #[instruction_set(arm::t32)] | |
35 | #[inline] | |
36 | fn instruction_set_t32() {} | |
37 | ||
38 | #[inline] | |
39 | fn instruction_set_default() {} | |
40 | ||
487cf647 FG |
41 | #[inline(always)] |
42 | fn inline_always_and_using_inline_asm() { | |
43 | unsafe { asm!("/* do nothing */") }; | |
44 | } | |
45 | ||
5869c6ff XL |
46 | // EMIT_MIR inline_instruction_set.t32.Inline.diff |
47 | #[instruction_set(arm::t32)] | |
48 | pub fn t32() { | |
ed00b5ec FG |
49 | // CHECK-LABEL: fn t32( |
50 | // CHECK-NOT: (inlined instruction_set_a32) | |
5869c6ff | 51 | instruction_set_a32(); |
ed00b5ec | 52 | // CHECK: (inlined instruction_set_t32) |
5869c6ff | 53 | instruction_set_t32(); |
ed00b5ec | 54 | // CHECK: (inlined instruction_set_default) |
5869c6ff | 55 | instruction_set_default(); |
ed00b5ec | 56 | // CHECK-NOT: (inlined inline_always_and_using_inline_asm) |
487cf647 | 57 | inline_always_and_using_inline_asm(); |
5869c6ff XL |
58 | } |
59 | ||
60 | // EMIT_MIR inline_instruction_set.default.Inline.diff | |
61 | pub fn default() { | |
ed00b5ec FG |
62 | // CHECK-LABEL: fn default( |
63 | // CHECK-NOT: (inlined instruction_set_a32) | |
5869c6ff | 64 | instruction_set_a32(); |
ed00b5ec | 65 | // CHECK-NOT: (inlined instruction_set_t32) |
5869c6ff | 66 | instruction_set_t32(); |
ed00b5ec | 67 | // CHECK: (inlined instruction_set_default) |
5869c6ff | 68 | instruction_set_default(); |
ed00b5ec | 69 | // CHECK: (inlined inline_always_and_using_inline_asm) |
487cf647 | 70 | inline_always_and_using_inline_asm(); |
5869c6ff | 71 | } |