File: assume_attr.cpp

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (120 lines) | stat: -rw-r--r-- 3,808 bytes parent folder | download | duplicates (7)
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// RUN: %clang_cc1 -emit-llvm -triple i386-linux-gnu %s -o - | FileCheck %s
// RUN: %clang_cc1 -x c++ -emit-pch -triple i386-linux-gnu -o %t %s
// RUN: %clang_cc1 -include-pch %t %s -triple i386-linux-gnu -emit-llvm -o - | FileCheck %s
// expected-no-diagnostics

#ifndef HEADER
#define HEADER

/// foo: declarations only

[[omp::assume("foo:before1")]] void foo();

[[omp::assume("foo:before2")]]
[[omp::assume("foo:before3")]] void
foo();

/// baz: static function declarations and a definition

[[omp::assume("baz:before1")]] static void baz();

[[omp::assume("baz:before2")]]
[[omp::assume("baz:before3")]] static void
baz();

// Definition
[[omp::assume("baz:def1,baz:def2")]] static void baz() { foo(); }

[[omp::assume("baz:after")]] static void baz();

/// bar: external function declarations and a definition

[[omp::assume("bar:before1")]] void bar();

[[omp::assume("bar:before2")]]
[[omp::assume("bar:before3")]] void
bar();

// Definition
[[omp::assume("bar:def1,bar:def2")]] void bar() { baz(); }

[[omp::assume("bar:after")]] void bar();

/// back to foo

[[omp::assume("foo:after")]] void foo();

/// class tests
class C {
  [[omp::assume("C:private_method")]] void private_method();
  [[omp::assume("C:private_static")]] static void private_static();

public:
  [[omp::assume("C:public_method1")]] void public_method();
  [[omp::assume("C:public_static1")]] static void public_static();
};

[[omp::assume("C:public_method2")]] void C::public_method() {
  private_method();
}

[[omp::assume("C:public_static2")]] void C::public_static() {
  private_static();
}

/// template tests
template <typename T>
[[omp::assume("template_func<T>")]] void template_func() {}

template <>
[[omp::assume("template_func<float>")]] void template_func<float>() {}

template <>
void template_func<int>() {}

template <typename T>
struct S {
  [[omp::assume("S<T>::method")]] void method();
};

template <>
[[omp::assume("S<float>::method")]] void S<float>::method() {}

template <>
void S<int>::method() {}

// CHECK:         define{{.*}} void @_Z3barv() #0
// CHECK:         define{{.*}} void @_ZL3bazv() #1
// CHECK:         define{{.*}} void @_ZN1C13public_methodEv({{.*}}) #2
// CHECK:         declare{{.*}} void @_ZN1C14private_methodEv({{.*}}) #3
// CHECK:         define{{.*}} void @_ZN1C13public_staticEv() #4
// CHECK:         declare{{.*}} void @_ZN1C14private_staticEv() #5
// CHECK:         define{{.*}} void @_Z13template_funcIfEvv() #6
// CHECK:         define{{.*}} void @_Z13template_funcIiEvv() #7
// CHECK:         define{{.*}} void @_ZN1SIfE6methodEv({{.*}}) #8
// CHECK:         define{{.*}} void @_ZN1SIiE6methodEv({{.*}}) #9
// CHECK:         declare{{.*}} void @_Z3foov() #10
// CHECK:         attributes #0
// CHECK-SAME:      "llvm.assume"="bar:before1,bar:before2,bar:before3,bar:def1,bar:def2"
// CHECK:         attributes #1
// CHECK-SAME:      "llvm.assume"="baz:before1,baz:before2,baz:before3,baz:def1,baz:def2,baz:after"
// CHECK:         attributes #2
// CHECK-SAME:      "llvm.assume"="C:public_method1,C:public_method2"
// CHECK:         attributes #3
// CHECK-SAME:      "llvm.assume"="C:private_method"
// CHECK:         attributes #4
// CHECK-SAME:      "llvm.assume"="C:public_static1,C:public_static2"
// CHECK:         attributes #5
// CHECK-SAME:      "llvm.assume"="C:private_static"
// CHECK:         attributes #6
// CHECK-SAME:      "llvm.assume"="template_func<T>,template_func<float>"
// CHECK:         attributes #7
// CHECK-SAME:      "llvm.assume"="template_func<T>"
// CHECK:         attributes #8
// CHECK-SAME:      "llvm.assume"="S<T>::method,S<float>::method"
// CHECK:         attributes #9
// CHECK-SAME:      "llvm.assume"="S<T>::method"
// CHECK:         attributes #10
// CHECK-SAME:      "llvm.assume"="foo:before1,foo:before2,foo:before3"

#endif