OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LLVMFunctionAttributesUtil.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2017 MapD Technologies, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #if LLVM_VERSION_MAJOR >= 6
20 void mark_function_always_inline(llvm::Function* func) {
21  func->addAttribute(llvm::AttributeList::AttrIndex::FunctionIndex,
22  llvm::Attribute::AlwaysInline);
23 }
24 
25 void mark_function_never_inline(llvm::Function* func) {
27  func->addAttribute(llvm::AttributeList::AttrIndex::FunctionIndex,
28  llvm::Attribute::NoInline);
29 }
30 
31 void clear_function_attributes(llvm::Function* func) {
32  llvm::AttributeList no_attributes;
33  func->setAttributes(no_attributes);
34 }
35 #else
36 void mark_function_always_inline(llvm::Function* func) {
37  func->addAttribute(llvm::AttributeSet::AttrIndex::FunctionIndex,
38  llvm::Attribute::AlwaysInline);
39 }
40 
41 void mark_function_never_inline(llvm::Function* func) {
42  llvm::AttributeSet no_inline_attrs;
43  no_inline_attrs =
44  no_inline_attrs.addAttribute(func->getContext(), 0, llvm::Attribute::NoInline);
45  func->setAttributes(no_inline_attrs);
46 }
47 
48 void clear_function_attributes(llvm::Function* func) {
49  llvm::AttributeSet no_attributes;
50  func->setAttributes(no_attributes);
51 }
52 #endif
void mark_function_never_inline(llvm::Function *func)
void mark_function_always_inline(llvm::Function *func)
void clear_function_attributes(llvm::Function *func)