LLVM API Documentation
#include "llvm/Transforms/IPO.h"#include "llvm/ADT/DenseMap.h"#include "llvm/ADT/FoldingSet.h"#include "llvm/ADT/Statistic.h"#include "llvm/Constants.h"#include "llvm/InlineAsm.h"#include "llvm/Instructions.h"#include "llvm/LLVMContext.h"#include "llvm/Module.h"#include "llvm/Pass.h"#include "llvm/Support/CallSite.h"#include "llvm/Support/Compiler.h"#include "llvm/Support/Debug.h"#include "llvm/Support/ErrorHandling.h"#include "llvm/Support/raw_ostream.h"#include <map>#include <vector>
Go to the source code of this file.
Defines | |
| #define | DEBUG_TYPE "mergefunc" |
Enumerations | |
| enum | LinkageCategory { ExternalStrong, ExternalWeak, Internal } |
Functions | |
| STATISTIC (NumFunctionsMerged,"Number of functions merged") | |
| ModulePass * | llvm::createMergeFunctionsPass () |
| static unsigned long | hash (const Function *F) |
| static Value * | IgnoreBitcasts (Value *V) |
| static bool | isEquivalentType (const Type *Ty1, const Type *Ty2) |
| static bool | isEquivalentOperation (const Instruction *I1, const Instruction *I2) |
| static bool | compare (const Value *V, const Value *U) |
| static bool | equals (const BasicBlock *BB1, const BasicBlock *BB2, DenseMap< const Value *, const Value * > &ValueMap, DenseMap< const Value *, const Value * > &SpeculationMap) |
| static bool | equals (const Function *F, const Function *G) |
| static LinkageCategory | categorize (const Function *F) |
| static void | ThunkGToF (Function *F, Function *G) |
| static void | AliasGToF (Function *F, Function *G) |
| static bool | fold (std::vector< Function * > &FnVec, unsigned i, unsigned j) |
Variables | |
| static RegisterPass < MergeFunctions > | X ("mergefunc","Merge Functions") |
| #define DEBUG_TYPE "mergefunc" |
Definition at line 42 of file MergeFunctions.cpp.
| enum LinkageCategory |
Definition at line 519 of file MergeFunctions.cpp.
References llvm::Function::eraseFromParent(), llvm::GlobalValue::getAlignment(), llvm::ConstantExpr::getBitCast(), llvm::GlobalValue::getLinkage(), llvm::GlobalValue::getParent(), llvm::GlobalValue::getType(), llvm::GlobalValue::getVisibility(), llvm::GlobalValue::hasExternalLinkage(), llvm::GlobalValue::hasLocalLinkage(), llvm::GlobalValue::hasWeakLinkage(), llvm::Value::replaceAllUsesWith(), llvm::GlobalValue::setAlignment(), llvm::GlobalValue::setVisibility(), llvm::Value::takeName(), and ThunkGToF().
Referenced by fold().
| static LinkageCategory categorize | ( | const Function * | F | ) | [static] |
Definition at line 452 of file MergeFunctions.cpp.
References llvm::GlobalValue::AppendingLinkage, llvm::GlobalValue::AvailableExternallyLinkage, llvm::GlobalValue::CommonLinkage, llvm::GlobalValue::DLLExportLinkage, llvm::GlobalValue::DLLImportLinkage, llvm::GlobalValue::ExternalLinkage, ExternalStrong, ExternalWeak, llvm::GlobalValue::ExternalWeakLinkage, llvm::GlobalValue::getLinkage(), llvm::GlobalValue::GhostLinkage, Internal, llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::LinkerPrivateLinkage, llvm::GlobalValue::LinkOnceAnyLinkage, llvm::GlobalValue::LinkOnceODRLinkage, llvm_unreachable, llvm::GlobalValue::PrivateLinkage, llvm::GlobalValue::WeakAnyLinkage, and llvm::GlobalValue::WeakODRLinkage.
Referenced by fold().
Definition at line 240 of file MergeFunctions.cpp.
References llvm::InlineAsm::getAsmString(), llvm::InlineAsm::getConstraintString(), llvm::Value::getType(), and isEquivalentType().
Referenced by equals(), LowerSELECT_CC(), and llvm::APInt::tcDivide().
Definition at line 356 of file MergeFunctions.cpp.
References llvm::Function::arg_begin(), llvm::Function::arg_end(), llvm::Function::arg_size(), llvm::DenseMap< KeyT, ValueT, KeyInfoT, ValueInfoT >::begin(), E, llvm::DenseMap< KeyT, ValueT, KeyInfoT, ValueInfoT >::end(), equals(), llvm::Function::getAttributes(), llvm::Function::getCallingConv(), llvm::Function::getEntryBlock(), llvm::Function::getFunctionType(), llvm::Function::getGC(), llvm::GlobalValue::getSection(), llvm::Function::hasGC(), llvm::GlobalValue::hasSection(), isEquivalentType(), and llvm::Function::isVarArg().
| static bool equals | ( | const BasicBlock * | BB1, | |
| const BasicBlock * | BB2, | |||
| DenseMap< const Value *, const Value * > & | ValueMap, | |||
| DenseMap< const Value *, const Value * > & | SpeculationMap | |||
| ) | [static] |
Definition at line 268 of file MergeFunctions.cpp.
References llvm::BasicBlock::begin(), compare(), llvm::BasicBlock::end(), FI, GE, llvm::Value::getType(), llvm::Value::getValueID(), llvm::GetElementPtrInst::hasAllZeroIndices(), IgnoreBitcasts(), isEquivalentOperation(), and isEquivalentType().
Referenced by llvm::StringRef::count(), equals(), and llvm::StringRef::find().
Definition at line 533 of file MergeFunctions.cpp.
References AliasGToF(), categorize(), llvm::Function::copyAttributesFrom(), llvm::Function::Create(), ExternalStrong, ExternalWeak, F, G, llvm::GlobalValue::getAlignment(), llvm::Function::getFunctionType(), llvm::GlobalValue::getLinkage(), llvm::GlobalValue::getParent(), H, llvm::Function::hasAddressTaken(), Internal, llvm::GlobalValue::InternalLinkage, llvm_unreachable, llvm::Value::replaceAllUsesWith(), llvm::GlobalValue::setAlignment(), llvm::GlobalValue::setLinkage(), std::swap(), llvm::Value::takeName(), and ThunkGToF().
Definition at line 85 of file MergeFunctions.cpp.
References llvm::FoldingSetNodeID::AddBoolean(), llvm::FoldingSetNodeID::AddInteger(), llvm::FoldingSetNodeID::ComputeHash(), llvm::Function::getCallingConv(), llvm::Function::getFunctionType(), llvm::FunctionType::getNumParams(), llvm::FunctionType::getParamType(), llvm::FunctionType::getReturnType(), llvm::Type::getTypeID(), llvm::Function::hasGC(), ID, llvm::FunctionType::isVarArg(), and llvm::Function::size().
Referenced by llvm::DenseMapInfo< Expression >::getHashValue(), llvm::APInt::getHashValue(), and llvm::APFloat::getHashValue().
IgnoreBitcasts - given a bitcast, returns the first non-bitcast found by walking the chain of cast operands. Otherwise, returns the argument.
Definition at line 101 of file MergeFunctions.cpp.
Referenced by equals().
| static bool isEquivalentOperation | ( | const Instruction * | I1, | |
| const Instruction * | I2 | |||
| ) | [static] |
isEquivalentOperation - determine whether the two operations are the same except that pointer-to-A and pointer-to-B are equivalent. This should be kept in sync with Instruction::isSameOperationAs.
Definition at line 188 of file MergeFunctions.cpp.
References llvm::Intrinsic::getAttributes(), llvm::User::getNumOperands(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), getPredicate(), llvm::AttrListPtr::getRawPointer(), llvm::Value::getType(), llvm::Value::hasSameSubclassOptionalData(), isEquivalentType(), and LI.
Referenced by equals().
isEquivalentType - any two pointers are equivalent. Otherwise, standard type equivalence rules apply.
Definition at line 110 of file MergeFunctions.cpp.
References llvm::Type::ArrayTyID, llvm::Type::DoubleTyID, llvm::Type::FloatTyID, llvm::Type::FP128TyID, llvm::Type::FunctionTyID, llvm::PointerType::getAddressSpace(), llvm::SequentialType::getElementType(), llvm::StructType::getElementType(), llvm::StructType::getNumElements(), llvm::FunctionType::getNumParams(), llvm::FunctionType::getParamType(), llvm::FunctionType::getReturnType(), llvm::Type::getTypeID(), llvm::Type::IntegerTyID, llvm::StructType::isPacked(), llvm::FunctionType::isVarArg(), llvm::Type::LabelTyID, llvm_unreachable, llvm::Type::MetadataTyID, llvm::Type::OpaqueTyID, llvm::Type::PointerTyID, llvm::Type::PPC_FP128TyID, llvm::Type::StructTyID, llvm::Type::VectorTyID, llvm::Type::VoidTyID, and llvm::Type::X86_FP80TyID.
Referenced by compare(), equals(), and isEquivalentOperation().
| STATISTIC | ( | NumFunctionsMerged | , | |
| "Number of functions merged" | ||||
| ) |
Definition at line 480 of file MergeFunctions.cpp.
References AI, llvm::Function::arg_begin(), llvm::Function::arg_end(), BB, llvm::Function::begin(), llvm::Function::copyAttributesFrom(), llvm::BasicBlock::Create(), llvm::ReturnInst::Create(), llvm::Function::Create(), llvm::CallInst::Create(), llvm::Function::eraseFromParent(), llvm::Function::getCallingConv(), llvm::Function::getContext(), llvm::Function::getFunctionType(), llvm::GlobalValue::getLinkage(), llvm::FunctionType::getParamType(), llvm::GlobalValue::getParent(), llvm::Function::getReturnType(), llvm::Value::getType(), llvm::AllocationInst::getType(), llvm::Type::getVoidTy(), llvm::Value::replaceAllUsesWith(), llvm::CallInst::setCallingConv(), llvm::CallInst::setTailCall(), and llvm::Value::takeName().
Referenced by AliasGToF(), and fold().
char ID [static] |
Definition at line 66 of file MergeFunctions.cpp.
RegisterPass<MergeFunctions> X("mergefunc","Merge Functions") [static] |