GCC Code Coverage Report


Directory: ./
File: openvdb_ax/openvdb_ax/codegen/FunctionTypes.h
Date: 2022-07-25 17:40:05
Exec Total Coverage
Lines: 209 215 97.2%
Functions: 3650 4203 86.8%
Branches: 1987 4482 44.3%

Line Branch Exec Source
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3
4 /// @file codegen/FunctionTypes.h
5 ///
6 /// @authors Nick Avramoussis
7 ///
8 /// @brief Contains frameworks for creating custom AX functions which can
9 /// be registered within the FunctionRegistry and used during code
10 /// generation. The intended and safest way to build a function is to
11 /// use the FunctionBuilder struct with its addSignature methods. Note
12 /// that the derived Function classes provided can also be subclassed
13 /// for more granular control, however may be subject to more substantial
14 /// API changes.
15 ///
16 /// @details There are a variety of different ways to build a function
17 /// which are tailored towards different function types. The two currently
18 /// supported function implementations are C Bindings and IR generation.
19 /// Additionally, depending on the return type of the function, you may
20 /// need to declare your function an SRET (structural return) function.
21 ///
22 /// C Bindings:
23 /// As the name suggests, the CFunction class infrastructure provides
24 /// the quickest and easiest way to bind to methods in your host
25 /// application. The most important thing to consider when choosing
26 /// this approach is performance. LLVM will have no knowledge of the
27 /// function body during optimization passes. Depending on the
28 /// implementation of your method and the user's usage from AX, C
29 /// bindings may be subject to limited optimizations in comparison to
30 /// IR functions. For example, a static function which is called from
31 /// within a loop cannot be unrolled. See the CFunction templated
32 /// class.
33 ///
34 /// IR Functions:
35 /// IR Functions expect implementations to generate the body of the
36 /// function directly into IR during code generation. This ensures
37 /// optimal performance during optimization passes however can be
38 /// trickier to design. Note that, in the future, AX functions will
39 /// be internally supported to provide a better solution for
40 /// IR generated functions. See the IRFunction templated class.
41 ///
42 /// SRET Functions:
43 /// Both C Bindings and IR Functions can be marked as SRET methods.
44 /// SRET methods, in AX, are any function which returns a value which
45 /// is not a scalar (e.g. vectors, matrices). This follows the same
46 /// optimization logic as clang which will rebuild function signatures
47 /// with their return type as the first argument if the return type is
48 /// greater than a given size. You should never attempt to return
49 /// alloca's directly from functions (unless malloced).
50 ///
51 /// Some other things to consider:
52 /// - Ensure C Binding dependencies have been correctly mapped.
53 /// - Avoid calling B.CreateAlloca inside of IR functions - instead
54 /// rely on the utility method insertStaticAlloca() where possible.
55 /// - Ensure both floating point and integer argument signatures are
56 /// provided if you wish to avoid floats truncating.
57 /// - Array arguments (vectors/matrices) are always passed by pointer.
58 /// Scalar arguments are always passed by copy.
59 /// - Ensure array arguments which will not be modified are marked as
60 /// readonly. Currently, only array arguments can be passed by
61 /// "reference".
62 /// - Ensure function bodies, return types and parameters and marked
63 /// with desirable llvm attributes.
64 ///
65
66 #ifndef OPENVDB_AX_CODEGEN_FUNCTION_TYPES_HAS_BEEN_INCLUDED
67 #define OPENVDB_AX_CODEGEN_FUNCTION_TYPES_HAS_BEEN_INCLUDED
68
69 #include "Types.h"
70 #include "Utils.h" // isValidCast
71 #include "ConstantFolding.h"
72
73 #include <openvdb/version.h>
74
75 #include <llvm/IR/Constants.h>
76 #include <llvm/IR/IRBuilder.h>
77 #include <llvm/IR/Module.h>
78
79 #include <algorithm>
80 #include <functional>
81 #include <memory>
82 #include <stack>
83 #include <type_traits>
84 #include <unordered_map>
85 #include <vector>
86
87 namespace openvdb {
88 OPENVDB_USE_VERSION_NAMESPACE
89 namespace OPENVDB_VERSION_NAME {
90
91 namespace ax {
92 namespace codegen {
93
94 ////////////////////////////////////////////////////////////////////////////////
95 ////////////////////////////////////////////////////////////////////////////////
96
97 /// @brief Object to array conversion methods to allow functions to return
98 /// vector types. These containers provided an interface for automatic
99 /// conversion of C++ objects to LLVM types as array types.
100
101 template <typename T, size_t _SIZE = 1>
102 struct ArgType {
103 using Type = T;
104 static const size_t SIZE = _SIZE;
105 using ArrayType = Type[SIZE];
106 ArrayType mData;
107 };
108
109 template <typename T, size_t S>
110 struct LLVMType<ArgType<T,S>> : public AliasTypeMap<ArgType<T,S>, T[S]> {};
111
112 using V2D = ArgType<double, 2>;
113 using V2F = ArgType<float, 2>;
114 using V2I = ArgType<int32_t, 2>;
115 using V3D = ArgType<double, 3>;
116 using V3F = ArgType<float, 3>;
117 using V3I = ArgType<int32_t, 3>;
118 using V4D = ArgType<double, 4>;
119 using V4F = ArgType<float, 4>;
120 using V4I = ArgType<int32_t, 4>;
121 using M3D = ArgType<double, 9>;
122 using M3F = ArgType<float, 9>;
123 using M4D = ArgType<double, 16>;
124 using M4F = ArgType<float, 16>;
125
126 ////////////////////////////////////////////////////////////////////////////////
127
128 /// @brief Type to symbol conversions - these characters are used to build each
129 /// functions unique signature. They differ from standard AX or LLVM
130 /// syntax to be as short as possible i.e. vec4d, [4 x double] = d4
131
132
14/28
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 104 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 80 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 78 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 78 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 78 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 78 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 78 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 78 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 78 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 13 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 13 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 91 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 65 times.
✗ Branch 41 not taken.
1001 template <typename T> struct TypeToSymbol { static inline std::string s() { return "?"; } };
133
83/166
✓ Branch 1 taken 1074 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1120 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2047 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2275 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2357 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1475 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1475 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1475 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1474 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1474 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1474 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1474 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 1474 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 1474 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 1474 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 1474 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 1500 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 1500 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1522 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1522 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1518 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 1518 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 1472 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 1472 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1471 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 1471 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 1471 times.
✗ Branch 80 not taken.
✓ Branch 82 taken 1471 times.
✗ Branch 83 not taken.
✓ Branch 85 taken 1471 times.
✗ Branch 86 not taken.
✓ Branch 88 taken 1471 times.
✗ Branch 89 not taken.
✓ Branch 91 taken 1479 times.
✗ Branch 92 not taken.
✓ Branch 94 taken 1479 times.
✗ Branch 95 not taken.
✓ Branch 97 taken 1471 times.
✗ Branch 98 not taken.
✓ Branch 100 taken 1471 times.
✗ Branch 101 not taken.
✓ Branch 103 taken 1471 times.
✗ Branch 104 not taken.
✓ Branch 106 taken 1445 times.
✗ Branch 107 not taken.
✓ Branch 109 taken 1487 times.
✗ Branch 110 not taken.
✓ Branch 112 taken 1487 times.
✗ Branch 113 not taken.
✓ Branch 115 taken 1492 times.
✗ Branch 116 not taken.
✓ Branch 118 taken 1492 times.
✗ Branch 119 not taken.
✓ Branch 121 taken 801 times.
✗ Branch 122 not taken.
✓ Branch 124 taken 809 times.
✗ Branch 125 not taken.
✓ Branch 127 taken 771 times.
✗ Branch 128 not taken.
✓ Branch 130 taken 764 times.
✗ Branch 131 not taken.
✓ Branch 133 taken 764 times.
✗ Branch 134 not taken.
✓ Branch 136 taken 747 times.
✗ Branch 137 not taken.
✓ Branch 139 taken 734 times.
✗ Branch 140 not taken.
✓ Branch 142 taken 734 times.
✗ Branch 143 not taken.
✓ Branch 145 taken 724 times.
✗ Branch 146 not taken.
✓ Branch 148 taken 724 times.
✗ Branch 149 not taken.
✓ Branch 151 taken 724 times.
✗ Branch 152 not taken.
✓ Branch 154 taken 724 times.
✗ Branch 155 not taken.
✓ Branch 157 taken 724 times.
✗ Branch 158 not taken.
✓ Branch 160 taken 724 times.
✗ Branch 161 not taken.
✓ Branch 163 taken 724 times.
✗ Branch 164 not taken.
✓ Branch 166 taken 724 times.
✗ Branch 167 not taken.
✓ Branch 169 taken 724 times.
✗ Branch 170 not taken.
✓ Branch 172 taken 724 times.
✗ Branch 173 not taken.
✓ Branch 175 taken 724 times.
✗ Branch 176 not taken.
✓ Branch 178 taken 721 times.
✗ Branch 179 not taken.
✓ Branch 181 taken 724 times.
✗ Branch 182 not taken.
✓ Branch 184 taken 724 times.
✗ Branch 185 not taken.
✓ Branch 187 taken 722 times.
✗ Branch 188 not taken.
✓ Branch 190 taken 722 times.
✗ Branch 191 not taken.
✓ Branch 193 taken 732 times.
✗ Branch 194 not taken.
✓ Branch 196 taken 732 times.
✗ Branch 197 not taken.
✓ Branch 199 taken 771 times.
✗ Branch 200 not taken.
✓ Branch 202 taken 772 times.
✗ Branch 203 not taken.
✓ Branch 205 taken 719 times.
✗ Branch 206 not taken.
✓ Branch 208 taken 719 times.
✗ Branch 209 not taken.
✓ Branch 211 taken 719 times.
✗ Branch 212 not taken.
✓ Branch 214 taken 719 times.
✗ Branch 215 not taken.
✓ Branch 217 taken 719 times.
✗ Branch 218 not taken.
✓ Branch 220 taken 719 times.
✗ Branch 221 not taken.
✓ Branch 223 taken 719 times.
✗ Branch 224 not taken.
✓ Branch 226 taken 719 times.
✗ Branch 227 not taken.
✓ Branch 229 taken 719 times.
✗ Branch 230 not taken.
✓ Branch 232 taken 719 times.
✗ Branch 233 not taken.
✓ Branch 235 taken 719 times.
✗ Branch 236 not taken.
✓ Branch 238 taken 719 times.
✗ Branch 239 not taken.
✓ Branch 241 taken 719 times.
✗ Branch 242 not taken.
✓ Branch 244 taken 719 times.
✗ Branch 245 not taken.
✓ Branch 247 taken 7 times.
✗ Branch 248 not taken.
91495 template <> struct TypeToSymbol<void> { static inline std::string s() { return "v"; } };
134 598 template <> struct TypeToSymbol<char> { static inline std::string s() { return "c"; } };
135
1/2
✓ Branch 1 taken 230 times.
✗ Branch 2 not taken.
230 template <> struct TypeToSymbol<uint8_t> { static inline std::string s() { return "u8"; } };
136
1/2
✓ Branch 1 taken 230 times.
✗ Branch 2 not taken.
230 template <> struct TypeToSymbol<uint16_t> { static inline std::string s() { return "us"; } };
137 template <> struct TypeToSymbol<uint32_t> { static inline std::string s() { return "ui"; } };
138
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
58248 template <> struct TypeToSymbol<uint64_t> { static inline std::string s() { return "ul"; } };
139 template <> struct TypeToSymbol<int8_t> { static inline std::string s() { return "8"; } };
140
3/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
8670 template <> struct TypeToSymbol<int16_t> { static inline std::string s() { return "s"; } };
141
14/28
✓ Branch 1 taken 4797 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 62668 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4685 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 185 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 230 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 226 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 226 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 26 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 13 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 765 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 39 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 13 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 13 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 13 times.
✗ Branch 41 not taken.
73899 template <> struct TypeToSymbol<int32_t> { static inline std::string s() { return "i"; } };
142
4/8
✓ Branch 1 taken 170 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 26 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 13 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 765 times.
✗ Branch 11 not taken.
11402 template <> struct TypeToSymbol<int64_t> { static inline std::string s() { return "l"; } };
143
16/32
✓ Branch 1 taken 8570 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9596 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 5487 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1452 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 728 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 52 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 52 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 196 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 348 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 348 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 348 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 26 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 14 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 804 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 13 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 1975 times.
✗ Branch 47 not taken.
30009 template <> struct TypeToSymbol<float> { static inline std::string s() { return "f"; } };
144
26/52
✓ Branch 1 taken 4947 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5118 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 5058 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 5460 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 4761 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 52 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 52 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 122 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 122 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 122 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 348 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 348 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 348 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 26 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 26 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 13 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 13 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 209 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 817 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 13 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 14 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 27 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 13 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 13 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 13 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 2015 times.
✗ Branch 77 not taken.
30070 template <> struct TypeToSymbol<double> { static inline std::string s() { return "d"; } };
145 12968 template <> struct TypeToSymbol<codegen::String> { static inline std::string s() { return "a"; } };
146
147 template <typename T>
148 struct TypeToSymbol<T*> {
149
1/2
✓ Branch 2 taken 280625 times.
✗ Branch 3 not taken.
1122500 static inline std::string s() { return TypeToSymbol<T>::s() + "*"; }
150 };
151
152 template <typename T, size_t S>
153 struct TypeToSymbol<T[S]> {
154
1/2
✓ Branch 2 taken 123799 times.
✗ Branch 3 not taken.
742794 static inline std::string s() { return TypeToSymbol<T>::s() + std::to_string(S); }
155 };
156
157 template <typename T, size_t S> struct TypeToSymbol<ArgType<T,S>> : public TypeToSymbol<T[S]> {};
158 template <typename T> struct TypeToSymbol<math::Vec2<T>> : public TypeToSymbol<T[2]> {};
159 template <typename T> struct TypeToSymbol<math::Vec3<T>> : public TypeToSymbol<T[3]> {};
160 template <typename T> struct TypeToSymbol<math::Vec4<T>> : public TypeToSymbol<T[4]> {};
161 template <typename T> struct TypeToSymbol<math::Mat3<T>> : public TypeToSymbol<T[9]> {};
162 template <typename T> struct TypeToSymbol<math::Mat4<T>> : public TypeToSymbol<T[16]> {};
163 template <typename T> struct TypeToSymbol<const T> : public TypeToSymbol<T> {};
164 template <typename T> struct TypeToSymbol<const T*> : public TypeToSymbol<T*> {};
165
166 ////////////////////////////////////////////////////////////////////////////////
167 ////////////////////////////////////////////////////////////////////////////////
168
169 /// @brief Templated argument iterator which implements various small functions
170 /// per argument type, resolved at compile time.
171 ///
172 template <typename SignatureT, size_t I = FunctionTraits<SignatureT>::N_ARGS>
173 struct ArgumentIterator
174 {
175 using ArgT = typename FunctionTraits<SignatureT>::template Arg<I-1>;
176 using ArgumentValueType = typename ArgT::Type;
177
178 template <typename OpT>
179 3740476 static void apply(const OpT& op, const bool forwards) {
180
1/2
✓ Branch 0 taken 1870238 times.
✗ Branch 1 not taken.
3740476 if (forwards) {
181 2837436 ArgumentIterator<SignatureT, I-1>::apply(op, forwards);
182 3766537 op(ArgumentValueType());
183 }
184 else {
185 op(ArgumentValueType());
186 ArgumentIterator<SignatureT, I-1>::apply(op, forwards);
187 }
188 3740476 }
189 };
190
191 template <typename SignatureT>
192 struct ArgumentIterator<SignatureT, 0>
193 {
194 template <typename OpT>
195 static void apply(const OpT&, const bool) {}
196 };
197
198 ////////////////////////////////////////////////////////////////////////////////
199 ////////////////////////////////////////////////////////////////////////////////
200
201 /// @brief Populate a vector of llvm types from a function signature declaration.
202 ///
203 /// @param C The llvm context
204 /// @param types A vector of types to populate
205 ///
206 template <typename SignatureT>
207 inline llvm::Type*
208 746809 llvmTypesFromSignature(llvm::LLVMContext& C,
209 std::vector<llvm::Type*>* types = nullptr)
210 {
211 using Traits = FunctionTraits<SignatureT>;
212 using ArgumentIteratorT =
213 ArgumentIterator<SignatureT, Traits::N_ARGS>;
214
215
1/2
✓ Branch 0 taken 373545 times.
✗ Branch 1 not taken.
746809 if (types) {
216
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
746845 types->reserve(Traits::N_ARGS);
217 3787463 auto callback = [&types, &C](auto type) {
218 using Type = decltype(type);
219 1942013 types->emplace_back(LLVMType<Type>::get(C));
220 };
221 713150 ArgumentIteratorT::apply(callback, /*forwards*/true);
222 }
223 746812 return LLVMType<typename Traits::ReturnType>::get(C);
224 }
225
226 /// @brief Generate an LLVM FunctionType from a function signature
227 ///
228 /// @param C The llvm context
229 ///
230 template <typename SignatureT>
231 inline llvm::FunctionType*
232
1/2
✓ Branch 1 taken 1818 times.
✗ Branch 2 not taken.
1820 llvmFunctionTypeFromSignature(llvm::LLVMContext& C)
233 {
234 std::vector<llvm::Type*> types;
235 llvm::Type* returnType =
236
1/2
✓ Branch 1 taken 1817 times.
✗ Branch 2 not taken.
1818 llvmTypesFromSignature<SignatureT>(C, &types);
237
3/6
✓ Branch 1 taken 1818 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1817 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
1820 return llvm::FunctionType::get(/*Result=*/returnType,
238 /*Params=*/llvm::ArrayRef<llvm::Type*>(types),
239 1820 /*isVarArg=*/false);
240 }
241
242 /// @brief Print a function signature to the provided ostream.
243 ///
244 /// @param os The stream to print to
245 /// @param types The function argument types
246 /// @param returnType The return type of the function. Must not be a nullptr
247 /// @param name The name of the function. If not provided, the return type
248 /// neighbours the first parenthesis
249 /// @param names Names of the function parameters. If a name is nullptr, it
250 /// skipped
251 /// @param axTypes Whether to try and convert the llvm::Types provided to
252 /// AX types. If false, the llvm types are used.
253 OPENVDB_AX_API void
254 printSignature(std::ostream& os,
255 const std::vector<llvm::Type*>& types,
256 const llvm::Type* returnType,
257 const char* name = nullptr,
258 const std::vector<const char*>& names = {},
259 const bool axTypes = false);
260
261 ////////////////////////////////////////////////////////////////////////////////
262 ////////////////////////////////////////////////////////////////////////////////
263
264 /// @brief The base/abstract representation of an AX function. Derived classes
265 /// must implement the Function::types call to describe their signature.
266 struct OPENVDB_AX_API Function
267 {
268 using Ptr = std::shared_ptr<Function>;
269
270 108308 Function(const size_t size, const std::string& symbol)
271 108308 : mSize(size)
272 , mSymbol(symbol)
273 , mAttributes(nullptr)
274 , mNames()
275 108308 , mDeps() {
276 // symbol must be a valid string
277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108308 times.
108308 assert(!symbol.empty());
278 108308 }
279
280
2/2
✓ Branch 0 taken 3300 times.
✓ Branch 1 taken 105008 times.
433232 virtual ~Function() = default;
281
282 /// @brief Populate a vector of llvm::Types which describe this function
283 /// signature. This method is used by Function::create,
284 /// Function::print and Function::match.
285 virtual llvm::Type* types(std::vector<llvm::Type*>&, llvm::LLVMContext&) const = 0;
286
287 /// @brief Converts and creates this AX function into a llvm Function.
288 /// @details This method uses the result from Function::types() to construct
289 /// a llvm::FunctionType and a subsequent a llvm::Function. Any
290 /// parameter, return or function attributes are also added to the
291 /// function. If a module is provided, the module if first checked
292 /// to see if the function already exists. If it does, it is
293 /// immediately returned. If the function doesn't exist in the
294 /// module, its prototype is created and also inserted into the end
295 /// of the modules function list. If no module is provided, the
296 /// function is left detached and must be added to a valid Module
297 /// to be callable.
298 /// @warning If a module is not provided, the caller takes ownership of the
299 /// returned function and is responsible for deallocating it.
300 /// @note The body of the function is left to derived classes to
301 /// implement. As you need a Module to generate the prototype/body,
302 /// this function serves two purposes. The first is to return the
303 /// detached function signature if only a context is provided.
304 /// The second is to ensure the function prototype and body (if
305 /// required) is inserted into the module prior to returning.
306 /// @note It is possible to end up with function symbol collisions if you
307 /// do not have unique function symbols in your module
308 ///
309 /// @param C The LLVM Context
310 /// @param M The Module to write the function to
311 virtual llvm::Function*
312 create(llvm::LLVMContext& C, llvm::Module* M = nullptr) const;
313
314 /// @brief Convenience method which always uses the provided module to find
315 /// the function or insert it if necessary.
316 /// @param M The llvm::Module to use
317 llvm::Function* create(llvm::Module& M) const {
318
29/56
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 5 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 5 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 5 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 6 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 5 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 9 times.
✓ Branch 26 taken 1 times.
✓ Branch 28 taken 10 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 1 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 1 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 1 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 1 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 1 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 1 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 1 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 1 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 1 times.
✗ Branch 80 not taken.
✓ Branch 82 taken 1 times.
✗ Branch 83 not taken.
80 return this->create(M.getContext(), &M);
319 }
320
321 /// @brief Convenience method for calling M.getFunction(symbol). Returns a
322 /// nullptr if the function has not yet been created or if it is
323 /// embedded IR.
324 /// @param M The llvm::Module to use
325 llvm::Function* get(const llvm::Module& M) const;
326
327 /// @brief Uses the IRBuilder to create a call to this function with the
328 /// given arguments, creating the function and inserting it into the
329 /// IRBuilder's Module if necessary (through Function::create).
330 /// Returns the result of the function call which can be a nullptr
331 /// if the function is a non-sret void call.
332 /// @note The IRBuilder must have a valid llvm Module/Function/Block
333 /// attached
334 /// @note If the number of provided arguments do not match the size of the
335 /// current function, invalid IR will be generated.
336 /// @note If the provided argument types do not match the current function
337 /// and cast is false, invalid IR will be generated. Additionally,
338 /// invalid IR will be generated if cast is true but no valid cast
339 /// exists for a given argument.
340 /// @note When casting arguments, the readonly flags of the function are
341 /// not checked (unlike Function::match). Casting an argument will
342 /// cause a new copy of the argument to be created and passed to the
343 /// function. These new values do not propagate back any changes to
344 /// the original argument. Separate functions for all writable
345 /// argument types must be created.
346 ///
347 /// @param args The llvm Value arguments to call this function with
348 /// @param B The llvm IRBuilder
349 /// @param cast Whether to allow implicit casting of arguments
350 virtual llvm::Value*
351 call(const std::vector<llvm::Value*>& args,
352 llvm::IRBuilder<>& B,
353 const bool cast = false) const;
354
355 /// @brief The result type from calls to Function::match
356 enum SignatureMatch { None = 0, Size, Implicit, Explicit };
357
358 /// @brief The base implementation for determining how a vector of llvm
359 /// arguments translates to this functions signature. Returns an
360 /// enum which represents the available mapping.
361 /// @details This method calls types() to figure out the function signature,
362 /// then compares each argument type to the type in the input
363 /// vector. If the types match exactly, an Explicit match is found.
364 /// If the sizes of the inputs and signature differ, no match is
365 /// found and None is returned. If however, the sizes match and
366 /// there exists a valid implicit cast from the input type to the
367 /// signature type for every input, an Implicit match is returned.
368 /// Finally, if the sizes match but there is no implicit cast
369 /// mapping, Size is returned.
370 /// i8 -> i32 : Implicit
371 /// i32 -> i32 : Explicit
372 /// str -> i32 : Size
373 /// (i32,i32) -> i32 : None
374 /// @note Due to the way CFunctionSRet is implemented, the LLVM Context
375 /// must be provided in case we have a zero arg function signature
376 /// with a SRET.
377 /// @param inputs The input types
378 /// @param C The LLVM Context
379 virtual SignatureMatch match(const std::vector<llvm::Type*>& inputs, llvm::LLVMContext& C) const;
380
381 /// @brief The number of arguments that this function has
382
19/27
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8464 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 243012 times.
✓ Branch 4 taken 15084 times.
✓ Branch 5 taken 27538 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 48171 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 4 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 22 times.
✓ Branch 12 taken 4 times.
✓ Branch 13 taken 293566 times.
✓ Branch 14 taken 105366 times.
✓ Branch 16 taken 18743 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
759997 inline size_t size() const { return mSize; }
383
384 /// @brief The function symbol name.
385 /// @details This will be used as its identifier in IR and must be unique.
386 inline const char* symbol() const { return mSymbol.c_str(); }
387
388 /// @brief Returns the descriptive name of the given argument index
389 /// @details If the index is greater than the number of arguments, an empty
390 /// string is returned.
391 ///
392 /// @param idx The index of the argument
393 inline const char* argName(const size_t idx) const {
394
10/168
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 20123 times.
✓ Branch 3 taken 687 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✗ Branch 74 not taken.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✗ Branch 80 not taken.
✗ Branch 81 not taken.
✗ Branch 82 not taken.
✗ Branch 83 not taken.
✗ Branch 84 not taken.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
✗ Branch 87 not taken.
✗ Branch 88 not taken.
✗ Branch 89 not taken.
✗ Branch 90 not taken.
✗ Branch 91 not taken.
✗ Branch 92 not taken.
✗ Branch 93 not taken.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✗ Branch 96 not taken.
✗ Branch 97 not taken.
✗ Branch 98 not taken.
✗ Branch 99 not taken.
✗ Branch 100 not taken.
✗ Branch 101 not taken.
✗ Branch 102 not taken.
✗ Branch 103 not taken.
✗ Branch 104 not taken.
✗ Branch 105 not taken.
✗ Branch 106 not taken.
✗ Branch 107 not taken.
✗ Branch 108 not taken.
✗ Branch 109 not taken.
✗ Branch 110 not taken.
✗ Branch 111 not taken.
✗ Branch 112 not taken.
✗ Branch 113 not taken.
✗ Branch 114 not taken.
✗ Branch 115 not taken.
✗ Branch 116 not taken.
✗ Branch 117 not taken.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✗ Branch 120 not taken.
✗ Branch 121 not taken.
✗ Branch 122 not taken.
✗ Branch 123 not taken.
✗ Branch 124 not taken.
✗ Branch 125 not taken.
✗ Branch 126 not taken.
✗ Branch 127 not taken.
✗ Branch 128 not taken.
✗ Branch 129 not taken.
✗ Branch 130 not taken.
✗ Branch 131 not taken.
✗ Branch 132 not taken.
✗ Branch 133 not taken.
✗ Branch 134 not taken.
✗ Branch 135 not taken.
✗ Branch 136 not taken.
✗ Branch 137 not taken.
✗ Branch 138 not taken.
✗ Branch 139 not taken.
✗ Branch 140 not taken.
✗ Branch 141 not taken.
✗ Branch 142 not taken.
✗ Branch 143 not taken.
✗ Branch 144 not taken.
✗ Branch 145 not taken.
✗ Branch 146 not taken.
✗ Branch 147 not taken.
✗ Branch 148 not taken.
✗ Branch 149 not taken.
✗ Branch 150 not taken.
✗ Branch 151 not taken.
✗ Branch 152 not taken.
✗ Branch 153 not taken.
✗ Branch 154 not taken.
✗ Branch 155 not taken.
✗ Branch 156 not taken.
✗ Branch 157 not taken.
✗ Branch 158 not taken.
✗ Branch 159 not taken.
✗ Branch 160 not taken.
✗ Branch 161 not taken.
✗ Branch 162 not taken.
✗ Branch 163 not taken.
✗ Branch 164 not taken.
✗ Branch 165 not taken.
✗ Branch 166 not taken.
✗ Branch 167 not taken.
20839 return idx < mNames.size() ? mNames[idx] : "";
395 }
396
397 /// @brief Print this function's signature to the provided ostream.
398 /// @details This is intended to return a descriptive front end user string
399 /// rather than the function's IR representation. This function is
400 /// virtual so that derived classes can customize how they present
401 /// frontend information.
402 /// @sa printSignature
403 ///
404 /// @param C The llvm context
405 /// @param os The ostream to print to
406 /// @param name The name to insert into the description.
407 /// @param axTypes Whether to print llvm IR or AX Types.
408 virtual void print(llvm::LLVMContext& C,
409 std::ostream& os,
410 const char* name = nullptr,
411 const bool axTypes = true) const;
412
413 /// Builder methods
414
415
2/2
✓ Branch 0 taken 188402 times.
✓ Branch 1 taken 13416 times.
201818 inline bool hasParamAttribute(const size_t i,
416 const llvm::Attribute::AttrKind& kind) const
417 {
418
2/2
✓ Branch 0 taken 188402 times.
✓ Branch 1 taken 13416 times.
201818 if (!mAttributes) return false;
419
2/2
✓ Branch 0 taken 62223 times.
✓ Branch 1 taken 126179 times.
188402 const auto iter = mAttributes->mParamAttrs.find(i);
420
2/2
✓ Branch 0 taken 62223 times.
✓ Branch 1 taken 126179 times.
188402 if (iter == mAttributes->mParamAttrs.end()) return false;
421 const auto& vec = iter->second;
422 62223 return std::find(vec.begin(), vec.end(), kind) != vec.end();
423 }
424
425
2/4
✓ Branch 1 taken 7412 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8173 times.
✗ Branch 5 not taken.
15585 inline void setArgumentNames(std::vector<const char*> names) { mNames = names; }
426
427 const std::vector<const char*>& dependencies() const { return mDeps; }
428
2/4
✓ Branch 1 taken 95391 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12815 times.
✗ Branch 5 not taken.
108206 inline void setDependencies(std::vector<const char*> deps) { mDeps = deps; }
429
430 inline void setFnAttributes(const std::vector<llvm::Attribute::AttrKind>& in)
431 {
432
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
104105 this->attrs().mFnAttrs = in;
433 104105 }
434 inline void setRetAttributes(const std::vector<llvm::Attribute::AttrKind>& in)
435 {
436
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 this->attrs().mRetAttrs = in;
437 1 }
438 270570 inline void setParamAttributes(const size_t i,
439 const std::vector<llvm::Attribute::AttrKind>& in)
440 {
441 270570 this->attrs().mParamAttrs[i] = in;
442 270570 }
443
444 protected:
445
446 /// @brief Cast the provided arguments to the given type as supported by
447 /// implicit casting of function types. If the types already match
448 /// OR if a cast cannot be performed, nothing is done to the argument.
449 /// @todo This should really be generalized out for Function::call and
450 /// Function::match to both use. However, due to SRET functions,
451 /// this logic must be performed somewhere in the Function class
452 /// hierarchy and not in FunctionGroup
453 static void cast(std::vector<llvm::Value*>& args,
454 const std::vector<llvm::Type*>& types,
455 llvm::IRBuilder<>& B);
456
457 private:
458
459 struct Attributes {
460 std::vector<llvm::Attribute::AttrKind> mFnAttrs, mRetAttrs;
461 std::map<size_t, std::vector<llvm::Attribute::AttrKind>> mParamAttrs;
462 };
463
464
2/2
✓ Branch 0 taken 105073 times.
✓ Branch 1 taken 269603 times.
374676 inline Attributes& attrs() {
465
2/2
✓ Branch 0 taken 105073 times.
✓ Branch 1 taken 269603 times.
374676 if (!mAttributes) mAttributes.reset(new Attributes());
466 374676 return *mAttributes;
467 }
468
469 llvm::AttributeList flattenAttrs(llvm::LLVMContext& C) const;
470
471 const size_t mSize;
472 const std::string mSymbol;
473 std::unique_ptr<Attributes> mAttributes;
474 std::vector<const char*> mNames;
475 std::vector<const char*> mDeps;
476 };
477
478 /// @brief Templated interface class for SRET functions. This struct provides
479 /// the interface for functions that wish to return arrays (vectors or
480 /// matrices) by internally remapping the first argument for the user.
481 /// As far as LLVM and any bindings are concerned, the function
482 /// signature remains unchanged - however the first argument becomes
483 /// "invisible" to the user and is instead allocated by LLVM before the
484 /// function is executed. Importantly, the argument has no impact on
485 /// the user facing AX signature and doesn't affect declaration selection.
486 /// @note This class is not intended to be instantiated directly, but instead
487 /// used by derived implementation which hold a valid implementations
488 /// of member functions required to create a llvm::Function (such as
489 /// Function::types and Function::call). This exists as an interface to
490 /// avoid virtual inheritance.
491 ///
492 template <typename SignatureT, typename DerivedFunction>
493 struct SRetFunction : public DerivedFunction
494 {
495 using Ptr = std::shared_ptr<SRetFunction<SignatureT, DerivedFunction>>;
496 using Traits = FunctionTraits<SignatureT>;
497
498 // check there actually are arguments
499 static_assert(Traits::N_ARGS > 0,
500 "SRET Function object has been setup with the first argument as the return "
501 "value, however the provided signature is empty.");
502
503 // check no return value exists
504 static_assert(std::is_same<typename Traits::ReturnType, void>::value,
505 "SRET Function object has been setup with the first argument as the return "
506 "value and a non void return type.");
507
508 private:
509
510 using FirstArgument = typename Traits::template Arg<0>::Type;
511 static_assert(std::is_pointer<FirstArgument>::value,
512 "SRET Function object has been setup with the first argument as the return "
513 "value, but this argument it is not a pointer type.");
514 using SRetType = typename std::remove_pointer<FirstArgument>::type;
515
516 public:
517
518 /// @brief Override of match which inserts the SRET type such that the base
519 /// class methods ignore it.
520 8946 Function::SignatureMatch match(const std::vector<llvm::Type*>& args,
521 llvm::LLVMContext& C) const override
522 {
523 // append return type and right rotate
524 8946 std::vector<llvm::Type*> inputs(args);
525
2/6
✓ Branch 1 taken 4473 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2682 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
8946 inputs.emplace_back(LLVMType<SRetType*>::get(C));
526 8946 std::rotate(inputs.rbegin(), inputs.rbegin() + 1, inputs.rend());
527
1/2
✓ Branch 1 taken 4473 times.
✗ Branch 2 not taken.
17892 return DerivedFunction::match(inputs, C);
528 }
529
530 /// @brief Override of call which allocates the required SRET llvm::Value
531 /// for this function.
532 /// @note Unlike other function where the returned llvm::Value* is a
533 /// llvm::CallInst (which also represents the return value),
534 /// SRET functions return the allocated 1st argument i.e. not a
535 /// llvm::CallInst
536 llvm::Value*
537 3920 call(const std::vector<llvm::Value*>& args,
538 llvm::IRBuilder<>& B,
539 const bool cast) const override
540 {
541 // append return value and right rotate
542 3920 std::vector<llvm::Value*> inputs(args);
543
1/2
✓ Branch 1 taken 848 times.
✗ Branch 2 not taken.
1696 llvm::Type* sret = LLVMType<SRetType>::get(B.getContext());
544
2/6
✓ Branch 1 taken 1960 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1960 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
3920 inputs.emplace_back(insertStaticAlloca(B, sret));
545 3920 std::rotate(inputs.rbegin(), inputs.rbegin() + 1, inputs.rend());
546
1/2
✓ Branch 1 taken 1960 times.
✗ Branch 2 not taken.
3920 DerivedFunction::call(inputs, B, cast);
547
1/2
✓ Branch 0 taken 1960 times.
✗ Branch 1 not taken.
7840 return inputs.front();
548 }
549
550 /// @brief Override of print to avoid printing out the SRET type
551
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
6 void print(llvm::LLVMContext& C,
552 std::ostream& os,
553 const char* name = nullptr,
554 const bool axTypes = true) const override
555 {
556 std::vector<llvm::Type*> current;
557
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
6 llvm::Type* ret = this->types(current, C);
558 // left rotate
559
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
6 std::rotate(current.begin(), current.begin() + 1, current.end());
560
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
6 ret = current.back();
561 current.pop_back();
562
563 std::vector<const char*> names;
564
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
6 names.reserve(this->size());
565
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
8 for (size_t i = 0; i < this->size()-1; ++i) {
566
1/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 names.emplace_back(this->argName(i));
567 }
568
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
6 printSignature(os, current, ret, name, names, axTypes);
569 6 }
570
571 protected:
572 /// @brief Forward all arguments to the derived class
573 template <typename ...Args>
574 SRetFunction(Args&&... ts) : DerivedFunction(ts...) {}
575 };
576
577 /// @brief The base class for all C bindings.
578 struct CFunctionBase : public Function
579 {
580 using Ptr = std::shared_ptr<CFunctionBase>;
581
582 94364 ~CFunctionBase() override = default;
583
584 /// @brief Returns the global address of this function.
585 /// @note This is only required for C bindings.
586 virtual uint64_t address() const = 0;
587
588
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
95394 inline void setConstantFold(bool on) { mConstantFold = on; }
589
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
28547 inline bool hasConstantFold() const { return mConstantFold; }
590
591 inline virtual llvm::Value* fold(const std::vector<llvm::Value*>&,
592 llvm::LLVMContext&) const {
593 return nullptr;
594 }
595
596 protected:
597 CFunctionBase(const size_t size,
598 const std::string& symbol)
599 95402 : Function(size, symbol)
600 190804 , mConstantFold(false) {}
601
602 private:
603 bool mConstantFold;
604 };
605
606 /// @brief Represents a concrete C function binding.
607 ///
608 /// @note This struct is templated on the signature to allow for evaluation of
609 /// the arguments to llvm types from any llvm context.
610 ///
611 template <typename SignatureT>
612 struct CFunction : public CFunctionBase
613 {
614 using CFunctionT = CFunction<SignatureT>;
615 using Ptr = std::shared_ptr<CFunctionT>;
616 using Traits = FunctionTraits<SignatureT>;
617
618 // Assert that the return argument is not a pointer (relaxed for void* for mallocs).
619 // Note that this is relaxed for IR functions where it's allowed if the function is
620 // forcefully inlined.
621 static_assert(std::is_same<typename Traits::ReturnType, void*>::value ||
622 !std::is_pointer<typename Traits::ReturnType>::value,
623 "CFunction object has been setup with a pointer return argument. C bindings "
624 "cannot return memory locations to LLVM - Consider using a CFunctionSRet.");
625
626
123/246
✓ Branch 1 taken 876 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 782 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 858 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1634 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1575 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1902 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1734 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1461 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1461 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1461 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1461 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1461 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 1460 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 1460 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 1460 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 1460 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 1473 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 1473 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1484 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1484 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1480 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 1480 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 1456 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 1458 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1458 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 1458 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 1458 times.
✗ Branch 80 not taken.
✓ Branch 82 taken 1458 times.
✗ Branch 83 not taken.
✓ Branch 85 taken 1458 times.
✗ Branch 86 not taken.
✓ Branch 88 taken 1458 times.
✗ Branch 89 not taken.
✓ Branch 91 taken 1471 times.
✗ Branch 92 not taken.
✓ Branch 94 taken 1471 times.
✗ Branch 95 not taken.
✓ Branch 97 taken 1471 times.
✗ Branch 98 not taken.
✓ Branch 100 taken 1471 times.
✗ Branch 101 not taken.
✓ Branch 103 taken 1484 times.
✗ Branch 104 not taken.
✓ Branch 106 taken 1484 times.
✗ Branch 107 not taken.
✓ Branch 109 taken 1484 times.
✗ Branch 110 not taken.
✓ Branch 112 taken 1484 times.
✗ Branch 113 not taken.
✓ Branch 115 taken 1484 times.
✗ Branch 116 not taken.
✓ Branch 118 taken 1484 times.
✗ Branch 119 not taken.
✓ Branch 121 taken 790 times.
✗ Branch 122 not taken.
✓ Branch 124 taken 790 times.
✗ Branch 125 not taken.
✓ Branch 127 taken 784 times.
✗ Branch 128 not taken.
✓ Branch 130 taken 760 times.
✗ Branch 131 not taken.
✓ Branch 133 taken 806 times.
✗ Branch 134 not taken.
✓ Branch 136 taken 806 times.
✗ Branch 137 not taken.
✓ Branch 139 taken 1097 times.
✗ Branch 140 not taken.
✓ Branch 142 taken 1097 times.
✗ Branch 143 not taken.
✓ Branch 145 taken 819 times.
✗ Branch 146 not taken.
✓ Branch 148 taken 738 times.
✗ Branch 149 not taken.
✓ Branch 151 taken 738 times.
✗ Branch 152 not taken.
✓ Branch 154 taken 782 times.
✗ Branch 155 not taken.
✓ Branch 157 taken 782 times.
✗ Branch 158 not taken.
✓ Branch 160 taken 782 times.
✗ Branch 161 not taken.
✓ Branch 163 taken 834 times.
✗ Branch 164 not taken.
✓ Branch 166 taken 895 times.
✗ Branch 167 not taken.
✓ Branch 169 taken 895 times.
✗ Branch 170 not taken.
✓ Branch 172 taken 834 times.
✗ Branch 173 not taken.
✓ Branch 175 taken 895 times.
✗ Branch 176 not taken.
✓ Branch 178 taken 895 times.
✗ Branch 179 not taken.
✓ Branch 181 taken 834 times.
✗ Branch 182 not taken.
✓ Branch 184 taken 895 times.
✗ Branch 185 not taken.
✓ Branch 187 taken 895 times.
✗ Branch 188 not taken.
✓ Branch 190 taken 732 times.
✗ Branch 191 not taken.
✓ Branch 193 taken 732 times.
✗ Branch 194 not taken.
✓ Branch 196 taken 732 times.
✗ Branch 197 not taken.
✓ Branch 199 taken 732 times.
✗ Branch 200 not taken.
✓ Branch 202 taken 732 times.
✗ Branch 203 not taken.
✓ Branch 205 taken 732 times.
✗ Branch 206 not taken.
✓ Branch 208 taken 732 times.
✗ Branch 209 not taken.
✓ Branch 211 taken 732 times.
✗ Branch 212 not taken.
✓ Branch 214 taken 732 times.
✗ Branch 215 not taken.
✓ Branch 217 taken 720 times.
✗ Branch 218 not taken.
✓ Branch 220 taken 720 times.
✗ Branch 221 not taken.
✓ Branch 223 taken 761 times.
✗ Branch 224 not taken.
✓ Branch 226 taken 761 times.
✗ Branch 227 not taken.
✓ Branch 229 taken 749 times.
✗ Branch 230 not taken.
✓ Branch 232 taken 749 times.
✗ Branch 233 not taken.
✓ Branch 235 taken 749 times.
✗ Branch 236 not taken.
✓ Branch 238 taken 749 times.
✗ Branch 239 not taken.
✓ Branch 241 taken 745 times.
✗ Branch 242 not taken.
✓ Branch 244 taken 732 times.
✗ Branch 245 not taken.
✓ Branch 247 taken 732 times.
✗ Branch 248 not taken.
✓ Branch 250 taken 33 times.
✗ Branch 251 not taken.
✓ Branch 253 taken 13 times.
✗ Branch 254 not taken.
✓ Branch 256 taken 13 times.
✗ Branch 257 not taken.
✓ Branch 259 taken 3 times.
✗ Branch 260 not taken.
✓ Branch 262 taken 3 times.
✗ Branch 263 not taken.
✓ Branch 265 taken 3 times.
✗ Branch 266 not taken.
✓ Branch 268 taken 3 times.
✗ Branch 269 not taken.
✓ Branch 271 taken 3 times.
✗ Branch 272 not taken.
✓ Branch 274 taken 3 times.
✗ Branch 275 not taken.
✓ Branch 277 taken 3 times.
✗ Branch 278 not taken.
✓ Branch 280 taken 3 times.
✗ Branch 281 not taken.
✓ Branch 283 taken 3 times.
✗ Branch 284 not taken.
✓ Branch 286 taken 3 times.
✗ Branch 287 not taken.
✓ Branch 289 taken 3 times.
✗ Branch 290 not taken.
✓ Branch 292 taken 3 times.
✗ Branch 293 not taken.
✓ Branch 295 taken 3 times.
✗ Branch 296 not taken.
✓ Branch 298 taken 3 times.
✗ Branch 299 not taken.
✓ Branch 301 taken 3 times.
✗ Branch 302 not taken.
✓ Branch 304 taken 3 times.
✗ Branch 305 not taken.
✓ Branch 307 taken 3 times.
✗ Branch 308 not taken.
✓ Branch 310 taken 3 times.
✗ Branch 311 not taken.
✓ Branch 313 taken 13 times.
✗ Branch 314 not taken.
✓ Branch 316 taken 13 times.
✗ Branch 317 not taken.
✓ Branch 319 taken 13 times.
✗ Branch 320 not taken.
✓ Branch 322 taken 402 times.
✗ Branch 323 not taken.
✓ Branch 325 taken 13 times.
✗ Branch 326 not taken.
✓ Branch 328 taken 13 times.
✗ Branch 329 not taken.
✓ Branch 331 taken 13 times.
✗ Branch 332 not taken.
✓ Branch 334 taken 111 times.
✗ Branch 335 not taken.
✓ Branch 337 taken 415 times.
✗ Branch 338 not taken.
✓ Branch 340 taken 13 times.
✗ Branch 341 not taken.
✓ Branch 343 taken 13 times.
✗ Branch 344 not taken.
✓ Branch 346 taken 52 times.
✗ Branch 347 not taken.
✓ Branch 349 taken 26 times.
✗ Branch 350 not taken.
✓ Branch 352 taken 13 times.
✗ Branch 353 not taken.
✓ Branch 355 taken 14 times.
✗ Branch 356 not taken.
✓ Branch 358 taken 27 times.
✗ Branch 359 not taken.
✓ Branch 361 taken 1028 times.
✗ Branch 362 not taken.
✓ Branch 364 taken 1068 times.
✗ Branch 365 not taken.
✓ Branch 367 taken 1 times.
✗ Branch 368 not taken.
95402 CFunction(const std::string& symbol, SignatureT* function)
627 : CFunctionBase(Traits::N_ARGS, symbol)
628
81/162
✓ Branch 1 taken 870 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1528 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1914 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1746 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1473 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1473 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1486 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1486 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1486 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1486 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1486 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1486 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 1486 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 1486 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 1486 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 1486 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 1532 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 1532 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1823 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1823 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1541 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 1506 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 1506 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 1506 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1558 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 1619 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 1619 times.
✗ Branch 80 not taken.
✓ Branch 82 taken 1558 times.
✗ Branch 83 not taken.
✓ Branch 85 taken 1619 times.
✗ Branch 86 not taken.
✓ Branch 88 taken 1619 times.
✗ Branch 89 not taken.
✓ Branch 91 taken 1558 times.
✗ Branch 92 not taken.
✓ Branch 94 taken 1619 times.
✗ Branch 95 not taken.
✓ Branch 97 taken 1619 times.
✗ Branch 98 not taken.
✓ Branch 100 taken 1458 times.
✗ Branch 101 not taken.
✓ Branch 103 taken 1458 times.
✗ Branch 104 not taken.
✓ Branch 106 taken 1458 times.
✗ Branch 107 not taken.
✓ Branch 109 taken 1458 times.
✗ Branch 110 not taken.
✓ Branch 112 taken 1458 times.
✗ Branch 113 not taken.
✓ Branch 115 taken 1458 times.
✗ Branch 116 not taken.
✓ Branch 118 taken 1446 times.
✗ Branch 119 not taken.
✓ Branch 121 taken 752 times.
✗ Branch 122 not taken.
✓ Branch 124 taken 793 times.
✗ Branch 125 not taken.
✓ Branch 127 taken 787 times.
✗ Branch 128 not taken.
✓ Branch 130 taken 724 times.
✗ Branch 131 not taken.
✓ Branch 133 taken 724 times.
✗ Branch 134 not taken.
✓ Branch 136 taken 724 times.
✗ Branch 137 not taken.
✓ Branch 139 taken 724 times.
✗ Branch 140 not taken.
✓ Branch 142 taken 724 times.
✗ Branch 143 not taken.
✓ Branch 145 taken 724 times.
✗ Branch 146 not taken.
✓ Branch 148 taken 724 times.
✗ Branch 149 not taken.
✓ Branch 151 taken 724 times.
✗ Branch 152 not taken.
✓ Branch 154 taken 724 times.
✗ Branch 155 not taken.
✓ Branch 157 taken 724 times.
✗ Branch 158 not taken.
✓ Branch 160 taken 724 times.
✗ Branch 161 not taken.
✓ Branch 163 taken 724 times.
✗ Branch 164 not taken.
✓ Branch 166 taken 724 times.
✗ Branch 167 not taken.
✓ Branch 169 taken 724 times.
✗ Branch 170 not taken.
✓ Branch 172 taken 724 times.
✗ Branch 173 not taken.
✓ Branch 175 taken 724 times.
✗ Branch 176 not taken.
✓ Branch 178 taken 724 times.
✗ Branch 179 not taken.
✓ Branch 181 taken 724 times.
✗ Branch 182 not taken.
✓ Branch 184 taken 732 times.
✗ Branch 185 not taken.
✓ Branch 187 taken 732 times.
✗ Branch 188 not taken.
✓ Branch 190 taken 732 times.
✗ Branch 191 not taken.
✓ Branch 193 taken 1121 times.
✗ Branch 194 not taken.
✓ Branch 196 taken 732 times.
✗ Branch 197 not taken.
✓ Branch 199 taken 830 times.
✗ Branch 200 not taken.
✓ Branch 202 taken 1134 times.
✗ Branch 203 not taken.
✓ Branch 205 taken 732 times.
✗ Branch 206 not taken.
✓ Branch 208 taken 732 times.
✗ Branch 209 not taken.
✓ Branch 211 taken 771 times.
✗ Branch 212 not taken.
✓ Branch 214 taken 745 times.
✗ Branch 215 not taken.
✓ Branch 217 taken 732 times.
✗ Branch 218 not taken.
✓ Branch 220 taken 733 times.
✗ Branch 221 not taken.
✓ Branch 223 taken 746 times.
✗ Branch 224 not taken.
✓ Branch 226 taken 1747 times.
✗ Branch 227 not taken.
✓ Branch 229 taken 1787 times.
✗ Branch 230 not taken.
✓ Branch 232 taken 720 times.
✗ Branch 233 not taken.
✓ Branch 235 taken 719 times.
✗ Branch 236 not taken.
✓ Branch 238 taken 719 times.
✗ Branch 239 not taken.
✓ Branch 241 taken 719 times.
✗ Branch 242 not taken.
94204 , mFunction(function) {}
629
630
2/4
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
188390 ~CFunction() override = default;
631
632 585024 inline llvm::Type* types(std::vector<llvm::Type*>& types, llvm::LLVMContext& C) const override
633 {
634
5/10
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
585029 return llvmTypesFromSignature<SignatureT>(C, &types);
635 }
636
637 20432 inline uint64_t address() const override final {
638
6/12
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
20438 return reinterpret_cast<uint64_t>(mFunction);
639 }
640
641 llvm::Value*
642 57608 call(const std::vector<llvm::Value*>& args,
643 llvm::IRBuilder<>& B,
644 const bool cast) const override
645 {
646 57608 llvm::Value* result = this->fold(args, B.getContext());
647
2/2
✓ Branch 0 taken 28364 times.
✓ Branch 1 taken 440 times.
57608 if (result) return result;
648 56728 return Function::call(args, B, cast);
649 }
650
651 57618 llvm::Value* fold(const std::vector<llvm::Value*>& args, llvm::LLVMContext& C) const override final
652 {
653 auto allconst =
654 1495 [](const std::vector<llvm::Value*>& vals) -> bool {
655
86/246
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 116 times.
✓ Branch 3 taken 88 times.
✓ Branch 4 taken 128 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 128 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 20 times.
✓ Branch 13 taken 12 times.
✓ Branch 14 taken 48 times.
✓ Branch 15 taken 8 times.
✓ Branch 16 taken 5 times.
✓ Branch 17 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 19 taken 1 times.
✓ Branch 20 taken 253 times.
✓ Branch 21 taken 149 times.
✓ Branch 22 taken 153 times.
✓ Branch 23 taken 49 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 4 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 4 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 120 times.
✓ Branch 31 taken 60 times.
✓ Branch 32 taken 52 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 52 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 16 times.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✓ Branch 74 taken 4 times.
✗ Branch 75 not taken.
✓ Branch 76 taken 4 times.
✗ Branch 77 not taken.
✓ Branch 78 taken 8 times.
✗ Branch 79 not taken.
✓ Branch 80 taken 4 times.
✗ Branch 81 not taken.
✓ Branch 82 taken 4 times.
✗ Branch 83 not taken.
✓ Branch 84 taken 8 times.
✗ Branch 85 not taken.
✓ Branch 86 taken 8 times.
✗ Branch 87 not taken.
✓ Branch 88 taken 8 times.
✗ Branch 89 not taken.
✓ Branch 90 taken 8 times.
✗ Branch 91 not taken.
✓ Branch 92 taken 8 times.
✗ Branch 93 not taken.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✗ Branch 96 not taken.
✗ Branch 97 not taken.
✗ Branch 98 not taken.
✗ Branch 99 not taken.
✗ Branch 100 not taken.
✗ Branch 101 not taken.
✗ Branch 102 not taken.
✗ Branch 103 not taken.
✓ Branch 104 taken 4 times.
✓ Branch 105 taken 4 times.
✓ Branch 106 taken 12 times.
✓ Branch 107 taken 12 times.
✓ Branch 108 taken 4 times.
✗ Branch 109 not taken.
✓ Branch 110 taken 8 times.
✗ Branch 111 not taken.
✗ Branch 112 not taken.
✗ Branch 113 not taken.
✓ Branch 114 taken 4 times.
✗ Branch 115 not taken.
✓ Branch 116 taken 8 times.
✗ Branch 117 not taken.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✓ Branch 120 taken 8 times.
✗ Branch 121 not taken.
✓ Branch 122 taken 8 times.
✗ Branch 123 not taken.
✓ Branch 124 taken 4 times.
✗ Branch 125 not taken.
✓ Branch 126 taken 8 times.
✗ Branch 127 not taken.
✓ Branch 128 taken 8 times.
✗ Branch 129 not taken.
✓ Branch 130 taken 4 times.
✗ Branch 131 not taken.
✓ Branch 132 taken 8 times.
✗ Branch 133 not taken.
✓ Branch 134 taken 8 times.
✗ Branch 135 not taken.
✓ Branch 136 taken 4 times.
✗ Branch 137 not taken.
✓ Branch 138 taken 4 times.
✗ Branch 139 not taken.
✓ Branch 140 taken 4 times.
✗ Branch 141 not taken.
✓ Branch 142 taken 4 times.
✗ Branch 143 not taken.
✓ Branch 144 taken 4 times.
✗ Branch 145 not taken.
✓ Branch 146 taken 4 times.
✗ Branch 147 not taken.
✓ Branch 148 taken 16 times.
✓ Branch 149 taken 4 times.
✗ Branch 150 not taken.
✗ Branch 151 not taken.
✓ Branch 152 taken 112 times.
✓ Branch 153 taken 56 times.
✗ Branch 154 not taken.
✗ Branch 155 not taken.
✓ Branch 156 taken 4 times.
✗ Branch 157 not taken.
✗ Branch 158 not taken.
✗ Branch 159 not taken.
✗ Branch 160 not taken.
✗ Branch 161 not taken.
✗ Branch 162 not taken.
✗ Branch 163 not taken.
✗ Branch 164 not taken.
✗ Branch 165 not taken.
✗ Branch 166 not taken.
✗ Branch 167 not taken.
✗ Branch 168 not taken.
✗ Branch 169 not taken.
✗ Branch 170 not taken.
✗ Branch 171 not taken.
✗ Branch 172 not taken.
✗ Branch 173 not taken.
✗ Branch 174 not taken.
✗ Branch 175 not taken.
✗ Branch 176 not taken.
✗ Branch 177 not taken.
✓ Branch 178 taken 8 times.
✗ Branch 179 not taken.
✓ Branch 180 taken 8 times.
✗ Branch 181 not taken.
✓ Branch 182 taken 4 times.
✗ Branch 183 not taken.
✓ Branch 184 taken 4 times.
✗ Branch 185 not taken.
✓ Branch 186 taken 4 times.
✗ Branch 187 not taken.
✓ Branch 188 taken 4 times.
✗ Branch 189 not taken.
✓ Branch 190 taken 4 times.
✗ Branch 191 not taken.
✓ Branch 192 taken 4 times.
✗ Branch 193 not taken.
✓ Branch 194 taken 4 times.
✗ Branch 195 not taken.
✓ Branch 196 taken 4 times.
✗ Branch 197 not taken.
✓ Branch 198 taken 4 times.
✗ Branch 199 not taken.
✓ Branch 200 taken 4 times.
✗ Branch 201 not taken.
✗ Branch 202 not taken.
✗ Branch 203 not taken.
✗ Branch 204 not taken.
✗ Branch 205 not taken.
✗ Branch 206 not taken.
✗ Branch 207 not taken.
✗ Branch 208 not taken.
✗ Branch 209 not taken.
✓ Branch 210 taken 24 times.
✗ Branch 211 not taken.
✓ Branch 212 taken 24 times.
✗ Branch 213 not taken.
✓ Branch 214 taken 8 times.
✗ Branch 215 not taken.
✗ Branch 216 not taken.
✗ Branch 217 not taken.
✓ Branch 218 taken 16 times.
✗ Branch 219 not taken.
✗ Branch 220 not taken.
✗ Branch 221 not taken.
✓ Branch 222 taken 8 times.
✗ Branch 223 not taken.
✗ Branch 224 not taken.
✗ Branch 225 not taken.
✓ Branch 226 taken 8 times.
✗ Branch 227 not taken.
✗ Branch 228 not taken.
✗ Branch 229 not taken.
✓ Branch 230 taken 16 times.
✗ Branch 231 not taken.
✗ Branch 232 not taken.
✗ Branch 233 not taken.
✓ Branch 234 taken 8 times.
✗ Branch 235 not taken.
✗ Branch 236 not taken.
✗ Branch 237 not taken.
✓ Branch 238 taken 20 times.
✗ Branch 239 not taken.
✓ Branch 240 taken 20 times.
✗ Branch 241 not taken.
✓ Branch 242 taken 4 times.
✗ Branch 243 not taken.
✓ Branch 244 taken 4 times.
✗ Branch 245 not taken.
2293 for (auto& value : vals) {
656
81/246
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 88 times.
✓ Branch 4 taken 128 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 128 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 8 times.
✓ Branch 13 taken 12 times.
✓ Branch 14 taken 40 times.
✓ Branch 15 taken 8 times.
✓ Branch 16 taken 4 times.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 1 times.
✓ Branch 20 taken 44 times.
✓ Branch 21 taken 209 times.
✓ Branch 22 taken 8 times.
✓ Branch 23 taken 145 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 4 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 4 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 120 times.
✓ Branch 32 taken 52 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 52 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 16 times.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✓ Branch 74 taken 4 times.
✗ Branch 75 not taken.
✓ Branch 76 taken 4 times.
✗ Branch 77 not taken.
✓ Branch 78 taken 8 times.
✗ Branch 79 not taken.
✓ Branch 80 taken 4 times.
✗ Branch 81 not taken.
✓ Branch 82 taken 4 times.
✗ Branch 83 not taken.
✓ Branch 84 taken 8 times.
✗ Branch 85 not taken.
✓ Branch 86 taken 8 times.
✗ Branch 87 not taken.
✓ Branch 88 taken 8 times.
✗ Branch 89 not taken.
✓ Branch 90 taken 8 times.
✗ Branch 91 not taken.
✓ Branch 92 taken 8 times.
✗ Branch 93 not taken.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✗ Branch 96 not taken.
✗ Branch 97 not taken.
✗ Branch 98 not taken.
✗ Branch 99 not taken.
✗ Branch 100 not taken.
✗ Branch 101 not taken.
✗ Branch 102 not taken.
✗ Branch 103 not taken.
✗ Branch 104 not taken.
✓ Branch 105 taken 4 times.
✗ Branch 106 not taken.
✓ Branch 107 taken 12 times.
✓ Branch 108 taken 4 times.
✗ Branch 109 not taken.
✓ Branch 110 taken 8 times.
✗ Branch 111 not taken.
✗ Branch 112 not taken.
✗ Branch 113 not taken.
✓ Branch 114 taken 4 times.
✗ Branch 115 not taken.
✓ Branch 116 taken 8 times.
✗ Branch 117 not taken.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✓ Branch 120 taken 8 times.
✗ Branch 121 not taken.
✓ Branch 122 taken 8 times.
✗ Branch 123 not taken.
✓ Branch 124 taken 4 times.
✗ Branch 125 not taken.
✓ Branch 126 taken 8 times.
✗ Branch 127 not taken.
✓ Branch 128 taken 8 times.
✗ Branch 129 not taken.
✓ Branch 130 taken 4 times.
✗ Branch 131 not taken.
✓ Branch 132 taken 8 times.
✗ Branch 133 not taken.
✓ Branch 134 taken 8 times.
✗ Branch 135 not taken.
✓ Branch 136 taken 4 times.
✗ Branch 137 not taken.
✓ Branch 138 taken 4 times.
✗ Branch 139 not taken.
✓ Branch 140 taken 4 times.
✗ Branch 141 not taken.
✓ Branch 142 taken 4 times.
✗ Branch 143 not taken.
✓ Branch 144 taken 4 times.
✗ Branch 145 not taken.
✓ Branch 146 taken 4 times.
✗ Branch 147 not taken.
✓ Branch 148 taken 4 times.
✓ Branch 149 taken 12 times.
✗ Branch 150 not taken.
✗ Branch 151 not taken.
✗ Branch 152 not taken.
✓ Branch 153 taken 112 times.
✗ Branch 154 not taken.
✗ Branch 155 not taken.
✓ Branch 156 taken 4 times.
✗ Branch 157 not taken.
✗ Branch 158 not taken.
✗ Branch 159 not taken.
✗ Branch 160 not taken.
✗ Branch 161 not taken.
✗ Branch 162 not taken.
✗ Branch 163 not taken.
✗ Branch 164 not taken.
✗ Branch 165 not taken.
✗ Branch 166 not taken.
✗ Branch 167 not taken.
✗ Branch 168 not taken.
✗ Branch 169 not taken.
✗ Branch 170 not taken.
✗ Branch 171 not taken.
✗ Branch 172 not taken.
✗ Branch 173 not taken.
✗ Branch 174 not taken.
✗ Branch 175 not taken.
✗ Branch 176 not taken.
✗ Branch 177 not taken.
✓ Branch 178 taken 8 times.
✗ Branch 179 not taken.
✓ Branch 180 taken 8 times.
✗ Branch 181 not taken.
✓ Branch 182 taken 4 times.
✗ Branch 183 not taken.
✓ Branch 184 taken 4 times.
✗ Branch 185 not taken.
✓ Branch 186 taken 4 times.
✗ Branch 187 not taken.
✓ Branch 188 taken 4 times.
✗ Branch 189 not taken.
✓ Branch 190 taken 4 times.
✗ Branch 191 not taken.
✓ Branch 192 taken 4 times.
✗ Branch 193 not taken.
✓ Branch 194 taken 4 times.
✗ Branch 195 not taken.
✓ Branch 196 taken 4 times.
✗ Branch 197 not taken.
✓ Branch 198 taken 4 times.
✗ Branch 199 not taken.
✓ Branch 200 taken 4 times.
✗ Branch 201 not taken.
✗ Branch 202 not taken.
✗ Branch 203 not taken.
✗ Branch 204 not taken.
✗ Branch 205 not taken.
✗ Branch 206 not taken.
✗ Branch 207 not taken.
✗ Branch 208 not taken.
✗ Branch 209 not taken.
✓ Branch 210 taken 24 times.
✗ Branch 211 not taken.
✓ Branch 212 taken 24 times.
✗ Branch 213 not taken.
✓ Branch 214 taken 8 times.
✗ Branch 215 not taken.
✗ Branch 216 not taken.
✗ Branch 217 not taken.
✓ Branch 218 taken 16 times.
✗ Branch 219 not taken.
✗ Branch 220 not taken.
✗ Branch 221 not taken.
✓ Branch 222 taken 8 times.
✗ Branch 223 not taken.
✗ Branch 224 not taken.
✗ Branch 225 not taken.
✓ Branch 226 taken 8 times.
✗ Branch 227 not taken.
✗ Branch 228 not taken.
✗ Branch 229 not taken.
✓ Branch 230 taken 16 times.
✗ Branch 231 not taken.
✗ Branch 232 not taken.
✗ Branch 233 not taken.
✓ Branch 234 taken 8 times.
✗ Branch 235 not taken.
✗ Branch 236 not taken.
✗ Branch 237 not taken.
✓ Branch 238 taken 20 times.
✗ Branch 239 not taken.
✓ Branch 240 taken 20 times.
✗ Branch 241 not taken.
✓ Branch 242 taken 4 times.
✗ Branch 243 not taken.
✓ Branch 244 taken 4 times.
✗ Branch 245 not taken.
1775 if (!llvm::isa<llvm::Constant>(value)) return false;
657 }
658 518 return true;
659 };
660
661
2/2
✓ Branch 0 taken 1495 times.
✓ Branch 1 taken 27314 times.
57618 if (!this->hasConstantFold()) return nullptr;
662
2/2
✓ Branch 1 taken 518 times.
✓ Branch 2 taken 977 times.
2990 if (!allconst(args)) return nullptr;
663 std::vector<llvm::Constant*> constants;
664
1/2
✓ Branch 1 taken 518 times.
✗ Branch 2 not taken.
1036 constants.reserve(args.size());
665
2/2
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 518 times.
2632 for (auto& value : args) {
666
1/4
✓ Branch 2 taken 798 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1596 constants.emplace_back(llvm::cast<llvm::Constant>(value));
667 }
668
669 // no guarantee that fold() will be able to cast all arguments
670
1/2
✓ Branch 1 taken 518 times.
✗ Branch 2 not taken.
1036 return ConstantFolder<SignatureT>::fold(constants, *mFunction, C);
671 }
672
673 private:
674 SignatureT* mFunction;
675 };
676
677 /// @brief The base/abstract definition for an IR function.
678 struct OPENVDB_AX_API IRFunctionBase : public Function
679 {
680 using Ptr = std::shared_ptr<IRFunctionBase>;
681
682 /// @brief The IR callback function which will write the LLVM IR for this
683 /// function's body.
684 /// @details The first argument is the vector of functional arguments. i.e.
685 /// a representation of the value that the callback has been invoked
686 /// with.
687 /// The last argument is the IR builder which should be used to
688 /// generate the function body IR.
689 /// @note You can return a nullptr from this method which will represent
690 /// a ret void, a ret void instruction, or an actual value
691 using GeneratorCb = std::function<llvm::Value*
692 (const std::vector<llvm::Value*>&, llvm::IRBuilder<>&)>;
693
694 /// @brief Enable or disable the embedding of IR. Embedded IR is currently
695 /// required for function which use parent function parameters.
696
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
12815 inline void setEmbedIR(bool on) { mEmbedIR = on; }
697
4/4
✓ Branch 0 taken 15363 times.
✓ Branch 1 taken 110 times.
✓ Branch 2 taken 19182 times.
✓ Branch 3 taken 2 times.
34657 inline bool hasEmbedIR() const { return mEmbedIR; }
698
699 /// @brief Override for the creation of an IR function. This ensures that
700 /// the body and prototype of the function are generated if a Module
701 /// is provided.
702 /// @note A nullptr is returned if mEmbedIR is true and no action is
703 /// performed.
704 /// @note Throws if this function has been initialized with a nullptr
705 /// generator callback. In this case, the function prototype will
706 /// be created, but not the function body.
707 /// @note Throws if the return type of the generator callback does not
708 /// match the function prototype. In this case, both the prototype
709 /// and the function body will be created and inserted, but the IR
710 /// will be invalid.
711 llvm::Function*
712 create(llvm::LLVMContext& C, llvm::Module* M) const override;
713
714 /// @brief Override for call, which is only necessary if mEmbedIR is true,
715 /// as the IR generation for embedded functions is delayed until
716 /// the function is called. If mEmbedIR is false, this simply calls
717 /// Function::call
718 llvm::Value*
719 call(const std::vector<llvm::Value*>& args,
720 llvm::IRBuilder<>& B,
721 const bool cast) const override;
722
723 protected:
724
725 // @todo This should ideally live in FunctionGroup::execute, but the return
726 // type is allowed to differ for sret C bindings.
727 inline void
728 8544 verifyResultType(const llvm::Type* result, const llvm::Type* expected) const
729 {
730
2/2
✓ Branch 0 taken 8543 times.
✓ Branch 1 taken 1 times.
8544 if (result == expected) return;
731 std::string source, target;
732
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
1 if (result) llvmTypeToString(result, source);
733
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 llvmTypeToString(expected, target);
734
7/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
7 OPENVDB_THROW(AXCodeGenError, "Function \"" + std::string(this->symbol()) +
735 "\" has been invoked with a mismatching return type. Expected: \"" +
736 target + "\", got \"" + source + "\".");
737 }
738
739 12820 IRFunctionBase(const std::string& symbol,
740 const GeneratorCb& gen,
741 const size_t size)
742 12820 : Function(size, symbol)
743 , mGen(gen)
744
1/2
✓ Branch 2 taken 12820 times.
✗ Branch 3 not taken.
12820 , mEmbedIR(false) {}
745
1/2
✓ Branch 0 taken 12820 times.
✗ Branch 1 not taken.
51280 ~IRFunctionBase() override = default;
746
747 const GeneratorCb mGen;
748 bool mEmbedIR;
749 };
750
751 /// @brief Represents a concrete IR function.
752 template <typename SignatureT>
753 1159 struct IRFunction : public IRFunctionBase
754 {
755 using Traits = FunctionTraits<SignatureT>;
756 using Ptr = std::shared_ptr<IRFunction>;
757
758 12816 IRFunction(const std::string& symbol, const GeneratorCb& gen)
759
153/306
✓ Branch 1 taken 2641 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2641 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1868 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1891 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 319 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 378 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 364 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 691 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 461 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 20 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 37 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 37 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 15 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 15 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 15 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 15 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 27 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 27 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 27 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 27 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 38 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 38 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 38 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 38 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 14 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 14 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 14 times.
✗ Branch 80 not taken.
✓ Branch 82 taken 14 times.
✗ Branch 83 not taken.
✓ Branch 85 taken 14 times.
✗ Branch 86 not taken.
✓ Branch 88 taken 14 times.
✗ Branch 89 not taken.
✓ Branch 91 taken 14 times.
✗ Branch 92 not taken.
✓ Branch 94 taken 14 times.
✗ Branch 95 not taken.
✓ Branch 97 taken 27 times.
✗ Branch 98 not taken.
✓ Branch 100 taken 27 times.
✗ Branch 101 not taken.
✓ Branch 103 taken 27 times.
✗ Branch 104 not taken.
✓ Branch 106 taken 27 times.
✗ Branch 107 not taken.
✓ Branch 109 taken 27 times.
✗ Branch 110 not taken.
✓ Branch 112 taken 27 times.
✗ Branch 113 not taken.
✓ Branch 115 taken 27 times.
✗ Branch 116 not taken.
✓ Branch 118 taken 27 times.
✗ Branch 119 not taken.
✓ Branch 121 taken 40 times.
✗ Branch 122 not taken.
✓ Branch 124 taken 40 times.
✗ Branch 125 not taken.
✓ Branch 127 taken 40 times.
✗ Branch 128 not taken.
✓ Branch 130 taken 40 times.
✗ Branch 131 not taken.
✓ Branch 133 taken 40 times.
✗ Branch 134 not taken.
✓ Branch 136 taken 40 times.
✗ Branch 137 not taken.
✓ Branch 139 taken 40 times.
✗ Branch 140 not taken.
✓ Branch 142 taken 40 times.
✗ Branch 143 not taken.
✓ Branch 145 taken 39 times.
✗ Branch 146 not taken.
✓ Branch 148 taken 39 times.
✗ Branch 149 not taken.
✓ Branch 151 taken 39 times.
✗ Branch 152 not taken.
✓ Branch 154 taken 39 times.
✗ Branch 155 not taken.
✓ Branch 157 taken 39 times.
✗ Branch 158 not taken.
✓ Branch 160 taken 39 times.
✗ Branch 161 not taken.
✓ Branch 163 taken 39 times.
✗ Branch 164 not taken.
✓ Branch 166 taken 39 times.
✗ Branch 167 not taken.
✓ Branch 169 taken 39 times.
✗ Branch 170 not taken.
✓ Branch 172 taken 39 times.
✗ Branch 173 not taken.
✓ Branch 175 taken 39 times.
✗ Branch 176 not taken.
✓ Branch 178 taken 39 times.
✗ Branch 179 not taken.
✓ Branch 181 taken 39 times.
✗ Branch 182 not taken.
✓ Branch 184 taken 39 times.
✗ Branch 185 not taken.
✓ Branch 187 taken 85 times.
✗ Branch 188 not taken.
✓ Branch 190 taken 85 times.
✗ Branch 191 not taken.
✓ Branch 193 taken 85 times.
✗ Branch 194 not taken.
✓ Branch 196 taken 85 times.
✗ Branch 197 not taken.
✓ Branch 199 taken 98 times.
✗ Branch 200 not taken.
✓ Branch 202 taken 98 times.
✗ Branch 203 not taken.
✓ Branch 205 taken 98 times.
✗ Branch 206 not taken.
✓ Branch 208 taken 98 times.
✗ Branch 209 not taken.
✓ Branch 211 taken 17 times.
✗ Branch 212 not taken.
✓ Branch 214 taken 17 times.
✗ Branch 215 not taken.
✓ Branch 217 taken 17 times.
✗ Branch 218 not taken.
✓ Branch 220 taken 17 times.
✗ Branch 221 not taken.
✓ Branch 223 taken 61 times.
✗ Branch 224 not taken.
✓ Branch 226 taken 61 times.
✗ Branch 227 not taken.
✓ Branch 229 taken 61 times.
✗ Branch 230 not taken.
✓ Branch 232 taken 61 times.
✗ Branch 233 not taken.
✓ Branch 235 taken 61 times.
✗ Branch 236 not taken.
✓ Branch 238 taken 61 times.
✗ Branch 239 not taken.
✓ Branch 241 taken 113 times.
✗ Branch 242 not taken.
✓ Branch 244 taken 113 times.
✗ Branch 245 not taken.
✓ Branch 247 taken 174 times.
✗ Branch 248 not taken.
✓ Branch 250 taken 174 times.
✗ Branch 251 not taken.
✓ Branch 253 taken 174 times.
✗ Branch 254 not taken.
✓ Branch 256 taken 174 times.
✗ Branch 257 not taken.
✓ Branch 259 taken 113 times.
✗ Branch 260 not taken.
✓ Branch 262 taken 113 times.
✗ Branch 263 not taken.
✓ Branch 265 taken 174 times.
✗ Branch 266 not taken.
✓ Branch 268 taken 174 times.
✗ Branch 269 not taken.
✓ Branch 271 taken 174 times.
✗ Branch 272 not taken.
✓ Branch 274 taken 174 times.
✗ Branch 275 not taken.
✓ Branch 277 taken 113 times.
✗ Branch 278 not taken.
✓ Branch 280 taken 113 times.
✗ Branch 281 not taken.
✓ Branch 283 taken 174 times.
✗ Branch 284 not taken.
✓ Branch 286 taken 174 times.
✗ Branch 287 not taken.
✓ Branch 289 taken 174 times.
✗ Branch 290 not taken.
✓ Branch 292 taken 174 times.
✗ Branch 293 not taken.
✓ Branch 295 taken 13 times.
✗ Branch 296 not taken.
✓ Branch 298 taken 13 times.
✗ Branch 299 not taken.
✓ Branch 301 taken 13 times.
✗ Branch 302 not taken.
✓ Branch 304 taken 13 times.
✗ Branch 305 not taken.
✓ Branch 307 taken 13 times.
✗ Branch 308 not taken.
✓ Branch 310 taken 13 times.
✗ Branch 311 not taken.
✓ Branch 313 taken 13 times.
✗ Branch 314 not taken.
✓ Branch 316 taken 13 times.
✗ Branch 317 not taken.
✓ Branch 319 taken 13 times.
✗ Branch 320 not taken.
✓ Branch 322 taken 13 times.
✗ Branch 323 not taken.
✓ Branch 325 taken 13 times.
✗ Branch 326 not taken.
✓ Branch 328 taken 13 times.
✗ Branch 329 not taken.
✓ Branch 331 taken 13 times.
✗ Branch 332 not taken.
✓ Branch 334 taken 1 times.
✗ Branch 335 not taken.
✓ Branch 337 taken 1 times.
✗ Branch 338 not taken.
✓ Branch 340 taken 1 times.
✗ Branch 341 not taken.
✓ Branch 343 taken 1 times.
✗ Branch 344 not taken.
✓ Branch 346 taken 14 times.
✗ Branch 347 not taken.
✓ Branch 349 taken 14 times.
✗ Branch 350 not taken.
✓ Branch 352 taken 14 times.
✗ Branch 353 not taken.
✓ Branch 355 taken 14 times.
✗ Branch 356 not taken.
✓ Branch 358 taken 43 times.
✗ Branch 359 not taken.
✓ Branch 361 taken 43 times.
✗ Branch 362 not taken.
✓ Branch 364 taken 947 times.
✗ Branch 365 not taken.
✓ Branch 367 taken 947 times.
✗ Branch 368 not taken.
✓ Branch 370 taken 947 times.
✗ Branch 371 not taken.
✓ Branch 373 taken 947 times.
✗ Branch 374 not taken.
✓ Branch 376 taken 49 times.
✗ Branch 377 not taken.
✓ Branch 379 taken 50 times.
✗ Branch 380 not taken.
✓ Branch 382 taken 39 times.
✗ Branch 383 not taken.
✓ Branch 385 taken 39 times.
✗ Branch 386 not taken.
✓ Branch 388 taken 389 times.
✗ Branch 389 not taken.
✓ Branch 391 taken 389 times.
✗ Branch 392 not taken.
✓ Branch 394 taken 389 times.
✗ Branch 395 not taken.
✓ Branch 397 taken 389 times.
✗ Branch 398 not taken.
✓ Branch 400 taken 402 times.
✗ Branch 401 not taken.
✓ Branch 403 taken 402 times.
✗ Branch 404 not taken.
✓ Branch 406 taken 402 times.
✗ Branch 407 not taken.
✓ Branch 409 taken 402 times.
✗ Branch 410 not taken.
✓ Branch 412 taken 26 times.
✗ Branch 413 not taken.
✓ Branch 415 taken 26 times.
✗ Branch 416 not taken.
✓ Branch 418 taken 13 times.
✗ Branch 419 not taken.
✓ Branch 421 taken 13 times.
✗ Branch 422 not taken.
✓ Branch 424 taken 13 times.
✗ Branch 425 not taken.
✓ Branch 427 taken 13 times.
✗ Branch 428 not taken.
✓ Branch 430 taken 13 times.
✗ Branch 431 not taken.
✓ Branch 433 taken 13 times.
✗ Branch 434 not taken.
✓ Branch 436 taken 13 times.
✗ Branch 437 not taken.
✓ Branch 439 taken 13 times.
✗ Branch 440 not taken.
✓ Branch 442 taken 13 times.
✗ Branch 443 not taken.
✓ Branch 445 taken 13 times.
✗ Branch 446 not taken.
✓ Branch 448 taken 13 times.
✗ Branch 449 not taken.
✓ Branch 451 taken 13 times.
✗ Branch 452 not taken.
✓ Branch 454 taken 13 times.
✗ Branch 455 not taken.
✓ Branch 457 taken 13 times.
✗ Branch 458 not taken.
12816 : IRFunctionBase(symbol, gen, Traits::N_ARGS) {}
760
761 inline llvm::Type*
762 158484 types(std::vector<llvm::Type*>& types, llvm::LLVMContext& C) const override
763 {
764
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
158485 return llvmTypesFromSignature<SignatureT>(C, &types);
765 }
766 };
767
768 /// @brief Represents a concrete C function binding with the first argument as
769 /// its return type.
770 template <typename SignatureT>
771 struct CFunctionSRet : public SRetFunction<SignatureT, CFunction<SignatureT>>
772 {
773 using BaseT = SRetFunction<SignatureT, CFunction<SignatureT>>;
774 CFunctionSRet(const std::string& symbol, const SignatureT function)
775
45/90
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 142 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 193 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 72 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 13 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 13 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 13 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 13 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 13 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 13 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 13 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 13 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 13 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 13 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 13 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 13 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 37 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 37 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 37 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 37 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 13 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 13 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 13 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 13 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 13 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 13 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 13 times.
✗ Branch 80 not taken.
✓ Branch 82 taken 13 times.
✗ Branch 83 not taken.
✓ Branch 85 taken 17 times.
✗ Branch 86 not taken.
✓ Branch 88 taken 17 times.
✗ Branch 89 not taken.
✓ Branch 91 taken 13 times.
✗ Branch 92 not taken.
✓ Branch 94 taken 13 times.
✗ Branch 95 not taken.
✓ Branch 97 taken 13 times.
✗ Branch 98 not taken.
✓ Branch 100 taken 30 times.
✗ Branch 101 not taken.
✓ Branch 103 taken 30 times.
✗ Branch 104 not taken.
✓ Branch 106 taken 30 times.
✗ Branch 107 not taken.
✓ Branch 109 taken 30 times.
✗ Branch 110 not taken.
✓ Branch 112 taken 26 times.
✗ Branch 113 not taken.
✓ Branch 115 taken 13 times.
✗ Branch 116 not taken.
✓ Branch 118 taken 13 times.
✗ Branch 119 not taken.
✓ Branch 121 taken 26 times.
✗ Branch 122 not taken.
✓ Branch 124 taken 13 times.
✗ Branch 125 not taken.
✓ Branch 127 taken 13 times.
✗ Branch 128 not taken.
✓ Branch 130 taken 13 times.
✗ Branch 131 not taken.
✓ Branch 133 taken 13 times.
✗ Branch 134 not taken.
1198 : BaseT(symbol, function) {}
776 2396 ~CFunctionSRet() override = default;
777 };
778
779 /// @brief Represents a concrete IR function with the first argument as
780 /// its return type.
781 template <typename SignatureT>
782 struct IRFunctionSRet : public SRetFunction<SignatureT, IRFunction<SignatureT>>
783 {
784 using BaseT = SRetFunction<SignatureT, IRFunction<SignatureT>>;
785 IRFunctionSRet(const std::string& symbol,
786 const IRFunctionBase::GeneratorCb& gen)
787
39/78
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 141 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 186 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 72 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 13 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 13 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 13 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 13 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 13 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 13 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 13 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 13 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 13 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 13 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 13 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 13 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 37 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 37 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 37 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 37 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 13 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 13 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 13 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 13 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 13 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 13 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 13 times.
✗ Branch 80 not taken.
✓ Branch 82 taken 13 times.
✗ Branch 83 not taken.
✓ Branch 85 taken 17 times.
✗ Branch 86 not taken.
✓ Branch 88 taken 17 times.
✗ Branch 89 not taken.
✓ Branch 91 taken 17 times.
✗ Branch 92 not taken.
✓ Branch 94 taken 17 times.
✗ Branch 95 not taken.
✓ Branch 97 taken 13 times.
✗ Branch 98 not taken.
✓ Branch 100 taken 13 times.
✗ Branch 101 not taken.
✓ Branch 103 taken 13 times.
✗ Branch 104 not taken.
✓ Branch 106 taken 43 times.
✗ Branch 107 not taken.
✓ Branch 109 taken 43 times.
✗ Branch 110 not taken.
✓ Branch 112 taken 49 times.
✗ Branch 113 not taken.
✓ Branch 115 taken 50 times.
✗ Branch 116 not taken.
1159 : BaseT(symbol, gen) {}
788 2318 ~IRFunctionSRet() override = default;
789 };
790
791 /// @brief todo
792 struct OPENVDB_AX_API FunctionGroup
793 {
794 using Ptr = std::shared_ptr<FunctionGroup>;
795 using UniquePtr = std::unique_ptr<FunctionGroup>;
796 using FunctionList = std::vector<Function::Ptr>;
797
798 FunctionGroup(const char* name,
799 const char* doc,
800 const FunctionList& list)
801 11443 : mName(name)
802 , mDoc(doc)
803
5/10
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
11443 , mFunctionList(list) {}
804 11443 ~FunctionGroup() = default;
805
806 /// @brief Given a vector of llvm types, automatically returns the best
807 /// possible function declaration from the stored function list. The
808 /// 'best' declaration is determined by the provided types
809 /// compatibility to each functions signature.
810 /// @note If multiple implicit matches are found, the first match is
811 /// returned.
812 /// @note Returns a nullptr if no compatible match was found or if the
813 /// function list is empty. A compatible match is defined as an
814 /// Explicit or Implicit match.
815 ///
816 /// @param types A vector of types representing the function argument types
817 /// @param C The llvm context
818 /// @param type If provided, type is set to the type of match that occurred
819 const Function*
820 match(const std::vector<llvm::Type*>& types,
821 llvm::LLVMContext& C,
822 Function::SignatureMatch* type = nullptr) const;
823
824 /// @brief Given a vector of llvm values, find the best possible function
825 /// signature, generate and execute the function body. Returns the
826 /// return value of the function (nullptr if void). The behaviour
827 /// is undefined if a valid match does not exist. For such cases,
828 /// call the second version of FunctionGroup::execute.
829 /// @note This function will throw if no valid return is provided by the
830 /// matched declaration implementation.
831 ///
832 /// @param args A vector of values representing the function arguments
833 /// @param B The current llvm IRBuilder
834 llvm::Value*
835 execute(const std::vector<llvm::Value*>& args,
836 llvm::IRBuilder<>& B) const;
837
838 /// @brief Given a vector of llvm values, find the best possible function
839 /// signature, generate and execute the function body. Returns the
840 /// Function that was selected and executed or a nullptr if no
841 /// valid match was found. Sets the result variable to the return
842 /// value of the function (nullptr if void). If no match is found,
843 /// the result variable if left unset.
844 /// @note This function will throw if no valid return is provided by the
845 /// matched declaration implementation.
846 ///
847 /// @param args A vector of values representing the function arguments
848 /// @param B The current llvm IRBuilder
849 /// @param result The result to set. nullptr on void return.
850 /// @return The matched function. nullptr if no match was found
851 const Function*
852 execute(const std::vector<llvm::Value*>& args,
853 llvm::IRBuilder<>& B,
854 llvm::Value*& result) const;
855
856 /// @brief Accessor to the underlying function signature list
857 inline const FunctionList& list() const { return mFunctionList; }
858
2/6
✓ Branch 1 taken 107 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 106 times.
213 const char* name() const { return mName; }
859
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 const char* doc() const { return mDoc; }
860
861 private:
862 const char* mName;
863 const char* mDoc;
864 const FunctionList mFunctionList;
865 };
866
867 /// @brief The FunctionBuilder class provides a builder pattern framework to
868 /// allow easy and valid construction of AX functions. There are a
869 /// number of complex tasks which may need to be performed during
870 /// construction of C or IR function which are delegated to this
871 /// builder, whilst ensuring that the constructed functions are
872 /// guaranteed to be valid.
873 /// @details Use the FunctionBuilder::addSignature methods to append function
874 /// signatures. Finalize the group of functions with
875 /// FunctionBuilder::get.
876 struct FunctionBuilder
877 {
878 enum DeclPreferrence {
879 C, IR, Any
880 };
881
882
13/440
✓ Branch 1 taken 728 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✓ Branch 61 taken 724 times.
✗ Branch 62 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✓ Branch 73 taken 11436 times.
✗ Branch 74 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 79 not taken.
✗ Branch 80 not taken.
✗ Branch 82 not taken.
✗ Branch 83 not taken.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
✗ Branch 88 not taken.
✗ Branch 89 not taken.
✗ Branch 91 not taken.
✗ Branch 92 not taken.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✗ Branch 97 not taken.
✗ Branch 98 not taken.
✓ Branch 100 taken 724 times.
✗ Branch 101 not taken.
✗ Branch 103 not taken.
✗ Branch 104 not taken.
✗ Branch 106 not taken.
✗ Branch 107 not taken.
✗ Branch 109 not taken.
✗ Branch 110 not taken.
✗ Branch 112 not taken.
✗ Branch 113 not taken.
✗ Branch 115 not taken.
✗ Branch 116 not taken.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✗ Branch 121 not taken.
✗ Branch 122 not taken.
✗ Branch 124 not taken.
✗ Branch 125 not taken.
✗ Branch 127 not taken.
✗ Branch 128 not taken.
✗ Branch 130 not taken.
✗ Branch 131 not taken.
✗ Branch 133 not taken.
✗ Branch 134 not taken.
✗ Branch 136 not taken.
✗ Branch 137 not taken.
✓ Branch 139 taken 721 times.
✗ Branch 140 not taken.
✗ Branch 142 not taken.
✗ Branch 143 not taken.
✗ Branch 145 not taken.
✗ Branch 146 not taken.
✗ Branch 148 not taken.
✗ Branch 149 not taken.
✗ Branch 151 not taken.
✗ Branch 152 not taken.
✓ Branch 154 taken 13 times.
✗ Branch 155 not taken.
✗ Branch 157 not taken.
✗ Branch 158 not taken.
✗ Branch 160 not taken.
✗ Branch 161 not taken.
✗ Branch 163 not taken.
✗ Branch 164 not taken.
✗ Branch 166 not taken.
✗ Branch 167 not taken.
✗ Branch 169 not taken.
✗ Branch 170 not taken.
✗ Branch 172 not taken.
✗ Branch 173 not taken.
✗ Branch 175 not taken.
✗ Branch 176 not taken.
✗ Branch 178 not taken.
✗ Branch 179 not taken.
✗ Branch 181 not taken.
✗ Branch 182 not taken.
✗ Branch 184 not taken.
✗ Branch 185 not taken.
✗ Branch 187 not taken.
✗ Branch 188 not taken.
✗ Branch 190 not taken.
✗ Branch 191 not taken.
✗ Branch 193 not taken.
✗ Branch 194 not taken.
✗ Branch 196 not taken.
✗ Branch 197 not taken.
✗ Branch 199 not taken.
✗ Branch 200 not taken.
✗ Branch 202 not taken.
✗ Branch 203 not taken.
✗ Branch 205 not taken.
✗ Branch 206 not taken.
✗ Branch 208 not taken.
✗ Branch 209 not taken.
✗ Branch 211 not taken.
✗ Branch 212 not taken.
✗ Branch 214 not taken.
✗ Branch 215 not taken.
✗ Branch 217 not taken.
✗ Branch 218 not taken.
✗ Branch 220 not taken.
✗ Branch 221 not taken.
✗ Branch 223 not taken.
✗ Branch 224 not taken.
✗ Branch 226 not taken.
✗ Branch 227 not taken.
✗ Branch 229 not taken.
✗ Branch 230 not taken.
✗ Branch 232 not taken.
✗ Branch 233 not taken.
✗ Branch 235 not taken.
✗ Branch 236 not taken.
✗ Branch 238 not taken.
✗ Branch 239 not taken.
✓ Branch 241 taken 719 times.
✗ Branch 242 not taken.
✗ Branch 244 not taken.
✗ Branch 245 not taken.
✗ Branch 247 not taken.
✗ Branch 248 not taken.
✗ Branch 250 not taken.
✗ Branch 251 not taken.
✗ Branch 253 not taken.
✗ Branch 254 not taken.
✗ Branch 256 not taken.
✗ Branch 257 not taken.
✗ Branch 259 not taken.
✗ Branch 260 not taken.
✗ Branch 262 not taken.
✗ Branch 263 not taken.
✗ Branch 265 not taken.
✗ Branch 266 not taken.
✗ Branch 268 not taken.
✗ Branch 269 not taken.
✗ Branch 271 not taken.
✗ Branch 272 not taken.
✗ Branch 274 not taken.
✗ Branch 275 not taken.
✗ Branch 277 not taken.
✗ Branch 278 not taken.
✗ Branch 280 not taken.
✗ Branch 281 not taken.
✗ Branch 283 not taken.
✗ Branch 284 not taken.
✗ Branch 286 not taken.
✗ Branch 287 not taken.
✗ Branch 289 not taken.
✗ Branch 290 not taken.
✗ Branch 292 not taken.
✗ Branch 293 not taken.
✗ Branch 295 not taken.
✗ Branch 296 not taken.
✗ Branch 298 not taken.
✗ Branch 299 not taken.
✗ Branch 301 not taken.
✗ Branch 302 not taken.
✗ Branch 304 not taken.
✗ Branch 305 not taken.
✗ Branch 307 not taken.
✗ Branch 308 not taken.
✗ Branch 310 not taken.
✗ Branch 311 not taken.
✗ Branch 313 not taken.
✗ Branch 314 not taken.
✗ Branch 316 not taken.
✗ Branch 317 not taken.
✗ Branch 319 not taken.
✗ Branch 320 not taken.
✗ Branch 322 not taken.
✗ Branch 323 not taken.
✗ Branch 325 not taken.
✗ Branch 326 not taken.
✗ Branch 328 not taken.
✗ Branch 329 not taken.
✗ Branch 331 not taken.
✗ Branch 332 not taken.
✗ Branch 334 not taken.
✗ Branch 335 not taken.
✗ Branch 337 not taken.
✗ Branch 338 not taken.
✗ Branch 340 not taken.
✗ Branch 341 not taken.
✗ Branch 343 not taken.
✗ Branch 344 not taken.
✗ Branch 346 not taken.
✗ Branch 347 not taken.
✗ Branch 349 not taken.
✗ Branch 350 not taken.
✗ Branch 352 not taken.
✗ Branch 353 not taken.
✗ Branch 355 not taken.
✗ Branch 356 not taken.
✗ Branch 358 not taken.
✗ Branch 359 not taken.
✗ Branch 361 not taken.
✗ Branch 362 not taken.
✗ Branch 364 not taken.
✗ Branch 365 not taken.
✗ Branch 367 not taken.
✗ Branch 368 not taken.
✗ Branch 370 not taken.
✗ Branch 371 not taken.
✗ Branch 373 not taken.
✗ Branch 374 not taken.
✗ Branch 376 not taken.
✗ Branch 377 not taken.
✗ Branch 379 not taken.
✗ Branch 380 not taken.
✗ Branch 382 not taken.
✗ Branch 383 not taken.
✗ Branch 385 not taken.
✗ Branch 386 not taken.
✗ Branch 388 not taken.
✗ Branch 389 not taken.
✗ Branch 391 not taken.
✗ Branch 392 not taken.
✗ Branch 394 not taken.
✗ Branch 395 not taken.
✗ Branch 397 not taken.
✗ Branch 398 not taken.
✗ Branch 400 not taken.
✗ Branch 401 not taken.
✗ Branch 403 not taken.
✗ Branch 404 not taken.
✗ Branch 406 not taken.
✗ Branch 407 not taken.
✗ Branch 409 not taken.
✗ Branch 410 not taken.
✗ Branch 412 not taken.
✗ Branch 413 not taken.
✗ Branch 415 not taken.
✗ Branch 416 not taken.
✗ Branch 418 not taken.
✗ Branch 419 not taken.
✗ Branch 421 not taken.
✗ Branch 422 not taken.
✗ Branch 424 not taken.
✗ Branch 425 not taken.
✗ Branch 427 not taken.
✗ Branch 428 not taken.
✗ Branch 430 not taken.
✗ Branch 431 not taken.
✗ Branch 433 not taken.
✗ Branch 434 not taken.
✗ Branch 436 not taken.
✗ Branch 437 not taken.
✗ Branch 439 not taken.
✗ Branch 440 not taken.
✗ Branch 442 not taken.
✗ Branch 443 not taken.
✗ Branch 445 not taken.
✗ Branch 446 not taken.
✗ Branch 448 not taken.
✗ Branch 449 not taken.
✗ Branch 451 not taken.
✗ Branch 452 not taken.
✗ Branch 454 not taken.
✗ Branch 455 not taken.
✗ Branch 457 not taken.
✗ Branch 458 not taken.
✗ Branch 460 not taken.
✗ Branch 461 not taken.
✗ Branch 463 not taken.
✗ Branch 464 not taken.
✗ Branch 466 not taken.
✗ Branch 467 not taken.
✗ Branch 469 not taken.
✗ Branch 470 not taken.
✗ Branch 472 not taken.
✗ Branch 473 not taken.
✗ Branch 475 not taken.
✗ Branch 476 not taken.
✗ Branch 478 not taken.
✗ Branch 479 not taken.
✗ Branch 481 not taken.
✗ Branch 482 not taken.
✗ Branch 484 not taken.
✗ Branch 485 not taken.
✗ Branch 487 not taken.
✗ Branch 488 not taken.
✗ Branch 490 not taken.
✗ Branch 491 not taken.
✗ Branch 493 not taken.
✗ Branch 494 not taken.
✗ Branch 496 not taken.
✗ Branch 497 not taken.
✗ Branch 499 not taken.
✗ Branch 500 not taken.
✗ Branch 502 not taken.
✗ Branch 503 not taken.
✗ Branch 505 not taken.
✗ Branch 506 not taken.
✗ Branch 508 not taken.
✗ Branch 509 not taken.
✗ Branch 511 not taken.
✗ Branch 512 not taken.
✗ Branch 514 not taken.
✗ Branch 515 not taken.
✗ Branch 517 not taken.
✗ Branch 518 not taken.
✗ Branch 520 not taken.
✗ Branch 521 not taken.
✗ Branch 523 not taken.
✗ Branch 524 not taken.
✗ Branch 526 not taken.
✗ Branch 527 not taken.
✗ Branch 529 not taken.
✗ Branch 530 not taken.
✗ Branch 532 not taken.
✗ Branch 533 not taken.
✓ Branch 535 taken 3 times.
✗ Branch 536 not taken.
✗ Branch 538 not taken.
✗ Branch 539 not taken.
✗ Branch 541 not taken.
✗ Branch 542 not taken.
✗ Branch 544 not taken.
✗ Branch 545 not taken.
✗ Branch 547 not taken.
✗ Branch 548 not taken.
✗ Branch 550 not taken.
✗ Branch 551 not taken.
✗ Branch 553 not taken.
✗ Branch 554 not taken.
✗ Branch 556 not taken.
✗ Branch 557 not taken.
✗ Branch 559 not taken.
✗ Branch 560 not taken.
✗ Branch 562 not taken.
✗ Branch 563 not taken.
✗ Branch 565 not taken.
✗ Branch 566 not taken.
✓ Branch 568 taken 13 times.
✗ Branch 569 not taken.
✗ Branch 571 not taken.
✗ Branch 572 not taken.
✓ Branch 574 taken 13 times.
✗ Branch 575 not taken.
✓ Branch 577 taken 13 times.
✗ Branch 578 not taken.
✓ Branch 580 taken 13 times.
✗ Branch 581 not taken.
✗ Branch 583 not taken.
✗ Branch 584 not taken.
✗ Branch 586 not taken.
✗ Branch 587 not taken.
✗ Branch 589 not taken.
✗ Branch 590 not taken.
✗ Branch 592 not taken.
✗ Branch 593 not taken.
✓ Branch 595 taken 39 times.
✗ Branch 596 not taken.
✗ Branch 598 not taken.
✗ Branch 599 not taken.
✗ Branch 601 not taken.
✗ Branch 602 not taken.
✗ Branch 604 not taken.
✗ Branch 605 not taken.
✗ Branch 607 not taken.
✗ Branch 608 not taken.
✗ Branch 610 not taken.
✗ Branch 611 not taken.
✗ Branch 613 not taken.
✗ Branch 614 not taken.
✗ Branch 616 not taken.
✗ Branch 617 not taken.
✗ Branch 619 not taken.
✗ Branch 620 not taken.
✗ Branch 622 not taken.
✗ Branch 623 not taken.
✗ Branch 625 not taken.
✗ Branch 626 not taken.
✗ Branch 628 not taken.
✗ Branch 629 not taken.
✗ Branch 631 not taken.
✗ Branch 632 not taken.
✗ Branch 634 not taken.
✗ Branch 635 not taken.
✗ Branch 637 not taken.
✗ Branch 638 not taken.
✗ Branch 640 not taken.
✗ Branch 641 not taken.
✗ Branch 643 not taken.
✗ Branch 644 not taken.
✗ Branch 646 not taken.
✗ Branch 647 not taken.
✗ Branch 649 not taken.
✗ Branch 650 not taken.
✗ Branch 652 not taken.
✗ Branch 653 not taken.
✗ Branch 655 not taken.
✗ Branch 656 not taken.
✗ Branch 658 not taken.
✗ Branch 659 not taken.
15159 struct Settings
883 {
884 using Ptr = std::shared_ptr<Settings>;
885
886
2/2
✓ Branch 0 taken 108136 times.
✓ Branch 1 taken 68 times.
108204 inline bool isDefault() const {
887
2/2
✓ Branch 0 taken 108136 times.
✓ Branch 1 taken 68 times.
108204 if (mNames) return false;
888
1/2
✓ Branch 0 taken 108136 times.
✗ Branch 1 not taken.
108136 if (!mDeps.empty()) return false;
889
2/4
✓ Branch 0 taken 108136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 108136 times.
✗ Branch 3 not taken.
108136 if (mConstantFold || mEmbedIR) return false;
890
2/2
✓ Branch 0 taken 104520 times.
✓ Branch 1 taken 3616 times.
108136 if (!mFnAttrs.empty()) return false;
891
1/2
✓ Branch 0 taken 104520 times.
✗ Branch 1 not taken.
104520 if (!mRetAttrs.empty()) return false;
892
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 104481 times.
104520 if (!mParamAttrs.empty()) return false;
893 return true;
894 }
895
896 std::shared_ptr<std::vector<const char*>> mNames = nullptr;
897 std::vector<const char*> mDeps = {};
898 bool mConstantFold = false;
899 bool mEmbedIR = false;
900 std::vector<llvm::Attribute::AttrKind> mFnAttrs = {};
901 std::vector<llvm::Attribute::AttrKind> mRetAttrs = {};
902 std::map<size_t, std::vector<llvm::Attribute::AttrKind>> mParamAttrs = {};
903 };
904
905 11436 FunctionBuilder(const char* name)
906 11436 : mName(name)
907
1/2
✓ Branch 1 taken 11436 times.
✗ Branch 2 not taken.
22872 , mCurrentSettings(new Settings()) {}
908
909
910 template <typename Signature, bool SRet = false>
911 inline FunctionBuilder&
912 25628 addSignature(const IRFunctionBase::GeneratorCb& cb,
913 const char* symbol = nullptr)
914 {
915 using IRFType = typename std::conditional
916 <!SRet, IRFunction<Signature>, IRFunctionSRet<Signature>>::type;
917 using IRPtr = typename IRFType::Ptr;
918
919 Settings::Ptr settings = mCurrentSettings;
920
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 12762 times.
25628 if (!mCurrentSettings->isDefault()) {
921
2/4
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 52 times.
✗ Branch 5 not taken.
104 settings.reset(new Settings());
922 }
923
924 std::string s;
925
3/4
✓ Branch 0 taken 3772 times.
✓ Branch 1 taken 9042 times.
✓ Branch 3 taken 3772 times.
✗ Branch 4 not taken.
33172 if (symbol) s = std::string(symbol);
926
1/2
✓ Branch 1 taken 9042 times.
✗ Branch 2 not taken.
36168 else s = this->genSymbol<Signature>();
927
928
1/2
✓ Branch 1 taken 12814 times.
✗ Branch 2 not taken.
25628 auto ir = IRPtr(new IRFType(s, cb));
929
1/2
✓ Branch 1 taken 12814 times.
✗ Branch 2 not taken.
25628 mIRFunctions.emplace_back(ir);
930
1/4
✓ Branch 1 taken 12814 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
51256 mSettings[ir.get()] = settings;
931 mCurrentSettings = settings;
932 25628 return *this;
933 }
934
935 template <typename Signature, bool SRet = false>
936 inline FunctionBuilder&
937 190780 addSignature(const Signature* ptr,
938 const char* symbol = nullptr)
939 {
940 using CFType = typename std::conditional
941 <!SRet, CFunction<Signature>, CFunctionSRet<Signature>>::type;
942 using CPtr = typename CFType::Ptr;
943
944 Settings::Ptr settings = mCurrentSettings;
945
2/2
✓ Branch 0 taken 3671 times.
✓ Branch 1 taken 91719 times.
190780 if (!mCurrentSettings->isDefault()) {
946
2/4
✓ Branch 1 taken 3671 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3671 times.
✗ Branch 5 not taken.
7342 settings.reset(new Settings());
947 }
948
949 std::string s;
950
3/4
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 95114 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
191332 if (symbol) s = std::string(symbol);
951
1/2
✓ Branch 1 taken 95114 times.
✗ Branch 2 not taken.
380456 else s = this->genSymbol<Signature>();
952
953
1/2
✓ Branch 1 taken 95390 times.
✗ Branch 2 not taken.
190780 auto c = CPtr(new CFType(s, ptr));
954
1/2
✓ Branch 1 taken 95390 times.
✗ Branch 2 not taken.
190780 mCFunctions.emplace_back(c);
955
1/4
✓ Branch 1 taken 95390 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
381560 mSettings[c.get()] = settings;
956 mCurrentSettings = settings;
957 190780 return *this;
958 }
959
960 template <typename Signature, bool SRet = false>
961 inline FunctionBuilder&
962 addSignature(const IRFunctionBase::GeneratorCb& cb, const Signature* ptr, const char* symbol = nullptr)
963 {
964
165/330
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 53 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 70 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 127 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 147 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 474 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 13 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 13 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 13 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 13 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 13 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 13 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 13 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 13 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 13 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 13 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 13 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 13 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 13 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 13 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 13 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 13 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 13 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 13 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 13 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 13 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 13 times.
✗ Branch 80 not taken.
✓ Branch 82 taken 13 times.
✗ Branch 83 not taken.
✓ Branch 85 taken 13 times.
✗ Branch 86 not taken.
✓ Branch 88 taken 13 times.
✗ Branch 89 not taken.
✓ Branch 91 taken 37 times.
✗ Branch 92 not taken.
✓ Branch 94 taken 37 times.
✗ Branch 95 not taken.
✓ Branch 97 taken 37 times.
✗ Branch 98 not taken.
✓ Branch 100 taken 37 times.
✗ Branch 101 not taken.
✓ Branch 103 taken 13 times.
✗ Branch 104 not taken.
✓ Branch 106 taken 13 times.
✗ Branch 107 not taken.
✓ Branch 109 taken 13 times.
✗ Branch 110 not taken.
✓ Branch 112 taken 13 times.
✗ Branch 113 not taken.
✓ Branch 115 taken 13 times.
✗ Branch 116 not taken.
✓ Branch 118 taken 13 times.
✗ Branch 119 not taken.
✓ Branch 121 taken 13 times.
✗ Branch 122 not taken.
✓ Branch 124 taken 13 times.
✗ Branch 125 not taken.
✓ Branch 127 taken 13 times.
✗ Branch 128 not taken.
✓ Branch 130 taken 13 times.
✗ Branch 131 not taken.
✓ Branch 133 taken 13 times.
✗ Branch 134 not taken.
✓ Branch 136 taken 13 times.
✗ Branch 137 not taken.
✓ Branch 139 taken 13 times.
✗ Branch 140 not taken.
✓ Branch 142 taken 13 times.
✗ Branch 143 not taken.
✓ Branch 145 taken 13 times.
✗ Branch 146 not taken.
✓ Branch 148 taken 13 times.
✗ Branch 149 not taken.
✓ Branch 151 taken 13 times.
✗ Branch 152 not taken.
✓ Branch 154 taken 13 times.
✗ Branch 155 not taken.
✓ Branch 157 taken 13 times.
✗ Branch 158 not taken.
✓ Branch 160 taken 13 times.
✗ Branch 161 not taken.
✓ Branch 163 taken 13 times.
✗ Branch 164 not taken.
✓ Branch 166 taken 13 times.
✗ Branch 167 not taken.
✓ Branch 169 taken 13 times.
✗ Branch 170 not taken.
✓ Branch 172 taken 13 times.
✗ Branch 173 not taken.
✓ Branch 175 taken 13 times.
✗ Branch 176 not taken.
✓ Branch 178 taken 13 times.
✗ Branch 179 not taken.
✓ Branch 181 taken 13 times.
✗ Branch 182 not taken.
✓ Branch 184 taken 13 times.
✗ Branch 185 not taken.
✓ Branch 187 taken 13 times.
✗ Branch 188 not taken.
✓ Branch 190 taken 13 times.
✗ Branch 191 not taken.
✓ Branch 193 taken 13 times.
✗ Branch 194 not taken.
✓ Branch 196 taken 13 times.
✗ Branch 197 not taken.
✓ Branch 199 taken 13 times.
✗ Branch 200 not taken.
✓ Branch 202 taken 13 times.
✗ Branch 203 not taken.
✓ Branch 205 taken 13 times.
✗ Branch 206 not taken.
✓ Branch 208 taken 13 times.
✗ Branch 209 not taken.
✓ Branch 211 taken 13 times.
✗ Branch 212 not taken.
✓ Branch 214 taken 13 times.
✗ Branch 215 not taken.
✓ Branch 217 taken 13 times.
✗ Branch 218 not taken.
✓ Branch 220 taken 13 times.
✗ Branch 221 not taken.
✓ Branch 223 taken 13 times.
✗ Branch 224 not taken.
✓ Branch 226 taken 13 times.
✗ Branch 227 not taken.
✓ Branch 229 taken 13 times.
✗ Branch 230 not taken.
✓ Branch 232 taken 13 times.
✗ Branch 233 not taken.
✓ Branch 235 taken 13 times.
✗ Branch 236 not taken.
✓ Branch 238 taken 13 times.
✗ Branch 239 not taken.
✓ Branch 241 taken 13 times.
✗ Branch 242 not taken.
✓ Branch 244 taken 13 times.
✗ Branch 245 not taken.
✓ Branch 247 taken 13 times.
✗ Branch 248 not taken.
✓ Branch 250 taken 13 times.
✗ Branch 251 not taken.
✓ Branch 253 taken 153 times.
✗ Branch 254 not taken.
✓ Branch 256 taken 153 times.
✗ Branch 257 not taken.
✓ Branch 259 taken 153 times.
✗ Branch 260 not taken.
✓ Branch 262 taken 153 times.
✗ Branch 263 not taken.
✓ Branch 265 taken 85 times.
✗ Branch 266 not taken.
✓ Branch 268 taken 85 times.
✗ Branch 269 not taken.
✓ Branch 271 taken 85 times.
✗ Branch 272 not taken.
✓ Branch 274 taken 85 times.
✗ Branch 275 not taken.
✓ Branch 277 taken 105 times.
✗ Branch 278 not taken.
✓ Branch 280 taken 105 times.
✗ Branch 281 not taken.
✓ Branch 283 taken 105 times.
✗ Branch 284 not taken.
✓ Branch 286 taken 105 times.
✗ Branch 287 not taken.
✓ Branch 289 taken 105 times.
✗ Branch 290 not taken.
✓ Branch 292 taken 105 times.
✗ Branch 293 not taken.
✓ Branch 295 taken 105 times.
✗ Branch 296 not taken.
✓ Branch 298 taken 105 times.
✗ Branch 299 not taken.
✓ Branch 301 taken 13 times.
✗ Branch 302 not taken.
✓ Branch 304 taken 13 times.
✗ Branch 305 not taken.
✓ Branch 307 taken 17 times.
✗ Branch 308 not taken.
✓ Branch 310 taken 17 times.
✗ Branch 311 not taken.
✓ Branch 313 taken 17 times.
✗ Branch 314 not taken.
✓ Branch 316 taken 17 times.
✗ Branch 317 not taken.
✓ Branch 319 taken 17 times.
✗ Branch 320 not taken.
✓ Branch 322 taken 17 times.
✗ Branch 323 not taken.
✓ Branch 325 taken 61 times.
✗ Branch 326 not taken.
✓ Branch 328 taken 61 times.
✗ Branch 329 not taken.
✓ Branch 331 taken 61 times.
✗ Branch 332 not taken.
✓ Branch 334 taken 61 times.
✗ Branch 335 not taken.
✓ Branch 337 taken 61 times.
✗ Branch 338 not taken.
✓ Branch 340 taken 61 times.
✗ Branch 341 not taken.
✓ Branch 343 taken 61 times.
✗ Branch 344 not taken.
✓ Branch 346 taken 61 times.
✗ Branch 347 not taken.
✓ Branch 349 taken 61 times.
✗ Branch 350 not taken.
✓ Branch 352 taken 113 times.
✗ Branch 353 not taken.
✓ Branch 355 taken 113 times.
✗ Branch 356 not taken.
✓ Branch 358 taken 113 times.
✗ Branch 359 not taken.
✓ Branch 361 taken 113 times.
✗ Branch 362 not taken.
✓ Branch 364 taken 113 times.
✗ Branch 365 not taken.
✓ Branch 367 taken 113 times.
✗ Branch 368 not taken.
✓ Branch 370 taken 113 times.
✗ Branch 371 not taken.
✓ Branch 373 taken 113 times.
✗ Branch 374 not taken.
✓ Branch 376 taken 113 times.
✗ Branch 377 not taken.
✓ Branch 379 taken 13 times.
✗ Branch 380 not taken.
✓ Branch 382 taken 13 times.
✗ Branch 383 not taken.
✓ Branch 385 taken 13 times.
✗ Branch 386 not taken.
✓ Branch 388 taken 13 times.
✗ Branch 389 not taken.
✓ Branch 391 taken 13 times.
✗ Branch 392 not taken.
✓ Branch 394 taken 13 times.
✗ Branch 395 not taken.
✓ Branch 397 taken 13 times.
✗ Branch 398 not taken.
✓ Branch 400 taken 13 times.
✗ Branch 401 not taken.
✓ Branch 403 taken 13 times.
✗ Branch 404 not taken.
✓ Branch 406 taken 13 times.
✗ Branch 407 not taken.
✓ Branch 409 taken 13 times.
✗ Branch 410 not taken.
✓ Branch 412 taken 13 times.
✗ Branch 413 not taken.
✓ Branch 415 taken 13 times.
✗ Branch 416 not taken.
✓ Branch 418 taken 13 times.
✗ Branch 419 not taken.
✓ Branch 421 taken 13 times.
✗ Branch 422 not taken.
✓ Branch 424 taken 13 times.
✗ Branch 425 not taken.
✓ Branch 427 taken 13 times.
✗ Branch 428 not taken.
✓ Branch 430 taken 13 times.
✗ Branch 431 not taken.
✓ Branch 433 taken 13 times.
✗ Branch 434 not taken.
✓ Branch 436 taken 13 times.
✗ Branch 437 not taken.
✓ Branch 439 taken 13 times.
✗ Branch 440 not taken.
✓ Branch 442 taken 49 times.
✗ Branch 443 not taken.
✓ Branch 445 taken 49 times.
✗ Branch 446 not taken.
✓ Branch 448 taken 617 times.
✗ Branch 449 not taken.
✓ Branch 451 taken 617 times.
✗ Branch 452 not taken.
✓ Branch 454 taken 13 times.
✗ Branch 455 not taken.
✓ Branch 457 taken 13 times.
✗ Branch 458 not taken.
✓ Branch 460 taken 13 times.
✗ Branch 461 not taken.
✓ Branch 463 taken 13 times.
✗ Branch 464 not taken.
✓ Branch 466 taken 13 times.
✗ Branch 467 not taken.
✓ Branch 469 taken 13 times.
✗ Branch 470 not taken.
✓ Branch 472 taken 13 times.
✗ Branch 473 not taken.
✓ Branch 475 taken 13 times.
✗ Branch 476 not taken.
✓ Branch 478 taken 13 times.
✗ Branch 479 not taken.
✓ Branch 481 taken 13 times.
✗ Branch 482 not taken.
✓ Branch 484 taken 125 times.
✗ Branch 485 not taken.
✓ Branch 487 taken 125 times.
✗ Branch 488 not taken.
✓ Branch 490 taken 1 times.
✗ Branch 491 not taken.
✓ Branch 493 taken 1 times.
✗ Branch 494 not taken.
7601 this->addSignature<Signature, SRet>(cb, symbol);
965
165/330
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 53 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 70 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 127 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 147 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 474 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 13 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 13 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 13 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 13 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 13 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 13 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 13 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 13 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 13 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 13 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 13 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 13 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 13 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 13 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 13 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 13 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 13 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 13 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 13 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 13 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 13 times.
✗ Branch 80 not taken.
✓ Branch 82 taken 13 times.
✗ Branch 83 not taken.
✓ Branch 85 taken 13 times.
✗ Branch 86 not taken.
✓ Branch 88 taken 13 times.
✗ Branch 89 not taken.
✓ Branch 91 taken 37 times.
✗ Branch 92 not taken.
✓ Branch 94 taken 37 times.
✗ Branch 95 not taken.
✓ Branch 97 taken 37 times.
✗ Branch 98 not taken.
✓ Branch 100 taken 37 times.
✗ Branch 101 not taken.
✓ Branch 103 taken 13 times.
✗ Branch 104 not taken.
✓ Branch 106 taken 13 times.
✗ Branch 107 not taken.
✓ Branch 109 taken 13 times.
✗ Branch 110 not taken.
✓ Branch 112 taken 13 times.
✗ Branch 113 not taken.
✓ Branch 115 taken 13 times.
✗ Branch 116 not taken.
✓ Branch 118 taken 13 times.
✗ Branch 119 not taken.
✓ Branch 121 taken 13 times.
✗ Branch 122 not taken.
✓ Branch 124 taken 13 times.
✗ Branch 125 not taken.
✓ Branch 127 taken 13 times.
✗ Branch 128 not taken.
✓ Branch 130 taken 13 times.
✗ Branch 131 not taken.
✓ Branch 133 taken 13 times.
✗ Branch 134 not taken.
✓ Branch 136 taken 13 times.
✗ Branch 137 not taken.
✓ Branch 139 taken 13 times.
✗ Branch 140 not taken.
✓ Branch 142 taken 13 times.
✗ Branch 143 not taken.
✓ Branch 145 taken 13 times.
✗ Branch 146 not taken.
✓ Branch 148 taken 13 times.
✗ Branch 149 not taken.
✓ Branch 151 taken 13 times.
✗ Branch 152 not taken.
✓ Branch 154 taken 13 times.
✗ Branch 155 not taken.
✓ Branch 157 taken 13 times.
✗ Branch 158 not taken.
✓ Branch 160 taken 13 times.
✗ Branch 161 not taken.
✓ Branch 163 taken 13 times.
✗ Branch 164 not taken.
✓ Branch 166 taken 13 times.
✗ Branch 167 not taken.
✓ Branch 169 taken 13 times.
✗ Branch 170 not taken.
✓ Branch 172 taken 13 times.
✗ Branch 173 not taken.
✓ Branch 175 taken 13 times.
✗ Branch 176 not taken.
✓ Branch 178 taken 13 times.
✗ Branch 179 not taken.
✓ Branch 181 taken 13 times.
✗ Branch 182 not taken.
✓ Branch 184 taken 13 times.
✗ Branch 185 not taken.
✓ Branch 187 taken 13 times.
✗ Branch 188 not taken.
✓ Branch 190 taken 13 times.
✗ Branch 191 not taken.
✓ Branch 193 taken 13 times.
✗ Branch 194 not taken.
✓ Branch 196 taken 13 times.
✗ Branch 197 not taken.
✓ Branch 199 taken 13 times.
✗ Branch 200 not taken.
✓ Branch 202 taken 13 times.
✗ Branch 203 not taken.
✓ Branch 205 taken 13 times.
✗ Branch 206 not taken.
✓ Branch 208 taken 13 times.
✗ Branch 209 not taken.
✓ Branch 211 taken 13 times.
✗ Branch 212 not taken.
✓ Branch 214 taken 13 times.
✗ Branch 215 not taken.
✓ Branch 217 taken 13 times.
✗ Branch 218 not taken.
✓ Branch 220 taken 13 times.
✗ Branch 221 not taken.
✓ Branch 223 taken 13 times.
✗ Branch 224 not taken.
✓ Branch 226 taken 13 times.
✗ Branch 227 not taken.
✓ Branch 229 taken 13 times.
✗ Branch 230 not taken.
✓ Branch 232 taken 13 times.
✗ Branch 233 not taken.
✓ Branch 235 taken 13 times.
✗ Branch 236 not taken.
✓ Branch 238 taken 13 times.
✗ Branch 239 not taken.
✓ Branch 241 taken 13 times.
✗ Branch 242 not taken.
✓ Branch 244 taken 13 times.
✗ Branch 245 not taken.
✓ Branch 247 taken 13 times.
✗ Branch 248 not taken.
✓ Branch 250 taken 13 times.
✗ Branch 251 not taken.
✓ Branch 253 taken 153 times.
✗ Branch 254 not taken.
✓ Branch 256 taken 153 times.
✗ Branch 257 not taken.
✓ Branch 259 taken 153 times.
✗ Branch 260 not taken.
✓ Branch 262 taken 153 times.
✗ Branch 263 not taken.
✓ Branch 265 taken 85 times.
✗ Branch 266 not taken.
✓ Branch 268 taken 85 times.
✗ Branch 269 not taken.
✓ Branch 271 taken 85 times.
✗ Branch 272 not taken.
✓ Branch 274 taken 85 times.
✗ Branch 275 not taken.
✓ Branch 277 taken 105 times.
✗ Branch 278 not taken.
✓ Branch 280 taken 105 times.
✗ Branch 281 not taken.
✓ Branch 283 taken 105 times.
✗ Branch 284 not taken.
✓ Branch 286 taken 105 times.
✗ Branch 287 not taken.
✓ Branch 289 taken 105 times.
✗ Branch 290 not taken.
✓ Branch 292 taken 105 times.
✗ Branch 293 not taken.
✓ Branch 295 taken 105 times.
✗ Branch 296 not taken.
✓ Branch 298 taken 105 times.
✗ Branch 299 not taken.
✓ Branch 301 taken 13 times.
✗ Branch 302 not taken.
✓ Branch 304 taken 13 times.
✗ Branch 305 not taken.
✓ Branch 307 taken 17 times.
✗ Branch 308 not taken.
✓ Branch 310 taken 17 times.
✗ Branch 311 not taken.
✓ Branch 313 taken 17 times.
✗ Branch 314 not taken.
✓ Branch 316 taken 17 times.
✗ Branch 317 not taken.
✓ Branch 319 taken 17 times.
✗ Branch 320 not taken.
✓ Branch 322 taken 17 times.
✗ Branch 323 not taken.
✓ Branch 325 taken 61 times.
✗ Branch 326 not taken.
✓ Branch 328 taken 61 times.
✗ Branch 329 not taken.
✓ Branch 331 taken 61 times.
✗ Branch 332 not taken.
✓ Branch 334 taken 61 times.
✗ Branch 335 not taken.
✓ Branch 337 taken 61 times.
✗ Branch 338 not taken.
✓ Branch 340 taken 61 times.
✗ Branch 341 not taken.
✓ Branch 343 taken 61 times.
✗ Branch 344 not taken.
✓ Branch 346 taken 61 times.
✗ Branch 347 not taken.
✓ Branch 349 taken 61 times.
✗ Branch 350 not taken.
✓ Branch 352 taken 113 times.
✗ Branch 353 not taken.
✓ Branch 355 taken 113 times.
✗ Branch 356 not taken.
✓ Branch 358 taken 113 times.
✗ Branch 359 not taken.
✓ Branch 361 taken 113 times.
✗ Branch 362 not taken.
✓ Branch 364 taken 113 times.
✗ Branch 365 not taken.
✓ Branch 367 taken 113 times.
✗ Branch 368 not taken.
✓ Branch 370 taken 113 times.
✗ Branch 371 not taken.
✓ Branch 373 taken 113 times.
✗ Branch 374 not taken.
✓ Branch 376 taken 113 times.
✗ Branch 377 not taken.
✓ Branch 379 taken 13 times.
✗ Branch 380 not taken.
✓ Branch 382 taken 13 times.
✗ Branch 383 not taken.
✓ Branch 385 taken 13 times.
✗ Branch 386 not taken.
✓ Branch 388 taken 13 times.
✗ Branch 389 not taken.
✓ Branch 391 taken 13 times.
✗ Branch 392 not taken.
✓ Branch 394 taken 13 times.
✗ Branch 395 not taken.
✓ Branch 397 taken 13 times.
✗ Branch 398 not taken.
✓ Branch 400 taken 13 times.
✗ Branch 401 not taken.
✓ Branch 403 taken 13 times.
✗ Branch 404 not taken.
✓ Branch 406 taken 13 times.
✗ Branch 407 not taken.
✓ Branch 409 taken 13 times.
✗ Branch 410 not taken.
✓ Branch 412 taken 13 times.
✗ Branch 413 not taken.
✓ Branch 415 taken 13 times.
✗ Branch 416 not taken.
✓ Branch 418 taken 13 times.
✗ Branch 419 not taken.
✓ Branch 421 taken 13 times.
✗ Branch 422 not taken.
✓ Branch 424 taken 13 times.
✗ Branch 425 not taken.
✓ Branch 427 taken 13 times.
✗ Branch 428 not taken.
✓ Branch 430 taken 13 times.
✗ Branch 431 not taken.
✓ Branch 433 taken 13 times.
✗ Branch 434 not taken.
✓ Branch 436 taken 13 times.
✗ Branch 437 not taken.
✓ Branch 439 taken 13 times.
✗ Branch 440 not taken.
✓ Branch 442 taken 49 times.
✗ Branch 443 not taken.
✓ Branch 445 taken 49 times.
✗ Branch 446 not taken.
✓ Branch 448 taken 617 times.
✗ Branch 449 not taken.
✓ Branch 451 taken 617 times.
✗ Branch 452 not taken.
✓ Branch 454 taken 13 times.
✗ Branch 455 not taken.
✓ Branch 457 taken 13 times.
✗ Branch 458 not taken.
✓ Branch 460 taken 13 times.
✗ Branch 461 not taken.
✓ Branch 463 taken 13 times.
✗ Branch 464 not taken.
✓ Branch 466 taken 13 times.
✗ Branch 467 not taken.
✓ Branch 469 taken 13 times.
✗ Branch 470 not taken.
✓ Branch 472 taken 13 times.
✗ Branch 473 not taken.
✓ Branch 475 taken 13 times.
✗ Branch 476 not taken.
✓ Branch 478 taken 13 times.
✗ Branch 479 not taken.
✓ Branch 481 taken 13 times.
✗ Branch 482 not taken.
✓ Branch 484 taken 125 times.
✗ Branch 485 not taken.
✓ Branch 487 taken 125 times.
✗ Branch 488 not taken.
✓ Branch 490 taken 1 times.
✗ Branch 491 not taken.
✓ Branch 493 taken 1 times.
✗ Branch 494 not taken.
7601 this->addSignature<Signature, SRet>(ptr, symbol);
966 return *this;
967 }
968
969 inline FunctionBuilder& addDependency(const char* name) {
970
17/34
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 51 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 59 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 80 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 127 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 127 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 13 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 13 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 13 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 13 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 13 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 85 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 85 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 17 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 61 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 61 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 13 times.
✗ Branch 50 not taken.
646 mCurrentSettings->mDeps.emplace_back(name); return *this;
971 }
972
973 3879 inline FunctionBuilder& setEmbedIR(bool on) { mCurrentSettings->mEmbedIR = on; return *this; }
974
147/157
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 1577 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 269 times.
✓ Branch 4 taken 1276 times.
✓ Branch 5 taken 78 times.
✓ Branch 6 taken 996 times.
✓ Branch 7 taken 574 times.
✓ Branch 8 taken 40 times.
✓ Branch 9 taken 1859 times.
✓ Branch 10 taken 8 times.
✓ Branch 11 taken 469 times.
✓ Branch 12 taken 989 times.
✓ Branch 13 taken 5 times.
✓ Branch 14 taken 726 times.
✓ Branch 15 taken 3 times.
✓ Branch 16 taken 238 times.
✓ Branch 17 taken 487 times.
✓ Branch 18 taken 18 times.
✓ Branch 19 taken 10 times.
✓ Branch 20 taken 35 times.
✓ Branch 21 taken 13 times.
✓ Branch 22 taken 12 times.
✓ Branch 23 taken 8 times.
✓ Branch 24 taken 51 times.
✓ Branch 25 taken 8 times.
✓ Branch 26 taken 5 times.
✓ Branch 27 taken 15 times.
✓ Branch 28 taken 5 times.
✓ Branch 29 taken 28 times.
✓ Branch 30 taken 5 times.
✓ Branch 31 taken 22 times.
✓ Branch 32 taken 5 times.
✓ Branch 33 taken 10 times.
✓ Branch 34 taken 5 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 1 times.
✓ Branch 37 taken 8 times.
✓ Branch 38 taken 5 times.
✗ Branch 39 not taken.
✓ Branch 40 taken 1 times.
✓ Branch 41 taken 8 times.
✓ Branch 42 taken 5 times.
✗ Branch 43 not taken.
✓ Branch 44 taken 1 times.
✓ Branch 45 taken 8 times.
✓ Branch 46 taken 5 times.
✓ Branch 48 taken 13 times.
✗ Branch 49 not taken.
✓ Branch 50 taken 8 times.
✓ Branch 51 taken 5 times.
✓ Branch 53 taken 13 times.
✗ Branch 54 not taken.
✓ Branch 56 taken 13 times.
✗ Branch 57 not taken.
✓ Branch 59 taken 13 times.
✗ Branch 60 not taken.
✓ Branch 61 taken 8 times.
✓ Branch 62 taken 5 times.
✓ Branch 63 taken 8 times.
✓ Branch 64 taken 5 times.
✓ Branch 65 taken 8 times.
✓ Branch 66 taken 5 times.
✓ Branch 67 taken 16 times.
✓ Branch 68 taken 17 times.
✓ Branch 69 taken 8 times.
✓ Branch 70 taken 5 times.
✓ Branch 71 taken 8 times.
✓ Branch 72 taken 5 times.
✓ Branch 73 taken 8 times.
✓ Branch 74 taken 5 times.
✓ Branch 75 taken 8 times.
✓ Branch 76 taken 5 times.
✓ Branch 77 taken 8 times.
✓ Branch 78 taken 5 times.
✓ Branch 79 taken 8 times.
✓ Branch 80 taken 5 times.
✓ Branch 81 taken 8 times.
✓ Branch 82 taken 5 times.
✗ Branch 83 not taken.
✓ Branch 84 taken 37 times.
✓ Branch 86 taken 8 times.
✓ Branch 87 taken 5 times.
✓ Branch 88 taken 8 times.
✓ Branch 89 taken 5 times.
✓ Branch 90 taken 8 times.
✓ Branch 91 taken 5 times.
✓ Branch 92 taken 8 times.
✓ Branch 93 taken 5 times.
✓ Branch 94 taken 8 times.
✓ Branch 95 taken 5 times.
✓ Branch 96 taken 8 times.
✓ Branch 97 taken 5 times.
✓ Branch 98 taken 24 times.
✓ Branch 99 taken 129 times.
✓ Branch 100 taken 8 times.
✓ Branch 101 taken 5 times.
✓ Branch 102 taken 8 times.
✓ Branch 103 taken 5 times.
✓ Branch 104 taken 8 times.
✓ Branch 105 taken 5 times.
✓ Branch 106 taken 8 times.
✓ Branch 107 taken 5 times.
✓ Branch 108 taken 8 times.
✓ Branch 109 taken 6 times.
✓ Branch 110 taken 56 times.
✓ Branch 111 taken 29 times.
✓ Branch 112 taken 56 times.
✓ Branch 113 taken 49 times.
✓ Branch 114 taken 56 times.
✓ Branch 115 taken 49 times.
✓ Branch 116 taken 8 times.
✓ Branch 117 taken 5 times.
✓ Branch 118 taken 8 times.
✓ Branch 119 taken 9 times.
✓ Branch 120 taken 16 times.
✓ Branch 121 taken 45 times.
✓ Branch 122 taken 24 times.
✓ Branch 123 taken 89 times.
✓ Branch 124 taken 8 times.
✓ Branch 125 taken 5 times.
✓ Branch 126 taken 8 times.
✓ Branch 127 taken 5 times.
✓ Branch 128 taken 8 times.
✓ Branch 129 taken 5 times.
✓ Branch 130 taken 8 times.
✓ Branch 131 taken 5 times.
✓ Branch 132 taken 8 times.
✓ Branch 133 taken 5 times.
✓ Branch 134 taken 8 times.
✓ Branch 135 taken 5 times.
✓ Branch 136 taken 8 times.
✓ Branch 137 taken 5 times.
✓ Branch 138 taken 8 times.
✓ Branch 139 taken 5 times.
✓ Branch 140 taken 8 times.
✓ Branch 141 taken 5 times.
✓ Branch 142 taken 24 times.
✓ Branch 143 taken 25 times.
✓ Branch 144 taken 32 times.
✓ Branch 145 taken 585 times.
✓ Branch 146 taken 8 times.
✓ Branch 147 taken 5 times.
✓ Branch 148 taken 8 times.
✓ Branch 149 taken 5 times.
✓ Branch 150 taken 8 times.
✓ Branch 151 taken 5 times.
✓ Branch 152 taken 8 times.
✓ Branch 153 taken 5 times.
✓ Branch 154 taken 8 times.
✓ Branch 155 taken 5 times.
✓ Branch 156 taken 32 times.
✓ Branch 157 taken 93 times.
✗ Branch 158 not taken.
✓ Branch 159 taken 1 times.
✗ Branch 160 not taken.
✓ Branch 161 taken 1 times.
13490 inline FunctionBuilder& setConstantFold(bool on) { mCurrentSettings->mConstantFold = on; return *this; }
975 4191 inline FunctionBuilder& setArgumentNames(const std::vector<const char*>& names) {
976
1/2
✓ Branch 2 taken 4191 times.
✗ Branch 3 not taken.
4191 mCurrentSettings->mNames.reset(new std::vector<const char*>(names));
977 4191 return *this;
978 }
979
980 /// @details Parameter and Function Attributes. When designing a C binding,
981 /// llvm will be unable to assign parameter markings to the return
982 /// type, function body or parameter attributes due to there not
983 /// being any visibility on the function itself during codegen.
984 /// The best way to ensure performant C bindings is to ensure
985 /// that the function is marked with the required llvm parameters.
986 /// Some of the heavy hitters (which can have the most impact)
987 /// are below:
988 ///
989 /// Functions:
990 /// - norecurse
991 /// This function attribute indicates that the function does
992 /// not call itself either directly or indirectly down any
993 /// possible call path.
994 ///
995 /// - willreturn
996 /// This function attribute indicates that a call of this
997 /// function will either exhibit undefined behavior or comes
998 /// back and continues execution at a point in the existing
999 /// call stack that includes the current invocation.
1000 ///
1001 /// - nounwind
1002 /// This function attribute indicates that the function never
1003 /// raises an exception.
1004 ///
1005 /// - readnone
1006 /// On a function, this attribute indicates that the function
1007 /// computes its result (or decides to unwind an exception) based
1008 /// strictly on its arguments, without dereferencing any pointer
1009 /// arguments or otherwise accessing any mutable state (e.g. memory,
1010 /// control registers, etc) visible to caller functions.
1011 ///
1012 /// - readonly
1013 /// On a function, this attribute indicates that the function
1014 /// does not write through any pointer arguments (including byval
1015 /// arguments) or otherwise modify any state (e.g. memory, control
1016 /// registers, etc) visible to caller functions.
1017 /// control registers, etc) visible to caller functions.
1018 ///
1019 /// - writeonly
1020 /// On a function, this attribute indicates that the function may
1021 /// write to but does not read from memory.
1022 ///
1023 /// Parameters:
1024 /// - noalias
1025 /// This indicates that objects accessed via pointer values based
1026 /// on the argument or return value are not also accessed, during
1027 /// the execution of the function, via pointer values not based on
1028 /// the argument or return value.
1029 ///
1030 /// - nonnull
1031 /// This indicates that the parameter or return pointer is not null.
1032 ///
1033 /// - readonly
1034 /// Indicates that the function does not write through this pointer
1035 /// argument, even though it may write to the memory that the pointer
1036 /// points to.
1037 ///
1038 /// - writeonly
1039 /// Indicates that the function may write to but does not read through
1040 /// this pointer argument (even though it may read from the memory
1041 /// that the pointer points to).
1042 ///
1043 inline FunctionBuilder&
1044 addParameterAttribute(const size_t idx, const llvm::Attribute::AttrKind attr) {
1045
138/276
✓ Branch 1 taken 2968 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2968 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2968 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2968 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2996 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 2996 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 2992 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 2992 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 2992 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 2992 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 2992 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 2992 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 2963 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 2963 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 2965 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 2965 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 2965 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 2965 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 2271 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 2271 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 2271 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 2271 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 2271 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 2271 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 2271 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 2271 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 2265 times.
✗ Branch 80 not taken.
✓ Branch 82 taken 2265 times.
✗ Branch 83 not taken.
✓ Branch 85 taken 2255 times.
✗ Branch 86 not taken.
✓ Branch 88 taken 2255 times.
✗ Branch 89 not taken.
✓ Branch 91 taken 2265 times.
✗ Branch 92 not taken.
✓ Branch 94 taken 2265 times.
✗ Branch 95 not taken.
✓ Branch 97 taken 2265 times.
✗ Branch 98 not taken.
✓ Branch 100 taken 2265 times.
✗ Branch 101 not taken.
✓ Branch 103 taken 2265 times.
✗ Branch 104 not taken.
✓ Branch 106 taken 2265 times.
✗ Branch 107 not taken.
✓ Branch 109 taken 2263 times.
✗ Branch 110 not taken.
✓ Branch 112 taken 2263 times.
✗ Branch 113 not taken.
✓ Branch 115 taken 2263 times.
✗ Branch 116 not taken.
✓ Branch 118 taken 2263 times.
✗ Branch 119 not taken.
✓ Branch 121 taken 2239 times.
✗ Branch 122 not taken.
✓ Branch 124 taken 2239 times.
✗ Branch 125 not taken.
✓ Branch 127 taken 2239 times.
✗ Branch 128 not taken.
✓ Branch 130 taken 2239 times.
✗ Branch 131 not taken.
✓ Branch 133 taken 2239 times.
✗ Branch 134 not taken.
✓ Branch 136 taken 2239 times.
✗ Branch 137 not taken.
✓ Branch 139 taken 2239 times.
✗ Branch 140 not taken.
✓ Branch 142 taken 2239 times.
✗ Branch 143 not taken.
✓ Branch 145 taken 2239 times.
✗ Branch 146 not taken.
✓ Branch 148 taken 2239 times.
✗ Branch 149 not taken.
✓ Branch 151 taken 2239 times.
✗ Branch 152 not taken.
✓ Branch 154 taken 2239 times.
✗ Branch 155 not taken.
✓ Branch 157 taken 1488 times.
✗ Branch 158 not taken.
✓ Branch 160 taken 1488 times.
✗ Branch 161 not taken.
✓ Branch 163 taken 1488 times.
✗ Branch 164 not taken.
✓ Branch 166 taken 1488 times.
✗ Branch 167 not taken.
✓ Branch 169 taken 1508 times.
✗ Branch 170 not taken.
✓ Branch 172 taken 1508 times.
✗ Branch 173 not taken.
✓ Branch 175 taken 1508 times.
✗ Branch 176 not taken.
✓ Branch 178 taken 1508 times.
✗ Branch 179 not taken.
✓ Branch 181 taken 1488 times.
✗ Branch 182 not taken.
✓ Branch 184 taken 1488 times.
✗ Branch 185 not taken.
✓ Branch 187 taken 776 times.
✗ Branch 188 not taken.
✓ Branch 190 taken 776 times.
✗ Branch 191 not taken.
✓ Branch 193 taken 776 times.
✗ Branch 194 not taken.
✓ Branch 196 taken 776 times.
✗ Branch 197 not taken.
✓ Branch 199 taken 776 times.
✗ Branch 200 not taken.
✓ Branch 202 taken 776 times.
✗ Branch 203 not taken.
✓ Branch 205 taken 776 times.
✗ Branch 206 not taken.
✓ Branch 208 taken 776 times.
✗ Branch 209 not taken.
✓ Branch 211 taken 789 times.
✗ Branch 212 not taken.
✓ Branch 214 taken 789 times.
✗ Branch 215 not taken.
✓ Branch 217 taken 789 times.
✗ Branch 218 not taken.
✓ Branch 220 taken 789 times.
✗ Branch 221 not taken.
✓ Branch 223 taken 789 times.
✗ Branch 224 not taken.
✓ Branch 226 taken 789 times.
✗ Branch 227 not taken.
✓ Branch 229 taken 789 times.
✗ Branch 230 not taken.
✓ Branch 232 taken 789 times.
✗ Branch 233 not taken.
✓ Branch 235 taken 783 times.
✗ Branch 236 not taken.
✓ Branch 238 taken 783 times.
✗ Branch 239 not taken.
✓ Branch 241 taken 783 times.
✗ Branch 242 not taken.
✓ Branch 244 taken 783 times.
✗ Branch 245 not taken.
✓ Branch 247 taken 783 times.
✗ Branch 248 not taken.
✓ Branch 250 taken 783 times.
✗ Branch 251 not taken.
✓ Branch 253 taken 769 times.
✗ Branch 254 not taken.
✓ Branch 256 taken 769 times.
✗ Branch 257 not taken.
✓ Branch 259 taken 769 times.
✗ Branch 260 not taken.
✓ Branch 262 taken 769 times.
✗ Branch 263 not taken.
✓ Branch 265 taken 769 times.
✗ Branch 266 not taken.
✓ Branch 268 taken 769 times.
✗ Branch 269 not taken.
✓ Branch 271 taken 793 times.
✗ Branch 272 not taken.
✓ Branch 274 taken 793 times.
✗ Branch 275 not taken.
✓ Branch 277 taken 37 times.
✗ Branch 278 not taken.
✓ Branch 280 taken 37 times.
✗ Branch 281 not taken.
✓ Branch 283 taken 37 times.
✗ Branch 284 not taken.
✓ Branch 286 taken 37 times.
✗ Branch 287 not taken.
✓ Branch 289 taken 37 times.
✗ Branch 290 not taken.
✓ Branch 292 taken 37 times.
✗ Branch 293 not taken.
✓ Branch 295 taken 13 times.
✗ Branch 296 not taken.
✓ Branch 298 taken 13 times.
✗ Branch 299 not taken.
✓ Branch 301 taken 13 times.
✗ Branch 302 not taken.
✓ Branch 304 taken 13 times.
✗ Branch 305 not taken.
✓ Branch 307 taken 13 times.
✗ Branch 308 not taken.
✓ Branch 310 taken 13 times.
✗ Branch 311 not taken.
✓ Branch 313 taken 13 times.
✗ Branch 314 not taken.
✓ Branch 316 taken 13 times.
✗ Branch 317 not taken.
✓ Branch 319 taken 13 times.
✗ Branch 320 not taken.
✓ Branch 322 taken 13 times.
✗ Branch 323 not taken.
✓ Branch 325 taken 13 times.
✗ Branch 326 not taken.
✓ Branch 328 taken 13 times.
✗ Branch 329 not taken.
✓ Branch 331 taken 13 times.
✗ Branch 332 not taken.
✓ Branch 334 taken 13 times.
✗ Branch 335 not taken.
✓ Branch 337 taken 13 times.
✗ Branch 338 not taken.
✓ Branch 340 taken 13 times.
✗ Branch 341 not taken.
✓ Branch 343 taken 13 times.
✗ Branch 344 not taken.
✓ Branch 346 taken 13 times.
✗ Branch 347 not taken.
✓ Branch 349 taken 13 times.
✗ Branch 350 not taken.
✓ Branch 352 taken 13 times.
✗ Branch 353 not taken.
✓ Branch 355 taken 17 times.
✗ Branch 356 not taken.
✓ Branch 358 taken 17 times.
✗ Branch 359 not taken.
✓ Branch 361 taken 17 times.
✗ Branch 362 not taken.
✓ Branch 364 taken 17 times.
✗ Branch 365 not taken.
✓ Branch 367 taken 61 times.
✗ Branch 368 not taken.
✓ Branch 370 taken 61 times.
✗ Branch 371 not taken.
✓ Branch 373 taken 113 times.
✗ Branch 374 not taken.
✓ Branch 376 taken 113 times.
✗ Branch 377 not taken.
✓ Branch 379 taken 13 times.
✗ Branch 380 not taken.
✓ Branch 382 taken 13 times.
✗ Branch 383 not taken.
✓ Branch 385 taken 13 times.
✗ Branch 386 not taken.
✓ Branch 388 taken 13 times.
✗ Branch 389 not taken.
✓ Branch 391 taken 13 times.
✗ Branch 392 not taken.
✓ Branch 394 taken 13 times.
✗ Branch 395 not taken.
✓ Branch 397 taken 13 times.
✗ Branch 398 not taken.
✓ Branch 400 taken 13 times.
✗ Branch 401 not taken.
✓ Branch 403 taken 13 times.
✗ Branch 404 not taken.
✓ Branch 406 taken 13 times.
✗ Branch 407 not taken.
✓ Branch 409 taken 13 times.
✗ Branch 410 not taken.
✓ Branch 412 taken 13 times.
✗ Branch 413 not taken.
11777 mCurrentSettings->mParamAttrs[idx].emplace_back(attr);
1046 return *this;
1047 }
1048
1049 inline FunctionBuilder&
1050 addReturnAttribute(const llvm::Attribute::AttrKind attr) {
1051 mCurrentSettings->mRetAttrs.emplace_back(attr);
1052 return *this;
1053 }
1054
1055 inline FunctionBuilder&
1056 addFunctionAttribute(const llvm::Attribute::AttrKind attr) {
1057
241/482
✓ Branch 1 taken 2968 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2968 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2214 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1458 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1458 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 741 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 756 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 756 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 732 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 732 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 10 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 10 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 23 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 23 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 17 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 17 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 27 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 15 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 15 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 15 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 15 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 13 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 13 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 13 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 13 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 13 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 13 times.
✗ Branch 80 not taken.
✓ Branch 82 taken 13 times.
✗ Branch 83 not taken.
✓ Branch 85 taken 13 times.
✗ Branch 86 not taken.
✓ Branch 88 taken 13 times.
✗ Branch 89 not taken.
✓ Branch 91 taken 13 times.
✗ Branch 92 not taken.
✓ Branch 94 taken 13 times.
✗ Branch 95 not taken.
✓ Branch 97 taken 13 times.
✗ Branch 98 not taken.
✓ Branch 100 taken 13 times.
✗ Branch 101 not taken.
✓ Branch 103 taken 13 times.
✗ Branch 104 not taken.
✓ Branch 106 taken 13 times.
✗ Branch 107 not taken.
✓ Branch 109 taken 13 times.
✗ Branch 110 not taken.
✓ Branch 112 taken 13 times.
✗ Branch 113 not taken.
✓ Branch 115 taken 13 times.
✗ Branch 116 not taken.
✓ Branch 118 taken 13 times.
✗ Branch 119 not taken.
✓ Branch 121 taken 13 times.
✗ Branch 122 not taken.
✓ Branch 124 taken 13 times.
✗ Branch 125 not taken.
✓ Branch 127 taken 13 times.
✗ Branch 128 not taken.
✓ Branch 130 taken 13 times.
✗ Branch 131 not taken.
✓ Branch 133 taken 13 times.
✗ Branch 134 not taken.
✓ Branch 136 taken 13 times.
✗ Branch 137 not taken.
✓ Branch 139 taken 13 times.
✗ Branch 140 not taken.
✓ Branch 142 taken 13 times.
✗ Branch 143 not taken.
✓ Branch 145 taken 13 times.
✗ Branch 146 not taken.
✓ Branch 148 taken 13 times.
✗ Branch 149 not taken.
✓ Branch 151 taken 13 times.
✗ Branch 152 not taken.
✓ Branch 154 taken 13 times.
✗ Branch 155 not taken.
✓ Branch 157 taken 13 times.
✗ Branch 158 not taken.
✓ Branch 160 taken 13 times.
✗ Branch 161 not taken.
✓ Branch 163 taken 1 times.
✗ Branch 164 not taken.
✓ Branch 166 taken 1 times.
✗ Branch 167 not taken.
✓ Branch 169 taken 1 times.
✗ Branch 170 not taken.
✓ Branch 172 taken 1 times.
✗ Branch 173 not taken.
✓ Branch 175 taken 13 times.
✗ Branch 176 not taken.
✓ Branch 178 taken 13 times.
✗ Branch 179 not taken.
✓ Branch 181 taken 13 times.
✗ Branch 182 not taken.
✓ Branch 184 taken 13 times.
✗ Branch 185 not taken.
✓ Branch 187 taken 1 times.
✗ Branch 188 not taken.
✓ Branch 190 taken 1 times.
✗ Branch 191 not taken.
✓ Branch 193 taken 1 times.
✗ Branch 194 not taken.
✓ Branch 196 taken 1 times.
✗ Branch 197 not taken.
✓ Branch 199 taken 13 times.
✗ Branch 200 not taken.
✓ Branch 202 taken 13 times.
✗ Branch 203 not taken.
✓ Branch 205 taken 13 times.
✗ Branch 206 not taken.
✓ Branch 208 taken 13 times.
✗ Branch 209 not taken.
✓ Branch 211 taken 1 times.
✗ Branch 212 not taken.
✓ Branch 214 taken 1 times.
✗ Branch 215 not taken.
✓ Branch 217 taken 1 times.
✗ Branch 218 not taken.
✓ Branch 220 taken 1 times.
✗ Branch 221 not taken.
✓ Branch 223 taken 13 times.
✗ Branch 224 not taken.
✓ Branch 226 taken 13 times.
✗ Branch 227 not taken.
✓ Branch 229 taken 13 times.
✗ Branch 230 not taken.
✓ Branch 232 taken 13 times.
✗ Branch 233 not taken.
✓ Branch 235 taken 13 times.
✗ Branch 236 not taken.
✓ Branch 238 taken 13 times.
✗ Branch 239 not taken.
✓ Branch 241 taken 13 times.
✗ Branch 242 not taken.
✓ Branch 244 taken 13 times.
✗ Branch 245 not taken.
✓ Branch 247 taken 13 times.
✗ Branch 248 not taken.
✓ Branch 250 taken 13 times.
✗ Branch 251 not taken.
✓ Branch 253 taken 13 times.
✗ Branch 254 not taken.
✓ Branch 256 taken 13 times.
✗ Branch 257 not taken.
✓ Branch 259 taken 33 times.
✗ Branch 260 not taken.
✓ Branch 262 taken 33 times.
✗ Branch 263 not taken.
✓ Branch 265 taken 13 times.
✗ Branch 266 not taken.
✓ Branch 268 taken 13 times.
✗ Branch 269 not taken.
✓ Branch 271 taken 13 times.
✗ Branch 272 not taken.
✓ Branch 274 taken 13 times.
✗ Branch 275 not taken.
✓ Branch 277 taken 13 times.
✗ Branch 278 not taken.
✓ Branch 280 taken 13 times.
✗ Branch 281 not taken.
✓ Branch 283 taken 13 times.
✗ Branch 284 not taken.
✓ Branch 286 taken 13 times.
✗ Branch 287 not taken.
✓ Branch 289 taken 13 times.
✗ Branch 290 not taken.
✓ Branch 292 taken 13 times.
✗ Branch 293 not taken.
✓ Branch 295 taken 13 times.
✗ Branch 296 not taken.
✓ Branch 298 taken 13 times.
✗ Branch 299 not taken.
✓ Branch 301 taken 13 times.
✗ Branch 302 not taken.
✓ Branch 304 taken 37 times.
✗ Branch 305 not taken.
✓ Branch 307 taken 37 times.
✗ Branch 308 not taken.
✓ Branch 310 taken 49 times.
✗ Branch 311 not taken.
✓ Branch 313 taken 49 times.
✗ Branch 314 not taken.
✓ Branch 316 taken 50 times.
✗ Branch 317 not taken.
✓ Branch 319 taken 50 times.
✗ Branch 320 not taken.
✓ Branch 322 taken 13 times.
✗ Branch 323 not taken.
✓ Branch 325 taken 13 times.
✗ Branch 326 not taken.
✓ Branch 328 taken 13 times.
✗ Branch 329 not taken.
✓ Branch 331 taken 13 times.
✗ Branch 332 not taken.
✓ Branch 334 taken 13 times.
✗ Branch 335 not taken.
✓ Branch 337 taken 13 times.
✗ Branch 338 not taken.
✓ Branch 340 taken 13 times.
✗ Branch 341 not taken.
✓ Branch 343 taken 13 times.
✗ Branch 344 not taken.
✓ Branch 346 taken 13 times.
✗ Branch 347 not taken.
✓ Branch 349 taken 13 times.
✗ Branch 350 not taken.
✓ Branch 352 taken 13 times.
✗ Branch 353 not taken.
✓ Branch 355 taken 13 times.
✗ Branch 356 not taken.
✓ Branch 358 taken 13 times.
✗ Branch 359 not taken.
✓ Branch 361 taken 13 times.
✗ Branch 362 not taken.
✓ Branch 364 taken 13 times.
✗ Branch 365 not taken.
✓ Branch 367 taken 13 times.
✗ Branch 368 not taken.
✓ Branch 370 taken 13 times.
✗ Branch 371 not taken.
✓ Branch 373 taken 13 times.
✗ Branch 374 not taken.
✓ Branch 376 taken 13 times.
✗ Branch 377 not taken.
✓ Branch 379 taken 13 times.
✗ Branch 380 not taken.
✓ Branch 382 taken 13 times.
✗ Branch 383 not taken.
✓ Branch 385 taken 13 times.
✗ Branch 386 not taken.
✓ Branch 388 taken 153 times.
✗ Branch 389 not taken.
✓ Branch 391 taken 153 times.
✗ Branch 392 not taken.
✓ Branch 394 taken 153 times.
✗ Branch 395 not taken.
✓ Branch 397 taken 153 times.
✗ Branch 398 not taken.
✓ Branch 400 taken 13 times.
✗ Branch 401 not taken.
✓ Branch 403 taken 13 times.
✗ Branch 404 not taken.
✓ Branch 406 taken 13 times.
✗ Branch 407 not taken.
✓ Branch 409 taken 13 times.
✗ Branch 410 not taken.
✓ Branch 412 taken 13 times.
✗ Branch 413 not taken.
✓ Branch 415 taken 13 times.
✗ Branch 416 not taken.
✓ Branch 418 taken 13 times.
✗ Branch 419 not taken.
✓ Branch 421 taken 13 times.
✗ Branch 422 not taken.
✓ Branch 424 taken 13 times.
✗ Branch 425 not taken.
✓ Branch 427 taken 13 times.
✗ Branch 428 not taken.
✓ Branch 430 taken 13 times.
✗ Branch 431 not taken.
✓ Branch 433 taken 13 times.
✗ Branch 434 not taken.
✓ Branch 436 taken 13 times.
✗ Branch 437 not taken.
✓ Branch 439 taken 13 times.
✗ Branch 440 not taken.
✓ Branch 442 taken 13 times.
✗ Branch 443 not taken.
✓ Branch 445 taken 13 times.
✗ Branch 446 not taken.
✓ Branch 448 taken 85 times.
✗ Branch 449 not taken.
✓ Branch 451 taken 85 times.
✗ Branch 452 not taken.
✓ Branch 454 taken 85 times.
✗ Branch 455 not taken.
✓ Branch 457 taken 85 times.
✗ Branch 458 not taken.
✓ Branch 460 taken 105 times.
✗ Branch 461 not taken.
✓ Branch 463 taken 105 times.
✗ Branch 464 not taken.
✓ Branch 466 taken 105 times.
✗ Branch 467 not taken.
✓ Branch 469 taken 105 times.
✗ Branch 470 not taken.
✓ Branch 472 taken 105 times.
✗ Branch 473 not taken.
✓ Branch 475 taken 105 times.
✗ Branch 476 not taken.
✓ Branch 478 taken 105 times.
✗ Branch 479 not taken.
✓ Branch 481 taken 105 times.
✗ Branch 482 not taken.
✓ Branch 484 taken 13 times.
✗ Branch 485 not taken.
✓ Branch 487 taken 13 times.
✗ Branch 488 not taken.
✓ Branch 490 taken 13 times.
✗ Branch 491 not taken.
✓ Branch 493 taken 13 times.
✗ Branch 494 not taken.
✓ Branch 496 taken 17 times.
✗ Branch 497 not taken.
✓ Branch 499 taken 17 times.
✗ Branch 500 not taken.
✓ Branch 502 taken 61 times.
✗ Branch 503 not taken.
✓ Branch 505 taken 61 times.
✗ Branch 506 not taken.
✓ Branch 508 taken 61 times.
✗ Branch 509 not taken.
✓ Branch 511 taken 61 times.
✗ Branch 512 not taken.
✓ Branch 514 taken 113 times.
✗ Branch 515 not taken.
✓ Branch 517 taken 113 times.
✗ Branch 518 not taken.
✓ Branch 520 taken 113 times.
✗ Branch 521 not taken.
✓ Branch 523 taken 113 times.
✗ Branch 524 not taken.
✓ Branch 526 taken 13 times.
✗ Branch 527 not taken.
✓ Branch 529 taken 13 times.
✗ Branch 530 not taken.
✓ Branch 532 taken 13 times.
✗ Branch 533 not taken.
✓ Branch 535 taken 13 times.
✗ Branch 536 not taken.
✓ Branch 538 taken 13 times.
✗ Branch 539 not taken.
✓ Branch 541 taken 13 times.
✗ Branch 542 not taken.
✓ Branch 544 taken 13 times.
✗ Branch 545 not taken.
✓ Branch 547 taken 13 times.
✗ Branch 548 not taken.
✓ Branch 550 taken 13 times.
✗ Branch 551 not taken.
✓ Branch 553 taken 13 times.
✗ Branch 554 not taken.
✓ Branch 556 taken 13 times.
✗ Branch 557 not taken.
✓ Branch 559 taken 13 times.
✗ Branch 560 not taken.
✓ Branch 562 taken 13 times.
✗ Branch 563 not taken.
✓ Branch 565 taken 13 times.
✗ Branch 566 not taken.
✓ Branch 568 taken 13 times.
✗ Branch 569 not taken.
✓ Branch 571 taken 13 times.
✗ Branch 572 not taken.
✓ Branch 574 taken 13 times.
✗ Branch 575 not taken.
✓ Branch 577 taken 13 times.
✗ Branch 578 not taken.
✓ Branch 580 taken 13 times.
✗ Branch 581 not taken.
✓ Branch 583 taken 13 times.
✗ Branch 584 not taken.
✓ Branch 586 taken 13 times.
✗ Branch 587 not taken.
✓ Branch 589 taken 13 times.
✗ Branch 590 not taken.
✓ Branch 592 taken 13 times.
✗ Branch 593 not taken.
✓ Branch 595 taken 13 times.
✗ Branch 596 not taken.
✓ Branch 598 taken 13 times.
✗ Branch 599 not taken.
✓ Branch 601 taken 13 times.
✗ Branch 602 not taken.
✓ Branch 604 taken 13 times.
✗ Branch 605 not taken.
✓ Branch 607 taken 13 times.
✗ Branch 608 not taken.
✓ Branch 610 taken 13 times.
✗ Branch 611 not taken.
✓ Branch 613 taken 13 times.
✗ Branch 614 not taken.
✓ Branch 616 taken 13 times.
✗ Branch 617 not taken.
✓ Branch 619 taken 13 times.
✗ Branch 620 not taken.
✓ Branch 622 taken 13 times.
✗ Branch 623 not taken.
✓ Branch 625 taken 13 times.
✗ Branch 626 not taken.
✓ Branch 628 taken 49 times.
✗ Branch 629 not taken.
✓ Branch 631 taken 49 times.
✗ Branch 632 not taken.
✓ Branch 634 taken 49 times.
✗ Branch 635 not taken.
✓ Branch 637 taken 49 times.
✗ Branch 638 not taken.
✓ Branch 640 taken 617 times.
✗ Branch 641 not taken.
✓ Branch 643 taken 617 times.
✗ Branch 644 not taken.
✓ Branch 646 taken 617 times.
✗ Branch 647 not taken.
✓ Branch 649 taken 617 times.
✗ Branch 650 not taken.
✓ Branch 652 taken 13 times.
✗ Branch 653 not taken.
✓ Branch 655 taken 13 times.
✗ Branch 656 not taken.
✓ Branch 658 taken 13 times.
✗ Branch 659 not taken.
✓ Branch 661 taken 13 times.
✗ Branch 662 not taken.
✓ Branch 664 taken 13 times.
✗ Branch 665 not taken.
✓ Branch 667 taken 13 times.
✗ Branch 668 not taken.
✓ Branch 670 taken 13 times.
✗ Branch 671 not taken.
✓ Branch 673 taken 13 times.
✗ Branch 674 not taken.
✓ Branch 676 taken 13 times.
✗ Branch 677 not taken.
✓ Branch 679 taken 13 times.
✗ Branch 680 not taken.
✓ Branch 682 taken 13 times.
✗ Branch 683 not taken.
✓ Branch 685 taken 13 times.
✗ Branch 686 not taken.
✓ Branch 688 taken 13 times.
✗ Branch 689 not taken.
✓ Branch 691 taken 13 times.
✗ Branch 692 not taken.
✓ Branch 694 taken 13 times.
✗ Branch 695 not taken.
✓ Branch 697 taken 13 times.
✗ Branch 698 not taken.
✓ Branch 700 taken 13 times.
✗ Branch 701 not taken.
✓ Branch 703 taken 13 times.
✗ Branch 704 not taken.
✓ Branch 706 taken 13 times.
✗ Branch 707 not taken.
✓ Branch 709 taken 13 times.
✗ Branch 710 not taken.
✓ Branch 712 taken 125 times.
✗ Branch 713 not taken.
✓ Branch 715 taken 125 times.
✗ Branch 716 not taken.
✓ Branch 718 taken 125 times.
✗ Branch 719 not taken.
✓ Branch 721 taken 125 times.
✗ Branch 722 not taken.
13395 mCurrentSettings->mFnAttrs.emplace_back(attr);
1058 return *this;
1059 }
1060
1061
4/8
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 60 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 114 times.
✗ Branch 11 not taken.
4261 inline FunctionBuilder& setDocumentation(const char* doc) { mDoc = doc; return *this; }
1062
80/160
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 769 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 109 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 852 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1190 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1035 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 22 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 32 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 35 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 20 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 33 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 27 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 15 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 13 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 13 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 13 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 13 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 13 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 13 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 13 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 1 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 13 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 13 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 13 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 13 times.
✗ Branch 80 not taken.
✓ Branch 82 taken 13 times.
✗ Branch 83 not taken.
✓ Branch 85 taken 33 times.
✗ Branch 86 not taken.
✓ Branch 88 taken 13 times.
✗ Branch 89 not taken.
✓ Branch 91 taken 13 times.
✗ Branch 92 not taken.
✓ Branch 94 taken 13 times.
✗ Branch 95 not taken.
✓ Branch 97 taken 13 times.
✗ Branch 98 not taken.
✓ Branch 100 taken 13 times.
✗ Branch 101 not taken.
✓ Branch 103 taken 13 times.
✗ Branch 104 not taken.
✓ Branch 106 taken 13 times.
✗ Branch 107 not taken.
✓ Branch 109 taken 37 times.
✗ Branch 110 not taken.
✓ Branch 112 taken 49 times.
✗ Branch 113 not taken.
✓ Branch 115 taken 50 times.
✗ Branch 116 not taken.
✓ Branch 118 taken 13 times.
✗ Branch 119 not taken.
✓ Branch 121 taken 13 times.
✗ Branch 122 not taken.
✓ Branch 124 taken 13 times.
✗ Branch 125 not taken.
✓ Branch 127 taken 13 times.
✗ Branch 128 not taken.
✓ Branch 130 taken 13 times.
✗ Branch 131 not taken.
✓ Branch 133 taken 13 times.
✗ Branch 134 not taken.
✓ Branch 136 taken 153 times.
✗ Branch 137 not taken.
✓ Branch 139 taken 13 times.
✗ Branch 140 not taken.
✓ Branch 142 taken 13 times.
✗ Branch 143 not taken.
✓ Branch 145 taken 13 times.
✗ Branch 146 not taken.
✓ Branch 148 taken 13 times.
✗ Branch 149 not taken.
✓ Branch 151 taken 13 times.
✗ Branch 152 not taken.
✓ Branch 154 taken 14 times.
✗ Branch 155 not taken.
✓ Branch 157 taken 13 times.
✗ Branch 158 not taken.
✓ Branch 160 taken 85 times.
✗ Branch 161 not taken.
✓ Branch 163 taken 105 times.
✗ Branch 164 not taken.
✓ Branch 166 taken 105 times.
✗ Branch 167 not taken.
✓ Branch 169 taken 13 times.
✗ Branch 170 not taken.
✓ Branch 172 taken 17 times.
✗ Branch 173 not taken.
✓ Branch 175 taken 61 times.
✗ Branch 176 not taken.
✓ Branch 178 taken 113 times.
✗ Branch 179 not taken.
✓ Branch 181 taken 13 times.
✗ Branch 182 not taken.
✓ Branch 184 taken 13 times.
✗ Branch 185 not taken.
✓ Branch 187 taken 13 times.
✗ Branch 188 not taken.
✓ Branch 190 taken 13 times.
✗ Branch 191 not taken.
✓ Branch 193 taken 13 times.
✗ Branch 194 not taken.
✓ Branch 196 taken 13 times.
✗ Branch 197 not taken.
✓ Branch 199 taken 13 times.
✗ Branch 200 not taken.
✓ Branch 202 taken 13 times.
✗ Branch 203 not taken.
✓ Branch 205 taken 13 times.
✗ Branch 206 not taken.
✓ Branch 208 taken 49 times.
✗ Branch 209 not taken.
✓ Branch 211 taken 617 times.
✗ Branch 212 not taken.
✓ Branch 214 taken 13 times.
✗ Branch 215 not taken.
✓ Branch 217 taken 13 times.
✗ Branch 218 not taken.
✓ Branch 220 taken 13 times.
✗ Branch 221 not taken.
✓ Branch 223 taken 13 times.
✗ Branch 224 not taken.
✓ Branch 226 taken 13 times.
✗ Branch 227 not taken.
✓ Branch 229 taken 125 times.
✗ Branch 230 not taken.
✓ Branch 232 taken 1 times.
✗ Branch 233 not taken.
✓ Branch 235 taken 1 times.
✗ Branch 236 not taken.
✓ Branch 238 taken 1 times.
✗ Branch 239 not taken.
7217 inline FunctionBuilder& setPreferredImpl(DeclPreferrence pref) { mDeclPref = pref; return *this; }
1063
1064 11436 inline FunctionGroup::UniquePtr get() const
1065 {
1066
2/2
✓ Branch 0 taken 95390 times.
✓ Branch 1 taken 11436 times.
106826 for (auto& decl : mCFunctions) {
1067 95390 const auto& s = mSettings.at(decl.get());
1068
2/2
✓ Branch 1 taken 93583 times.
✓ Branch 2 taken 1807 times.
190780 decl->setDependencies(s->mDeps);
1069
2/2
✓ Branch 0 taken 93583 times.
✓ Branch 1 taken 1807 times.
95390 decl->setConstantFold(s->mConstantFold);
1070
2/2
✓ Branch 0 taken 93583 times.
✓ Branch 1 taken 1807 times.
95390 if (!s->mFnAttrs.empty()) decl->setFnAttributes(s->mFnAttrs);
1071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95390 times.
95390 if (!s->mRetAttrs.empty()) decl->setRetAttributes(s->mRetAttrs);
1072
2/2
✓ Branch 0 taken 90021 times.
✓ Branch 1 taken 5369 times.
95390 if (!s->mParamAttrs.empty()) {
1073
2/2
✓ Branch 0 taken 243012 times.
✓ Branch 1 taken 90021 times.
333033 for (auto& idxAttrs : s->mParamAttrs) {
1074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243012 times.
243012 if (idxAttrs.first > decl->size()) continue;
1075 243012 decl->setParamAttributes(idxAttrs.first, idxAttrs.second);
1076 }
1077 }
1078
2/2
✓ Branch 0 taken 7412 times.
✓ Branch 1 taken 87978 times.
102802 if (s->mNames) decl->setArgumentNames(*s->mNames);
1079 }
1080
1081
2/2
✓ Branch 0 taken 12814 times.
✓ Branch 1 taken 11436 times.
24250 for (auto& decl : mIRFunctions) {
1082 12814 const auto& s = mSettings.at(decl.get());
1083
2/2
✓ Branch 1 taken 10521 times.
✓ Branch 2 taken 2293 times.
25628 decl->setDependencies(s->mDeps);
1084
2/2
✓ Branch 0 taken 10521 times.
✓ Branch 1 taken 2293 times.
12814 decl->setEmbedIR(s->mEmbedIR);
1085
2/2
✓ Branch 0 taken 10521 times.
✓ Branch 1 taken 2293 times.
12814 if (!s->mFnAttrs.empty()) decl->setFnAttributes(s->mFnAttrs);
1086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12814 times.
12814 if (!s->mRetAttrs.empty()) decl->setRetAttributes(s->mRetAttrs);
1087
2/2
✓ Branch 0 taken 6754 times.
✓ Branch 1 taken 6060 times.
12814 if (!s->mParamAttrs.empty()) {
1088
2/2
✓ Branch 0 taken 27538 times.
✓ Branch 1 taken 6754 times.
34292 for (auto& idxAttrs : s->mParamAttrs) {
1089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27538 times.
27538 if (idxAttrs.first > decl->size()) continue;
1090 27538 decl->setParamAttributes(idxAttrs.first, idxAttrs.second);
1091 }
1092 }
1093
2/2
✓ Branch 0 taken 8173 times.
✓ Branch 1 taken 4641 times.
20987 if (s->mNames) decl->setArgumentNames(*s->mNames);
1094 }
1095
1096 11436 std::vector<Function::Ptr> functions;
1097
1098
2/2
✓ Branch 0 taken 9018 times.
✓ Branch 1 taken 2418 times.
11436 if (mDeclPref == DeclPreferrence::IR) {
1099
1/2
✓ Branch 1 taken 9018 times.
✗ Branch 2 not taken.
9018 functions.insert(functions.end(), mIRFunctions.begin(), mIRFunctions.end());
1100 }
1101
2/2
✓ Branch 0 taken 2418 times.
✓ Branch 1 taken 9018 times.
11436 if (mDeclPref == DeclPreferrence::C) {
1102
1/2
✓ Branch 1 taken 2418 times.
✗ Branch 2 not taken.
2418 functions.insert(functions.end(), mCFunctions.begin(), mCFunctions.end());
1103 }
1104
2/2
✓ Branch 0 taken 2773 times.
✓ Branch 1 taken 8663 times.
11436 if (functions.empty()) {
1105
2/4
✓ Branch 1 taken 2773 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2773 times.
✗ Branch 5 not taken.
2773 functions.insert(functions.end(), mIRFunctions.begin(), mIRFunctions.end());
1106
1/2
✓ Branch 1 taken 2773 times.
✗ Branch 2 not taken.
2773 functions.insert(functions.end(), mCFunctions.begin(), mCFunctions.end());
1107 }
1108
1109
2/4
✓ Branch 1 taken 11436 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 11436 times.
✗ Branch 5 not taken.
11436 FunctionGroup::UniquePtr group(new FunctionGroup(mName, mDoc, functions));
1110 11436 return group;
1111 }
1112
1113 private:
1114
1115 template <typename Signature>
1116 104156 std::string genSymbol() const
1117 {
1118 using Traits = FunctionTraits<Signature>;
1119
1120 std::string args;
1121 479727 auto callback = [&args](auto type) {
1122 using Type = decltype(type);
1123 656149 args += TypeToSymbol<Type>::s();
1124 };
1125
1126 94945 ArgumentIterator<Signature>::apply(callback, /*forwards*/true);
1127 /// @note important to prefix all symbols with "ax." so that
1128 /// they will never conflict with internal llvm symbol
1129 /// names (such as standard library methods e.g, cos, cosh
1130
1131 // assemble the symbol
1132 104156 return "ax." + std::string(this->mName) + "." +
1133 208312 TypeToSymbol<typename Traits::ReturnType>::s() + args;
1134 }
1135
1136 const char* mName = "";
1137 const char* mDoc = "";
1138 DeclPreferrence mDeclPref = IR;
1139 std::vector<CFunctionBase::Ptr> mCFunctions = {};
1140 std::vector<IRFunctionBase::Ptr> mIRFunctions = {};
1141 std::map<const Function*, Settings::Ptr> mSettings = {};
1142 Settings::Ptr mCurrentSettings = nullptr;
1143 };
1144
1145 } // namespace codegen
1146 } // namespace ax
1147 } // namespace OPENVDB_VERSION_NAME
1148 } // namespace openvdb
1149
1150 #endif // OPENVDB_AX_CODEGEN_FUNCTION_TYPES_HAS_BEEN_INCLUDED
1151
1152