llvm/llvm/lib/IR/Function.cpp

//===- Function.cpp - Implement the Global object classes -----------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// This file implements the Function class for the IR library.
//
//===----------------------------------------------------------------------===//

#include "llvm/IR/Function.h"
#include "SymbolTableListTraitsImpl.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/AbstractCallSite.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/ConstantRange.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/SymbolTableListTraits.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Use.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/ValueSymbolTable.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ModRef.h"
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <string>

usingnamespacellvm;
ProfileCount;

// Explicit instantiations of SymbolTableListTraits since some of the methods
// are not in the public header file...
template class llvm::SymbolTableListTraits<BasicBlock>;

static cl::opt<int> NonGlobalValueMaxNameSize(
    "non-global-value-max-name-size", cl::Hidden, cl::init(1024),
    cl::desc("Maximum size for the name of non-global values."));

extern cl::opt<bool> UseNewDbgInfoFormat;

void Function::renumberBlocks() {}

void Function::validateBlockNumbers() const {}

void Function::convertToNewDbgValues() {}

void Function::convertFromNewDbgValues() {}

void Function::setIsNewDbgInfoFormat(bool NewFlag) {}
void Function::setNewDbgInfoFormatFlag(bool NewFlag) {}

//===----------------------------------------------------------------------===//
// Argument Implementation
//===----------------------------------------------------------------------===//

Argument::Argument(Type *Ty, const Twine &Name, Function *Par, unsigned ArgNo)
    :{}

void Argument::setParent(Function *parent) {}

bool Argument::hasNonNullAttr(bool AllowUndefOrPoison) const {}

bool Argument::hasByValAttr() const {}

bool Argument::hasByRefAttr() const {}

bool Argument::hasSwiftSelfAttr() const {}

bool Argument::hasSwiftErrorAttr() const {}

bool Argument::hasInAllocaAttr() const {}

bool Argument::hasPreallocatedAttr() const {}

bool Argument::hasPassPointeeByValueCopyAttr() const {}

bool Argument::hasPointeeInMemoryValueAttr() const {}

/// For a byval, sret, inalloca, or preallocated parameter, get the in-memory
/// parameter type.
static Type *getMemoryParamAllocType(AttributeSet ParamAttrs) {}

uint64_t Argument::getPassPointeeByValueCopySize(const DataLayout &DL) const {}

Type *Argument::getPointeeInMemoryValueType() const {}

MaybeAlign Argument::getParamAlign() const {}

MaybeAlign Argument::getParamStackAlign() const {}

Type *Argument::getParamByValType() const {}

Type *Argument::getParamStructRetType() const {}

Type *Argument::getParamByRefType() const {}

Type *Argument::getParamInAllocaType() const {}

uint64_t Argument::getDereferenceableBytes() const {}

uint64_t Argument::getDereferenceableOrNullBytes() const {}

FPClassTest Argument::getNoFPClass() const {}

std::optional<ConstantRange> Argument::getRange() const {}

bool Argument::hasNestAttr() const {}

bool Argument::hasNoAliasAttr() const {}

bool Argument::hasNoCaptureAttr() const {}

bool Argument::hasNoFreeAttr() const {}

bool Argument::hasStructRetAttr() const {}

bool Argument::hasInRegAttr() const {}

bool Argument::hasReturnedAttr() const {}

bool Argument::hasZExtAttr() const {}

bool Argument::hasSExtAttr() const {}

bool Argument::onlyReadsMemory() const {}

void Argument::addAttrs(AttrBuilder &B) {}

void Argument::addAttr(Attribute::AttrKind Kind) {}

void Argument::addAttr(Attribute Attr) {}

void Argument::removeAttr(Attribute::AttrKind Kind) {}

void Argument::removeAttrs(const AttributeMask &AM) {}

bool Argument::hasAttribute(Attribute::AttrKind Kind) const {}

Attribute Argument::getAttribute(Attribute::AttrKind Kind) const {}

//===----------------------------------------------------------------------===//
// Helper Methods in Function
//===----------------------------------------------------------------------===//

LLVMContext &Function::getContext() const {}

