diff options
Diffstat (limited to 'include/llvm/IR/Module.h')
-rw-r--r-- | include/llvm/IR/Module.h | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/include/llvm/IR/Module.h b/include/llvm/IR/Module.h index 9ef35f1f73cd..f458680cfe15 100644 --- a/include/llvm/IR/Module.h +++ b/include/llvm/IR/Module.h @@ -1,9 +1,8 @@ //===- llvm/Module.h - C++ class to represent a VM module -------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -29,6 +28,7 @@ #include "llvm/IR/GlobalIFunc.h" #include "llvm/IR/GlobalVariable.h" #include "llvm/IR/Metadata.h" +#include "llvm/IR/ProfileSummary.h" #include "llvm/IR/SymbolTableListTraits.h" #include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/CodeGen.h" @@ -333,16 +333,18 @@ public: /// Look up the specified function in the module symbol table. Four /// possibilities: /// 1. If it does not exist, add a prototype for the function and return it. - /// 2. If it exists, and has a local linkage, the existing function is - /// renamed and a new one is inserted. - /// 3. Otherwise, if the existing function has the correct prototype, return + /// 2. Otherwise, if the existing function has the correct prototype, return /// the existing function. - /// 4. Finally, the function exists but has the wrong prototype: return the + /// 3. Finally, the function exists but has the wrong prototype: return the /// function with a constantexpr cast to the right prototype. - Constant *getOrInsertFunction(StringRef Name, FunctionType *T, - AttributeList AttributeList); + /// + /// In all cases, the returned value is a FunctionCallee wrapper around the + /// 'FunctionType *T' passed in, as well as a 'Value*' either of the Function or + /// the bitcast to the function. + FunctionCallee getOrInsertFunction(StringRef Name, FunctionType *T, + AttributeList AttributeList); - Constant *getOrInsertFunction(StringRef Name, FunctionType *T); + FunctionCallee getOrInsertFunction(StringRef Name, FunctionType *T); /// Look up the specified function in the module symbol table. If it does not /// exist, add a prototype for the function and return it. This function @@ -350,11 +352,10 @@ public: /// or a ConstantExpr BitCast of that type if the named function has a /// different type. This version of the method takes a list of /// function arguments, which makes it easier for clients to use. - template<typename... ArgsTy> - Constant *getOrInsertFunction(StringRef Name, - AttributeList AttributeList, - Type *RetTy, ArgsTy... Args) - { + template <typename... ArgsTy> + FunctionCallee getOrInsertFunction(StringRef Name, + AttributeList AttributeList, Type *RetTy, + ArgsTy... Args) { SmallVector<Type*, sizeof...(ArgsTy)> ArgTys{Args...}; return getOrInsertFunction(Name, FunctionType::get(RetTy, ArgTys, false), @@ -362,15 +363,17 @@ public: } /// Same as above, but without the attributes. - template<typename... ArgsTy> - Constant *getOrInsertFunction(StringRef Name, Type *RetTy, ArgsTy... Args) { + template <typename... ArgsTy> + FunctionCallee getOrInsertFunction(StringRef Name, Type *RetTy, + ArgsTy... Args) { return getOrInsertFunction(Name, AttributeList{}, RetTy, Args...); } // Avoid an incorrect ordering that'd otherwise compile incorrectly. template <typename... ArgsTy> - Constant *getOrInsertFunction(StringRef Name, AttributeList AttributeList, - FunctionType *Invalid, ArgsTy... Args) = delete; + FunctionCallee + getOrInsertFunction(StringRef Name, AttributeList AttributeList, + FunctionType *Invalid, ArgsTy... Args) = delete; /// Look up the specified function in the module symbol table. If it does not /// exist, return null. @@ -866,10 +869,11 @@ public: /// @{ /// Attach profile summary metadata to this module. - void setProfileSummary(Metadata *M); + void setProfileSummary(Metadata *M, ProfileSummary::Kind Kind); - /// Returns profile summary metadata - Metadata *getProfileSummary(); + /// Returns profile summary metadata. When IsCS is true, use the context + /// sensitive profile summary. + Metadata *getProfileSummary(bool IsCS); /// @} /// Returns true if PLT should be avoided for RTLib calls. |