diff options
Diffstat (limited to 'lib/IR/Module.cpp')
-rw-r--r-- | lib/IR/Module.cpp | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/lib/IR/Module.cpp b/lib/IR/Module.cpp index 93f27304424f..dbf4035ac7c1 100644 --- a/lib/IR/Module.cpp +++ b/lib/IR/Module.cpp @@ -1,9 +1,8 @@ //===- Module.cpp - Implement the Module class ----------------------------===// // -// 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 // //===----------------------------------------------------------------------===// // @@ -141,8 +140,8 @@ void Module::getOperandBundleTags(SmallVectorImpl<StringRef> &Result) const { // it. This is nice because it allows most passes to get away with not handling // the symbol table directly for this common task. // -Constant *Module::getOrInsertFunction(StringRef Name, FunctionType *Ty, - AttributeList AttributeList) { +FunctionCallee Module::getOrInsertFunction(StringRef Name, FunctionType *Ty, + AttributeList AttributeList) { // See if we have a definition for the specified function already. GlobalValue *F = getNamedValue(Name); if (!F) { @@ -152,21 +151,20 @@ Constant *Module::getOrInsertFunction(StringRef Name, FunctionType *Ty, if (!New->isIntrinsic()) // Intrinsics get attrs set on construction New->setAttributes(AttributeList); FunctionList.push_back(New); - return New; // Return the new prototype. + return {Ty, New}; // Return the new prototype. } // If the function exists but has the wrong type, return a bitcast to the // right type. auto *PTy = PointerType::get(Ty, F->getAddressSpace()); if (F->getType() != PTy) - return ConstantExpr::getBitCast(F, PTy); + return {Ty, ConstantExpr::getBitCast(F, PTy)}; // Otherwise, we just found the existing function or a prototype. - return F; + return {Ty, F}; } -Constant *Module::getOrInsertFunction(StringRef Name, - FunctionType *Ty) { +FunctionCallee Module::getOrInsertFunction(StringRef Name, FunctionType *Ty) { return getOrInsertFunction(Name, Ty, AttributeList()); } @@ -533,12 +531,16 @@ void Module::setCodeModel(CodeModel::Model CL) { addModuleFlag(ModFlagBehavior::Error, "Code Model", CL); } -void Module::setProfileSummary(Metadata *M) { - addModuleFlag(ModFlagBehavior::Error, "ProfileSummary", M); +void Module::setProfileSummary(Metadata *M, ProfileSummary::Kind Kind) { + if (Kind == ProfileSummary::PSK_CSInstr) + addModuleFlag(ModFlagBehavior::Error, "CSProfileSummary", M); + else + addModuleFlag(ModFlagBehavior::Error, "ProfileSummary", M); } -Metadata *Module::getProfileSummary() { - return getModuleFlag("ProfileSummary"); +Metadata *Module::getProfileSummary(bool IsCS) { + return (IsCS ? getModuleFlag("CSProfileSummary") + : getModuleFlag("ProfileSummary")); } void Module::setOwnedMemoryBuffer(std::unique_ptr<MemoryBuffer> MB) { |