]> git.proxmox.com Git - rustc.git/blob - src/test/codegen/naked-functions.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / codegen / naked-functions.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // ignore-tidy-linelength
12
13 // compile-flags: -C no-prepopulate-passes
14
15 #![crate_type = "lib"]
16 #![feature(naked_functions)]
17
18 // CHECK: Function Attrs: naked uwtable
19 // CHECK-NEXT: define internal void @naked_empty()
20 #[no_mangle]
21 #[naked]
22 fn naked_empty() {
23 // CHECK: ret void
24 }
25
26 // CHECK: Function Attrs: naked uwtable
27 #[no_mangle]
28 #[naked]
29 // CHECK-NEXT: define internal void @naked_with_args(i{{[0-9]+}})
30 fn naked_with_args(a: isize) {
31 // CHECK: %a = alloca i{{[0-9]+}}
32 // CHECK: ret void
33 }
34
35 // CHECK: Function Attrs: naked uwtable
36 // CHECK-NEXT: define internal i{{[0-9]+}} @naked_with_return()
37 #[no_mangle]
38 #[naked]
39 fn naked_with_return() -> isize {
40 // CHECK: ret i{{[0-9]+}} 0
41 0
42 }
43
44 // CHECK: Function Attrs: naked uwtable
45 // CHECK-NEXT: define internal i{{[0-9]+}} @naked_with_args_and_return(i{{[0-9]+}})
46 #[no_mangle]
47 #[naked]
48 fn naked_with_args_and_return(a: isize) -> isize {
49 // CHECK: %a = alloca i{{[0-9]+}}
50 // CHECK: ret i{{[0-9]+}} %{{[0-9]+}}
51 a
52 }
53
54 // CHECK: Function Attrs: naked uwtable
55 // CHECK-NEXT: define internal void @naked_recursive()
56 #[no_mangle]
57 #[naked]
58 fn naked_recursive() {
59 // CHECK: call void @naked_empty()
60 naked_empty();
61 // CHECK: %{{[0-9]+}} = call i{{[0-9]+}} @naked_with_return()
62 naked_with_args(
63 // CHECK: %{{[0-9]+}} = call i{{[0-9]+}} @naked_with_args_and_return(i{{[0-9]+}} %{{[0-9]+}})
64 naked_with_args_and_return(
65 // CHECK: call void @naked_with_args(i{{[0-9]+}} %{{[0-9]+}})
66 naked_with_return()
67 )
68 );
69 }