LLVM  7.0.0svn
Macros | Functions | Variables
MergeFunctions.cpp File Reference
#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>
Include dependency graph for MergeFunctions.cpp:

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 (NumDoubleWeak, "Number of new functions created")
 
static ValuecreateCast (IRBuilder<> &Builder, Value *V, Type *DestTy)
 
static bool isThunkProfitable (Function *F)
 

Variables

static cl::opt< unsignedNumFunctionsForSanityCheck ("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< boolMergeFunctionsPDI ("mergefunc-preserve-debug-info", cl::Hidden, cl::init(false), cl::desc("Preserve debug info in thunk when mergefunc " "transformations are made."))
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "mergefunc"

Definition at line 135 of file MergeFunctions.cpp.

Function Documentation

◆ createCast()

static Value* createCast ( IRBuilder<> &  Builder,
Value V,
Type DestTy 
)
static

◆ isThunkProfitable()

static bool isThunkProfitable ( Function F)
static

Definition at line 645 of file MergeFunctions.cpp.

References llvm::AMDGPU::HSAMD::Kernel::Key::Args, llvm::Function::args(), assert(), C, llvm::ScaledNumbers::compare(), llvm::Function::copyAttributesFrom(), llvm::BasicBlock::Create(), llvm::Function::Create(), createCast(), llvm::dbgs(), llvm::GlobalNumberState::erase(), llvm::Function::eraseFromParent(), F(), llvm::Function::front(), G, llvm::DebugLoc::get(), llvm::GlobalObject::getAlignment(), llvm::Function::getAttributes(), llvm::ConstantExpr::getBitCast(), 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(), llvm::GlobalValue::getType(), H, llvm::GlobalValue::hasGlobalUnnamedAddr(), llvm::GlobalValue::hasLocalLinkage(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::GlobalValue::isInterposable(), llvm::Type::isVoidTy(), LLVM_DEBUG, llvm::max(), MergeFunctionsPDI, llvm::GlobalValue::PrivateLinkage, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::sys::fs::remove(), llvm::Value::replaceAllUsesWith(), llvm::GlobalObject::setAlignment(), llvm::CallBase< InstTy >::setAttributes(), llvm::CallBase< InstTy >::setCallingConv(), llvm::Instruction::setDebugLoc(), llvm::GlobalValue::setLinkage(), llvm::CallInst::setTailCall(), llvm::BasicBlock::size(), llvm::Function::size(), llvm::Value::takeName(), llvm::Value::use_empty(), and llvm::Value::users().

◆ STATISTIC() [1/3]

STATISTIC ( NumFunctionsMerged  ,
"Number of functions merged"   
)

◆ STATISTIC() [2/3]

STATISTIC ( NumThunksWritten  ,
"Number of thunks generated"   
)

◆ STATISTIC() [3/3]

STATISTIC ( NumDoubleWeak  ,
"Number of new functions created"   
)

Variable Documentation

◆ MergeFunctionsPDI

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

Referenced by isThunkProfitable().

◆ NumFunctionsForSanityCheck

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