const DataLayout &Function::getDataLayout() const {}

unsigned Function::getInstructionCount() const {}

Function *Function::Create(FunctionType *Ty, LinkageTypes Linkage,
                           const Twine &N, Module &M) {}

Function *Function::createWithDefaultAttr(FunctionType *Ty,
                                          LinkageTypes Linkage,
                                          unsigned AddrSpace, const Twine &N,
                                          Module *M) {}

void Function::removeFromParent() {}

void Function::eraseFromParent() {}

void Function::splice(Function::iterator ToIt, Function *FromF,
                      Function::iterator FromBeginIt,
                      Function::iterator FromEndIt) {}

Function::iterator Function::erase(Function::iterator FromIt,
                                   Function::iterator ToIt) {}

//===----------------------------------------------------------------------===//
// Function Implementation
//===----------------------------------------------------------------------===//

static unsigned computeAddrSpace(unsigned AddrSpace, Module *M) {}

Function::Function(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace,
                   const Twine &name, Module *ParentModule)
    :{}

Function::~Function() {}

void Function::BuildLazyArguments() const {}

static MutableArrayRef<Argument> makeArgArray(Argument *Args, size_t Count) {}

bool Function::isConstrainedFPIntrinsic() const {}

void Function::clearArguments() {}

void Function::stealArgumentListFrom(Function &Src) {}

void Function::deleteBodyImpl(bool ShouldDrop) {}

void Function::addAttributeAtIndex(unsigned i, Attribute Attr) {}

void Function::addFnAttr(Attribute::AttrKind Kind) {}

void Function::addFnAttr(StringRef Kind, StringRef Val) {}

void Function::addFnAttr(Attribute Attr) {}

void Function::addFnAttrs(const AttrBuilder &Attrs) {}

void Function::addRetAttr(Attribute::AttrKind Kind) {}

void Function::addRetAttr(Attribute Attr) {}

void Function::addRetAttrs(const AttrBuilder &Attrs) {}

void Function::addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) {}

void Function::addParamAttr(unsigned ArgNo, Attribute Attr) {}

void Function::addParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs) {}

void Function::removeAttributeAtIndex(unsigned i, Attribute::AttrKind Kind) {}

void Function::removeAttributeAtIndex(unsigned i, StringRef Kind) {}

void Function::removeFnAttr(Attribute::AttrKind Kind) {}

void Function::removeFnAttr(StringRef Kind) {}

void Function::removeFnAttrs(const AttributeMask &AM) {}

void Function::removeRetAttr(Attribute::AttrKind Kind) {}

void Function::removeRetAttr(StringRef Kind) {}

void Function::removeRetAttrs(const AttributeMask &Attrs) {}

void Function::removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) {}

void Function::removeParamAttr(unsigned ArgNo, StringRef Kind) {}

void Function::removeParamAttrs(unsigned ArgNo, const AttributeMask &Attrs) {}

void Function::addDereferenceableParamAttr(unsigned ArgNo, uint64_t Bytes) {}

bool Function::hasFnAttribute(Attribute::AttrKind Kind) const {}

bool Function::hasFnAttribute(StringRef Kind) const {}

bool Function::hasRetAttribute(Attribute::AttrKind Kind) const {}

bool Function::hasParamAttribute(unsigned ArgNo,
                                 Attribute::AttrKind Kind) const {}

Attribute Function::getAttributeAtIndex(unsigned i,
                                        Attribute::AttrKind Kind) const {}

Attribute Function::getAttributeAtIndex(unsigned i, StringRef Kind) const {}

bool Function::hasAttributeAtIndex(unsigned Idx,
                                   Attribute::AttrKind Kind) const {}

Attribute Function::getFnAttribute(Attribute::AttrKind Kind) const {}

Attribute Function::getFnAttribute(StringRef Kind) const {}

Attribute Function::getRetAttribute(Attribute::AttrKind Kind) const {}

uint64_t Function::getFnAttributeAsParsedInteger(StringRef Name,
                                                 uint64_t Default) const {}

/// gets the specified attribute from the list of attributes.
Attribute Function::getParamAttribute(unsigned ArgNo,
                                      Attribute::AttrKind Kind) const {}

