1 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 %s -emit-llvm -o - | FileCheck %s
2
3 void t1(void) __attribute__((naked));
4
5 // Basic functionality check
6 // (Note that naked needs to imply noinline to work properly.)
7 // CHECK: define{{.*}} void @t1() [[NAKED_OPTNONE:#[0-9]+]] {
t1(void)8 void t1(void)
9 {
10 }
11
12 // Make sure this doesn't explode in the verifier.
13 // (It doesn't really make sense, but it isn't invalid.)
14 // CHECK: define{{.*}} void @t2() [[NAKED:#[0-9]+]] {
t2(void)15 __attribute((naked, always_inline)) void t2(void) {
16 }
17
18 // Make sure not to generate prolog or epilog for naked functions.
t3(int x)19 __attribute((naked)) void t3(int x) {
20 // CHECK: define{{.*}} void @t3(i32 noundef %0)
21 // CHECK-NOT: alloca
22 // CHECK-NOT: store
23 // CHECK: unreachable
24 }
25
26 // Make sure naked functions do not attempt to evaluate parameters with a
27 // variably-modified type. Naked functions get no prolog, so this evaluation
28 // should not take place.
t4(int len,char x[len])29 __attribute__((naked)) void t4(int len, char x[len]) {
30 // CHECK: define{{.*}} void @t4(i32 noundef{{.*}}, ptr noundef{{.*}})
31 // CHECK: unreachable
32 }
33
34 // CHECK: attributes [[NAKED_OPTNONE]] = { naked noinline nounwind optnone{{.*}} }
35 // CHECK: attributes [[NAKED]] = { naked noinline nounwind{{.*}} }
36