File: attr-no-tail.c

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (33 lines) | stat: -rw-r--r-- 904 bytes parent folder | download | duplicates (12)
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
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 %s -emit-llvm -o - | FileCheck %s

// CHECK: %{{[a-z0-9]+}} = notail call i32 @callee0(i32 noundef %
// CHECK: %{{[a-z0-9]+}} = notail call i32 @callee1(i32 noundef %

// Check that indirect calls do not have the notail marker.
// CHECK: store ptr @callee1, ptr [[ALLOCA1:%[A-Za-z0-9]+]], align 8
// CHECK: [[INDIRFUNC:%[0-9]+]] = load ptr, ptr [[ALLOCA1]], align 8
// CHECK: %{{[a-z0-9]+}} = call i32 [[INDIRFUNC]](i32 noundef %{{[0-9]+}}

// CHECK: %{{[a-z0-9]+}} = call i32 @callee2(i32 noundef %

int callee0(int a) __attribute__((not_tail_called)) {
  return a + 1;
}

int callee1(int) __attribute__((not_tail_called));

int callee2(int);

typedef int (*FuncTy)(int);

int foo0(int a) {
  if (a > 1)
    return callee0(a);
  if (a == 1)
    return callee1(a);
  if (a < 0) {
    FuncTy F = callee1;
    return (*F)(a);
  }
  return callee2(a);
}