LLVM
8.0.1
|
#include "llvm/Transforms/IPO/ConstantMerge.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Transforms/IPO.h"
#include <algorithm>
#include <cassert>
#include <utility>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "constmerge" |
Enumerations | |
enum | CanMerge { CanMerge::No, CanMerge::Yes } |
Functions | |
STATISTIC (NumIdenticalMerged, "Number of identical global constants merged") | |
static void | FindUsedValues (GlobalVariable *LLVMUsed, SmallPtrSetImpl< const GlobalValue *> &UsedValues) |
Find values that are marked as llvm.used. More... | |
static bool | IsBetterCanonical (const GlobalVariable &A, const GlobalVariable &B) |
static bool | hasMetadataOtherThanDebugLoc (const GlobalVariable *GV) |
static void | copyDebugLocMetadata (const GlobalVariable *From, GlobalVariable *To) |
static unsigned | getAlignment (GlobalVariable *GV) |
static CanMerge | makeMergeable (GlobalVariable *Old, GlobalVariable *New) |
static void | replace (Module &M, GlobalVariable *Old, GlobalVariable *New) |
static bool | mergeConstants (Module &M) |
INITIALIZE_PASS (ConstantMergeLegacyPass, "constmerge", "Merge Duplicate Global Constants", false, false) ModulePass *llvm | |
#define DEBUG_TYPE "constmerge" |
Definition at line 41 of file ConstantMerge.cpp.
|
strong |
Enumerator | |
---|---|
No | |
Yes |
Definition at line 94 of file ConstantMerge.cpp.
|
static |
Definition at line 79 of file ConstantMerge.cpp.
References llvm::GlobalVariable::addDebugInfo(), and llvm::GlobalVariable::getDebugInfo().
Referenced by replace().
|
static |
Find values that are marked as llvm.used.
Definition at line 46 of file ConstantMerge.cpp.
References llvm::GlobalVariable::getInitializer(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::SmallPtrSetImpl< PtrType >::insert(), and llvm::Value::stripPointerCastsNoFollowAliases().
Referenced by mergeConstants().
|
static |
Definition at line 87 of file ConstantMerge.cpp.
References llvm::AMDGPU::HSAMD::Kernel::Arg::Key::Align, llvm::GlobalObject::getAlignment(), llvm::Module::getDataLayout(), llvm::GlobalValue::getParent(), and llvm::DataLayout::getPreferredAlignment().
Referenced by replace().
|
static |
Definition at line 70 of file ConstantMerge.cpp.
References llvm::GlobalObject::getAllMetadata(), and llvm::LLVMContext::MD_dbg.
Referenced by llvm::Instruction::getAllMetadataOtherThanDebugLoc(), makeMergeable(), and mergeConstants().
INITIALIZE_PASS | ( | ConstantMergeLegacyPass | , |
"constmerge" | , | ||
"Merge Duplicate Global Constants" | , | ||
false | , | ||
false | |||
) |
Definition at line 281 of file ConstantMerge.cpp.
|
static |
Definition at line 59 of file ConstantMerge.cpp.
References llvm::GlobalValue::hasGlobalUnnamedAddr(), and llvm::GlobalValue::hasLocalLinkage().
Referenced by mergeConstants().
|
static |
Definition at line 95 of file ConstantMerge.cpp.
References assert(), llvm::GlobalValue::hasGlobalUnnamedAddr(), hasMetadataOtherThanDebugLoc(), No, llvm::GlobalValue::None, llvm::GlobalValue::setUnnamedAddr(), and Yes.
Referenced by mergeConstants().
Definition at line 125 of file ConstantMerge.cpp.
References llvm::SmallVectorImpl< T >::clear(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::dbgs(), E, llvm::GlobalVariable::eraseFromParent(), FindUsedValues(), llvm::PointerType::getAddressSpace(), llvm::Module::getGlobalVariable(), llvm::GlobalVariable::getInitializer(), llvm::Value::getName(), llvm::GlobalValue::getType(), llvm::Module::global_begin(), llvm::Module::global_end(), llvm::GlobalVariable::hasDefinitiveInitializer(), llvm::GlobalValue::hasLocalLinkage(), hasMetadataOtherThanDebugLoc(), llvm::GlobalObject::hasSection(), IsBetterCanonical(), llvm::GlobalVariable::isConstant(), llvm::GlobalValue::isWeakForLinker(), LLVM_DEBUG, makeMergeable(), No, llvm::SmallVectorTemplateBase< T >::push_back(), llvm::Constant::removeDeadConstantUsers(), replace(), llvm::SmallVectorBase::size(), and llvm::Value::use_empty().
Referenced by llvm::ConstantMergePass::run().
|
static |
Definition at line 106 of file ConstantMerge.cpp.
References assert(), copyDebugLocMetadata(), llvm::dbgs(), llvm::GlobalVariable::eraseFromParent(), llvm::GlobalObject::getAlignment(), getAlignment(), llvm::Value::getName(), llvm::GlobalValue::hasLocalLinkage(), LLVM_DEBUG, llvm::max(), llvm::Value::replaceAllUsesWith(), and llvm::GlobalObject::setAlignment().
Referenced by llvm::CodeViewDebug::CodeViewDebug(), computeRelativePath(), llvm::sys::path::convert_to_slash(), getSignature(), llvm::pdb::PDBSymbolCompiland::getSourceFileFullPath(), llvm::orc::MaterializationResponsibility::getSymbols(), GetVBR(), isIgnorableInst(), lowerV8I16GeneralSingleInputVectorShuffle(), mergeConstants(), llvm::sys::path::native(), llvm::LiveVariables::replaceKillInstruction(), llvm::orc::JITDylib::setGenerator(), simplifyAllocaArraySize(), llvm::UnrollLoop(), and llvm::sroa::AllocaSliceRewriter::visit().
STATISTIC | ( | NumIdenticalMerged | , |
"Number of identical global constants merged" | |||
) |