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.
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.
11 // ignore-tidy-linelength
13 // compile-flags: -C no-prepopulate-passes
15 #![crate_type = "lib"]
16 #![feature(naked_functions)]
18 // CHECK: Function Attrs: naked uwtable
19 // CHECK-NEXT: define void @naked_empty()
22 pub fn naked_empty() {
23 // CHECK-NEXT: {{.+}}:
24 // CHECK-NEXT: ret void
27 // CHECK: Function Attrs: naked uwtable
30 // CHECK-NEXT: define void @naked_with_args(i{{[0-9]+}})
31 pub fn naked_with_args(a: isize) {
32 // CHECK-NEXT: {{.+}}:
33 // CHECK-NEXT: %a = alloca i{{[0-9]+}}
34 &a; // keep variable in an alloca
38 // CHECK: Function Attrs: naked uwtable
39 // CHECK-NEXT: define i{{[0-9]+}} @naked_with_return()
42 pub fn naked_with_return() -> isize {
43 // CHECK-NEXT: {{.+}}:
44 // CHECK-NEXT: ret i{{[0-9]+}} 0
48 // CHECK: Function Attrs: naked uwtable
49 // CHECK-NEXT: define i{{[0-9]+}} @naked_with_args_and_return(i{{[0-9]+}})
52 pub fn naked_with_args_and_return(a: isize) -> isize {
53 // CHECK-NEXT: {{.+}}:
54 // CHECK-NEXT: %a = alloca i{{[0-9]+}}
55 &a; // keep variable in an alloca
56 // CHECK: ret i{{[0-9]+}} %{{[0-9]+}}
60 // CHECK: Function Attrs: naked uwtable
61 // CHECK-NEXT: define void @naked_recursive()
64 pub fn naked_recursive() {
65 // CHECK-NEXT: {{.+}}:
66 // CHECK-NEXT: call void @naked_empty()
68 // FIXME(#39685) Avoid one block per call.
69 // CHECK-NEXT: br label %bb1
74 // CHECK-NEXT: %{{[0-9]+}} = call i{{[0-9]+}} @naked_with_return()
76 // FIXME(#39685) Avoid one block per call.
77 // CHECK-NEXT: br label %bb2
80 // CHECK-NEXT: %{{[0-9]+}} = call i{{[0-9]+}} @naked_with_args_and_return(i{{[0-9]+}} %{{[0-9]+}})
82 // FIXME(#39685) Avoid one block per call.
83 // CHECK-NEXT: br label %bb3
86 // CHECK-NEXT: call void @naked_with_args(i{{[0-9]+}} %{{[0-9]+}})
88 // FIXME(#39685) Avoid one block per call.
89 // CHECK-NEXT: br label %bb4
93 naked_with_args_and_return(
97 // CHECK-NEXT: ret void