void Function::addDereferenceableOrNullParamAttr(unsigned ArgNo,
                                                 uint64_t Bytes) {}

void Function::addRangeRetAttr(const ConstantRange &CR) {}

DenormalMode Function::getDenormalMode(const fltSemantics &FPType) const {}

DenormalMode Function::getDenormalModeRaw() const {}

DenormalMode Function::getDenormalModeF32Raw() const {}

const std::string &Function::getGC() const {}

void Function::setGC(std::string Str) {}

void Function::clearGC() {}

bool Function::hasStackProtectorFnAttr() const {}

/// Copy all additional attributes (those not needed to create a Function) from
/// the Function Src to this one.
void Function::copyAttributesFrom(const Function *Src) {}

MemoryEffects Function::getMemoryEffects() const {}
void Function::setMemoryEffects(MemoryEffects ME) {}

/// Determine if the function does not access memory.
bool Function::doesNotAccessMemory() const {}
void Function::setDoesNotAccessMemory() {}

/// Determine if the function does not access or only reads memory.
bool Function::onlyReadsMemory() const {}
void Function::setOnlyReadsMemory() {}

/// Determine if the function does not access or only writes memory.
bool Function::onlyWritesMemory() const {}
void Function::setOnlyWritesMemory() {}

/// Determine if the call can access memmory only using pointers based
/// on its arguments.
bool Function::onlyAccessesArgMemory() const {}
void Function::setOnlyAccessesArgMemory() {}

/// Determine if the function may only access memory that is
///  inaccessible from the IR.
bool Function::onlyAccessesInaccessibleMemory() const {}
void Function::setOnlyAccessesInaccessibleMemory() {}

/// Determine if the function may only access memory that is
///  either inaccessible from the IR or pointed to by its arguments.
bool Function::onlyAccessesInaccessibleMemOrArgMem() const {}
void Function::setOnlyAccessesInaccessibleMemOrArgMem() {}

bool Function::isTargetIntrinsic() const {}

void Function::updateAfterNameChange() {}

/// hasAddressTaken - returns true if there are any uses of this function
/// other than direct calls or invokes to it. Optionally ignores callback
/// uses, assume like pointer annotation calls, and references in llvm.used
/// and llvm.compiler.used variables.
bool Function::hasAddressTaken(const User **PutOffender,
                               bool IgnoreCallbackUses,
                               bool IgnoreAssumeLikeCalls, bool IgnoreLLVMUsed,
                               bool IgnoreARCAttachedCall,
                               bool IgnoreCastedDirectCall) const {}

bool Function::isDefTriviallyDead() const {}

/// callsFunctionThatReturnsTwice - Return true if the function has a call to
/// setjmp or other function that gcc recognizes as "returning twice".
bool Function::callsFunctionThatReturnsTwice() const {}

Constant *Function::getPersonalityFn() const {}

void Function::setPersonalityFn(Constant *Fn) {}

Constant *Function::getPrefixData() const {}

void Function::setPrefixData(Constant *PrefixData) {}

Constant *Function::getPrologueData() const {}

void Function::setPrologueData(Constant *PrologueData) {}

void Function::allocHungoffUselist() {}

template <int Idx>
void Function::setHungoffOperand(Constant *C) {}

void Function::setValueSubclassDataBit(unsigned Bit, bool On) {}

void Function::setEntryCount(ProfileCount Count,
                             const DenseSet<GlobalValue::GUID> *S) {}

void Function::setEntryCount(uint64_t Count, Function::ProfileCountType Type,
                             const DenseSet<GlobalValue::GUID> *Imports) {}

std::optional<ProfileCount> Function::getEntryCount(bool AllowSynthetic) const {}

DenseSet<GlobalValue::GUID> Function::getImportGUIDs() const {}

void Function::setSectionPrefix(StringRef Prefix) {}

std::optional<StringRef> Function::getSectionPrefix() const {}

bool Function::nullPointerIsDefined() const {}

bool llvm::NullPointerIsDefined(const Function *F, unsigned AS) {}