LLVM
8.0.1
|
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Use.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/IR/ValueMap.h"
#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Utils/FunctionComparator.h"
#include <algorithm>
#include <cassert>
#include <iterator>
#include <set>
#include <utility>
#include <vector>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "mergefunc" |
Functions | |
STATISTIC (NumFunctionsMerged, "Number of functions merged") | |
STATISTIC (NumThunksWritten, "Number of thunks generated") | |
STATISTIC (NumAliasesWritten, "Number of aliases generated") | |
STATISTIC (NumDoubleWeak, "Number of new functions created") | |
static Value * | createCast (IRBuilder<> &Builder, Value *V, Type *DestTy) |
static bool | isThunkProfitable (Function *F) |
static bool | canCreateAliasFor (Function *F) |
static bool | isFuncOrderCorrect (const Function *F, const Function *G) |
Variables | |
static cl::opt< unsigned > | NumFunctionsForSanityCheck ("mergefunc-sanity", cl::desc("How many functions in module could be used for " "MergeFunctions pass sanity check. " "'0' disables this check. Works only with '-debug' key."), cl::init(0), cl::Hidden) |
static cl::opt< bool > | MergeFunctionsPDI ("mergefunc-preserve-debug-info", cl::Hidden, cl::init(false), cl::desc("Preserve debug info in thunk when mergefunc " "transformations are made.")) |
static cl::opt< bool > | MergeFunctionsAliases ("mergefunc-use-aliases", cl::Hidden, cl::init(false), cl::desc("Allow mergefunc to create aliases")) |
#define DEBUG_TYPE "mergefunc" |
Definition at line 135 of file MergeFunctions.cpp.
Definition at line 752 of file MergeFunctions.cpp.
References assert(), llvm::ScaledNumbers::compare(), llvm::Function::copyAttributesFrom(), llvm::GlobalAlias::create(), llvm::Function::Create(), llvm::dbgs(), llvm::GlobalNumberState::erase(), llvm::Function::eraseFromParent(), G, llvm::GlobalValue::getAddressSpace(), llvm::GlobalObject::getAlignment(), llvm::ConstantExpr::getBitCast(), llvm::Function::getFunctionType(), llvm::GlobalValue::getLinkage(), llvm::GlobalValue::getParent(), llvm::GlobalValue::getType(), llvm::GlobalValue::getVisibility(), llvm::GlobalValue::Global, llvm::GlobalValue::hasExternalLinkage(), llvm::GlobalValue::hasGlobalUnnamedAddr(), llvm::GlobalValue::hasLinkOnceLinkage(), llvm::GlobalValue::hasLocalLinkage(), llvm::GlobalValue::hasWeakLinkage(), I, llvm::GlobalValue::isDiscardableIfUnused(), llvm::GlobalValue::isInterposable(), isThunkProfitable(), LLVM_DEBUG, llvm::max(), MergeFunctionsAliases, MergeFunctionsPDI, llvm::GlobalValue::PrivateLinkage, llvm::Value::replaceAllUsesWith(), llvm::GlobalObject::setAlignment(), llvm::GlobalValue::setLinkage(), llvm::Value::takeName(), and llvm::Value::use_empty().
Definition at line 486 of file MergeFunctions.cpp.
References Arg, assert(), llvm::BasicBlock::back(), llvm::BasicBlock::begin(), llvm::Function::begin(), llvm::IRBuilder< T, Inserter >::CreateBitCast(), llvm::IRBuilder< T, Inserter >::CreateExtractValue(), llvm::IRBuilder< T, Inserter >::CreateInsertValue(), llvm::IRBuilder< T, Inserter >::CreateIntToPtr(), llvm::IRBuilder< T, Inserter >::CreatePtrToInt(), llvm::dbgs(), E, llvm::BasicBlock::end(), llvm::Function::end(), llvm::Instruction::eraseFromParent(), llvm::BasicBlock::eraseFromParent(), G, llvm::UndefValue::get(), llvm::Type::getStructElementType(), llvm::Type::getStructNumElements(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), I, llvm::Type::isIntegerTy(), llvm::DILocalVariable::isParameter(), llvm::Type::isPointerTy(), llvm::Type::isStructTy(), LLVM_DEBUG, llvm::makeArrayRef(), llvm::iplist_impl< IntrusiveListT, TraitsT >::pop_back(), llvm::Metadata::print(), llvm::Value::print(), SI, and llvm::Value::users().
Referenced by isThunkProfitable().
Definition at line 881 of file MergeFunctions.cpp.
References assert(), C, llvm::dbgs(), F(), llvm::Value::getName(), llvm::GlobalValue::hasLocalLinkage(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::GlobalValue::isInterposable(), LLVM_DEBUG, llvm::sys::fs::remove(), and llvm::Value::users().
Definition at line 659 of file MergeFunctions.cpp.
References llvm::AMDGPU::HSAMD::Kernel::Key::Args, llvm::Function::args(), llvm::Function::copyAttributesFrom(), llvm::BasicBlock::Create(), llvm::Function::Create(), createCast(), llvm::dbgs(), llvm::Function::eraseFromParent(), F(), llvm::Function::front(), G, llvm::DebugLoc::get(), llvm::GlobalValue::getAddressSpace(), llvm::Function::getAttributes(), llvm::Function::getCallingConv(), llvm::Function::getContext(), llvm::Function::getEntryBlock(), llvm::Function::getFunctionType(), llvm::GlobalValue::getLinkage(), llvm::Value::getName(), llvm::FunctionType::getParamType(), llvm::GlobalValue::getParent(), llvm::Function::getReturnType(), llvm::Function::getSubprogram(), H, llvm::Type::isVoidTy(), LLVM_DEBUG, MergeFunctionsPDI, llvm::SmallVectorTemplateBase< T >::push_back(), llvm::Value::replaceAllUsesWith(), llvm::CallBase::setAttributes(), llvm::CallBase::setCallingConv(), llvm::Instruction::setDebugLoc(), llvm::CallInst::setTailCall(), llvm::BasicBlock::size(), llvm::Function::size(), and llvm::Value::takeName().
Referenced by canCreateAliasFor().
STATISTIC | ( | NumFunctionsMerged | , |
"Number of functions merged" | |||
) |
STATISTIC | ( | NumThunksWritten | , |
"Number of thunks generated" | |||
) |
STATISTIC | ( | NumAliasesWritten | , |
"Number of aliases generated" | |||
) |
STATISTIC | ( | NumDoubleWeak | , |
"Number of new functions created" | |||
) |
|
static |
Referenced by canCreateAliasFor().
|
static |
Referenced by canCreateAliasFor(), and isThunkProfitable().