-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Expand file tree
/
Copy pathc-variadic-inline.rs
More file actions
46 lines (39 loc) · 1.04 KB
/
c-variadic-inline.rs
File metadata and controls
46 lines (39 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//@ compile-flags: -C opt-level=3
// Test that the inline attributes are accepted on C-variadic functions.
//
// Currently LLVM is unable to inline C-variadic functions, but that is valid because despite
// the name even `#[inline(always)]` is just a hint.
#[inline(always)]
unsafe extern "C" fn inline_always(mut ap: ...) -> u32 {
ap.next_arg::<u32>()
}
#[inline]
unsafe extern "C" fn inline(mut ap: ...) -> u32 {
ap.next_arg::<u32>()
}
#[inline(never)]
unsafe extern "C" fn inline_never(mut ap: ...) -> u32 {
ap.next_arg::<u32>()
}
#[cold]
unsafe extern "C" fn cold(mut ap: ...) -> u32 {
ap.next_arg::<u32>()
}
#[unsafe(no_mangle)]
#[inline(never)]
fn helper() {
// CHECK-LABEL: helper
// CHECK-LABEL: call c_variadic_inline::inline_always
// CHECK-LABEL: call c_variadic_inline::inline
// CHECK-LABEL: call c_variadic_inline::inline_never
// CHECK-LABEL: call c_variadic_inline::cold
unsafe {
inline_always(1);
inline(2);
inline_never(3);
cold(4);
}
}
fn main() {
helper()
}