File: attr-minsize.cpp

package info (click to toggle)
llvm-toolchain-15 1%3A15.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,554,644 kB
  • sloc: cpp: 5,922,452; ansic: 1,012,136; asm: 674,362; python: 191,568; objc: 73,855; f90: 42,327; lisp: 31,913; pascal: 11,973; javascript: 10,144; sh: 9,421; perl: 7,447; ml: 5,527; awk: 3,523; makefile: 2,520; xml: 885; cs: 573; fortran: 567
file content (79 lines) | stat: -rw-r--r-- 2,103 bytes parent folder | download | duplicates (29)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// RUN: %clang_cc1 -Oz -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s -check-prefix=Oz
// RUN: %clang_cc1     -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s -check-prefix=OTHER
// RUN: %clang_cc1 -O1 -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s -check-prefix=OTHER
// RUN: %clang_cc1 -O2 -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s -check-prefix=OTHER
// RUN: %clang_cc1 -O3 -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s -check-prefix=OTHER
// RUN: %clang_cc1 -Os -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s -check-prefix=OTHER
// Check that we set the minsize attribute on each function
// when Oz optimization level is set.

__attribute__((minsize))
int test1() {
  return 42;
// Oz: @{{.*}}test1{{.*}}[[MINSIZE:#[0-9]+]]
// OTHER: @{{.*}}test1{{.*}}[[MS:#[0-9]+]]
}

int test2() {
  return 42;
// Oz: @{{.*}}test2{{.*}}[[MINSIZE]]
// Oz: ret
// OTHER: @{{.*}}test2
// OTHER-NOT: [[MS]]
// OTHER: ret
}

int test3() {
  return 42;
// Oz: @{{.*}}test3{{.*}}[[MINSIZE]]
// Oz: ret
// OTHER: @{{.*}}test3
// OTHER-NOT: [[MS]]
// OTHER: ret
}

// Check that the minsize attribute is well propagated through
// template instantiation

template<typename T>
__attribute__((minsize))
void test4(T arg) {
  return;
}

template
void test4<int>(int arg);
// Oz: define{{.*}}void @{{.*}}test4
// Oz: [[MINSIZE]]
// OTHER: define{{.*}}void @{{.*}}test4
// OTHER: [[MS]]

template
void test4<float>(float arg);
// Oz: define{{.*}}void @{{.*}}test4
// Oz: [[MINSIZE]]
// OTHER: define{{.*}}void @{{.*}}test4
// OTHER: [[MS]]

template<typename T>
void test5(T arg) {
  return;
}

template
void test5<int>(int arg);
// Oz: define{{.*}}void @{{.*}}test5
// Oz: [[MINSIZE]]
// OTHER: define{{.*}}void @{{.*}}test5
// OTHER-NOT: define{{.*}}void @{{.*}}test5{{.*}}[[MS]]

template
void test5<float>(float arg);
// Oz: define{{.*}}void @{{.*}}test5
// Oz: [[MINSIZE]]
// OTHER: define{{.*}}void @{{.*}}test5
// OTHER-NOT: define{{.*}}void @{{.*}}test5{{.*}}[[MS]]

// Oz: attributes [[MINSIZE]] = { minsize{{.*}} }

// OTHER: attributes [[MS]] = { minsize{{.*}} }