Clang Project

clang_source_code/test/CodeGen/attr-naked.c
1// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 %s -emit-llvm -o - | FileCheck %s
2
3void t1() __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]+]] {
8void t1()
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]+]] {
15__attribute((naked, always_inline)) void t2() {
16}
17
18// Make sure not to generate prolog or epilog for naked functions.
19__attribute((naked)) void t3(int x) {
20// CHECK: define void @t3(i32)
21// CHECK-NOT: alloca
22// CHECK-NOT: store
23// CHECK: unreachable
24}
25
26// CHECK: attributes [[NAKED_OPTNONE]] = { naked noinline nounwind optnone{{.*}} }
27// CHECK: attributes [[NAKED]] = { naked noinline nounwind{{.*}} }
28